RPA Toolkit
build changes for macos. jrs is still broken - objcopy doesn't work
authorMartin Stoilov <martin@rpasearch.com>
Fri, 29 Jul 2011 06:11:21 +0000 (23:11 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Fri, 29 Jul 2011 06:11:21 +0000 (23:11 -0700)
20 files changed:
arch/darwin/x86_64/rtypes.h [new file with mode: 0644]
build/darwin/x86_64/Makefile [new file with mode: 0644]
rgrep/build/darwin/i386/Makefile
rgrep/build/darwin/rgrep.mk
rgrep/build/darwin/x86_64/Makefile [new file with mode: 0644]
rjs/build/darwin/i386/Makefile
rjs/build/darwin/rjs.mk
rjs/build/darwin/x86_64/Makefile [new file with mode: 0644]
rlib/build/darwin/i386/Makefile
rlib/build/darwin/x86_64/Makefile [new file with mode: 0644]
rpa/build/darwin/i386/Makefile
rpa/build/darwin/x86_64/Makefile [new file with mode: 0644]
rvm/build/darwin/i386/Makefile
rvm/build/darwin/x86_64/Makefile [new file with mode: 0644]
tests/testmisc/build/darwin/i386/Makefile
tests/testmisc/build/darwin/x86_64/Makefile [new file with mode: 0644]
tests/testrjs/build/darwin/i386/Makefile
tests/testrjs/build/darwin/x86_64/Makefile [new file with mode: 0644]
tests/testrpa/build/darwin/i386/Makefile
tests/testrpa/build/darwin/x86_64/Makefile [new file with mode: 0644]

diff --git a/arch/darwin/x86_64/rtypes.h b/arch/darwin/x86_64/rtypes.h
new file mode 100644 (file)
index 0000000..132adaa
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef _RTYPES_H_
+#define _RTYPES_H_
+
+/* 
+ * Architecture dependent types. These types have to be redefined
+ * for every architecture
+ */
+typedef signed char rint8;
+typedef unsigned char ruint8;
+typedef signed short rint16;
+typedef unsigned short ruint16;
+typedef signed int rint32;
+typedef unsigned int ruint32;
+typedef signed long long rint64;
+typedef unsigned long long ruint64;
+typedef unsigned int ratomic_t;
+typedef unsigned long ruword;
+typedef long rword;
+
+/*
+ * Common types. These types should be the same for most of the architectures.
+ */
+typedef int rboolean;
+typedef void *rpointer;
+typedef const void *rconstpointer;
+typedef struct {ruint32 p1; ruint32 p2;} rpair_t;
+
+/*
+ * Atomic operations (Architecture Dependent)
+ */
+#define R_ATOMIC_CMPXCHG(ptr, oldval, newval, resptr) \
+               do { __asm__ __volatile__ ("lock; cmpxchgl %2, %1" \
+                       : "=a" (*(resptr)), "=m" (*ptr) \
+                       : "r" (newval), "m" (*ptr), "0" (oldval)); } while (0)
+
+#define R_ATOMIC_XCHG(ptr, val) \
+               do { __asm__ __volatile__("lock; xchgl %0,%1" \
+                       :"=r" ((ruint32) val) \
+                       :"m" (*(volatile ruint32 *)ptr), "0" (val) \
+                       :"memory"); } while (0)
+
+#define R_ATOMIC_ADD(ptr, val) \
+               do { __asm__ __volatile__ ("addl %1,%0" \
+                       : "=m" (*ptr) \
+                       : "ir" (val), "m" (*ptr)); } while (0)
+
+#define R_ATOMIC_SUB(ptr, val) \
+               do { __asm__ __volatile__ ("subl %1,%0" \
+                       : "=m" (*ptr) \
+                       : "ir" (val), "m" (*ptr)); } while (0)
+
+
+#define R_DEBUG_BRAKE __asm__ ("int $3")
+#define R_ASSERT(__a__) do {if (!(__a__)) R_DEBUG_BRAKE; } while (0)
+#define R_SIZE_ALIGN(s, n) ((((s) + (n) - 1) / (n)) * (n))
+#define R_MIN(a, b) ((a) < (b) ? (a): (b))
+#define R_MAX(a, b) ((a) > (b) ? (a): (b))
+
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((rpointer)0)
+#endif
+#endif
+
+#ifndef TRUE
+#define TRUE ((rboolean)1)
+#endif
+
+#ifndef FALSE
+#define FALSE ((rboolean)0)
+#endif
+
+
+typedef enum {
+       RVALSET_NONE = 0,
+       RVALSET_OR,
+       RVALSET_XOR,
+       RVALSET_AND,
+} rvalset_t;
+
+
+#endif
+
diff --git a/build/darwin/x86_64/Makefile b/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..c72041e
--- /dev/null
@@ -0,0 +1,6 @@
+SRCDIR = ../../..
+ARCHDIR = $(shell basename $(shell pwd))
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+
+include ../include.mk
+include ../build.mk
index 978ea8d..af54eb4 100644 (file)
@@ -2,17 +2,19 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 SRCDIR = ../../../..
-
+MACH = -m32
 
 CC = gcc
 AR = ar
+
+CFLAGS = $(MACH)
 ifeq ($(BLDCFG), release)
-CFLAGS = -O3
+CFLAGS += -O3
 else
 ifeq ($(BLDCFG), profile)
-CFLAGS = -O0 -pg
+CFLAGS += -O0 -pg
 else
-CFLAGS = -g -O0 -Wall 
+CFLAGS += -g -O0 -Wall 
 endif
 endif
 
@@ -20,9 +22,7 @@ ifeq ($(CCBLD), yes)
 CFLAGS += -fprofile-arcs -ftest-coverage
 endif
 
-CFLAGS += $(MACH) $(INCLUDE)
-
-CFLAGS := $(CFLAGS)
+CFLAGS += $(INCLUDE)
 LDFLAGS = $(MACH)
 
 
index 515ccd4..01daa32 100644 (file)
@@ -17,7 +17,7 @@ RPAGREP       = rgrep
 all : $(OUTDIR) $(OUTDIR)/$(RPAGREP)
 
 $(OUTDIR)/$(RPAGREP) : $(OBJECTS)
-       $(CC) $(ARCH) -o $@ $^ $(LIBS)
+       $(CC) $(MACH) -o $@ $^ $(LIBS)
 
 
 $(OUTDIR)/%.o: $(RGREP_SRCDIR)/%.c
diff --git a/rgrep/build/darwin/x86_64/Makefile b/rgrep/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..efc6949
--- /dev/null
@@ -0,0 +1,29 @@
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+SRCDIR = ../../../..
+MACH = -m64
+
+CC = gcc
+AR = ar
+
+CFLAGS = $(MACH)
+ifeq ($(BLDCFG), release)
+CFLAGS += -O3
+else
+ifeq ($(BLDCFG), profile)
+CFLAGS += -O0 -pg
+else
+CFLAGS += -g -O0 -Wall 
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(INCLUDE)
+LDFLAGS = $(MACH)
+
+
+include ../rgrep.mk
index d9d48bf..0824497 100644 (file)
@@ -3,25 +3,26 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
-ELFARCH = elf32-i386
+MACH = -m32
+ELFARCH = mach-o-i386
 BINARCH = i386
 
 CC = gcc
 AR = ar
 LD = ld
-OC = objcopy
+OC = gobjcopy
 
 ifeq ($(BLDCFG), release)
-CFLAGS := -fPIC -O3
+CFLAGS := $(MACH) -fPIC -O3
 else
-CFLAGS := -fPIC -O0 -g -Wall 
+CFLAGS := $(MACH) -fPIC -O0 -g -Wall 
 endif
 
 ifeq ($(CCBLD), yes)
 CFLAGS += -fprofile-arcs -ftest-coverage
 endif
 
-CFLAGS += $(MACH) $(INCLUDE)
+CFLAGS += $(INCLUDE)
 LDFLAGS := $(MACH)
 
 
index 3ca8f61..798ef1c 100644 (file)
@@ -18,7 +18,7 @@ RJS_OBJECTS = \
        $(OUTDIR)/rjsparser.o \
        $(OUTDIR)/rjscompiler.o \
        $(OUTDIR)/rjsrules.o \
-       $(OUTDIR)/rjsfile.o \   
+       $(OUTDIR)/rjsfile.o \
        $(OUTDIR)/ecma262.o \
 
 
@@ -43,7 +43,10 @@ $(RJS_SO): $(RJS_OBJECTS)
        $(CC) $(LDFLAGS) -shared -Wl,-soname,librjs.so -o $@ $^
 
 $(OUTDIR)/%.o: $(RJS_SRCDIR)/%.rpa
-       $(OC) --input binary --output $(ELFARCH) --binary-architecture $(BINARCH) $(RJS_SRCDIR)/$*.rpa $(OUTDIR)/$*.o
+       $(OC) --input-target binary --output-target $(ELFARCH) --binary-architecture $(BINARCH) $(RJS_SRCDIR)/$*.rpa $(OUTDIR)/$*.o
+#      gobjcopy -I binary -O mach-o-x86-64 -B i386:x86-64 $(RJS_SRCDIR)/$*.rpa $(OUTDIR)/$*.o
+
+
 
 $(OUTDIR):
        @mkdir $(OUTDIR)
diff --git a/rjs/build/darwin/x86_64/Makefile b/rjs/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..06b6114
--- /dev/null
@@ -0,0 +1,29 @@
+SRCDIR = ../../../..
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m64
+ELFARCH = mach-o-x86-64
+BINARCH = i386:x86-64
+
+CC = gcc
+AR = ar
+LD = ld
+OC = gobjcopy
+
+ifeq ($(BLDCFG), release)
+CFLAGS := $(MACH) -fPIC -O3
+else
+CFLAGS := $(MACH) -fPIC -O0 -g -Wall 
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(INCLUDE)
+LDFLAGS := $(MACH)
+
+
+include ../rjs.mk
index 0bafae4..09876c0 100644 (file)
@@ -3,19 +3,21 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m32
 
 CC = gcc
 AR = ar
 LD = ld
 
+CFLAGS := $(MACH)
 ifeq ($(BLDCFG), release)
-CFLAGS := -fPIC -O3
+CFLAGS += -fPIC -O3
 else 
 ifeq ($(BLDCFG), profile)
-CFLAGS := -fPIC -O0 -pg -Wall 
+CFLAGS += -fPIC -O0 -pg -Wall
 CFLAGS += -DR_DEBUG_MEMALLOC
 else
-CFLAGS := -fPIC -O0 -g -Wall 
+CFLAGS += -fPIC -O0 -g -Wall
 CFLAGS += -DR_DEBUG_MEMALLOC
 endif
 endif
@@ -24,7 +26,7 @@ ifeq ($(CCBLD), yes)
 CFLAGS += -fprofile-arcs -ftest-coverage
 endif
 
-CFLAGS += $(MACH) $(INCLUDE)
+CFLAGS +=  $(INCLUDE)
 LDFLAGS := $(MACH)
 
 include $(SRCDIR)/build/$(OS)/include.mk
diff --git a/rlib/build/darwin/x86_64/Makefile b/rlib/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..f55e903
--- /dev/null
@@ -0,0 +1,33 @@
+SRCDIR = ../../../..
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m64
+
+CC = gcc
+AR = ar
+LD = ld
+
+CFLAGS := $(MACH)
+ifeq ($(BLDCFG), release)
+CFLAGS += -fPIC -O3
+else 
+ifeq ($(BLDCFG), profile)
+CFLAGS += -fPIC -O0 -pg -Wall
+CFLAGS += -DR_DEBUG_MEMALLOC
+else
+CFLAGS += -fPIC -O0 -g -Wall
+CFLAGS += -DR_DEBUG_MEMALLOC
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS +=  $(INCLUDE)
+LDFLAGS := $(MACH)
+
+include $(SRCDIR)/build/$(OS)/include.mk
+include ../rlib.mk
index 68f3657..06a4a53 100644 (file)
@@ -3,23 +3,25 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m32
 
 CC = gcc
 AR = ar
 LD = ld
 
+CFLAGS := $(MACH)
 ifeq ($(BLDCFG), release)
-CFLAGS := -fPIC -O3
+CFLAGS += -fPIC -O3
 else
-CFLAGS := -fPIC -O0 -g -Wall 
+CFLAGS += -fPIC -O0 -g -Wall 
 endif
 
 ifeq ($(CCBLD), yes)
 CFLAGS += -fprofile-arcs -ftest-coverage
 endif
 
-CFLAGS += $(MACH) $(INCLUDE)
+CFLAGS += $(INCLUDE)
 LDFLAGS := $(MACH)
 
-include ../../../../build/$(OS)/include.mk
+include $(SRCDIR)/build/$(OS)/include.mk
 include ../rpa.mk
diff --git a/rpa/build/darwin/x86_64/Makefile b/rpa/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..1a333c0
--- /dev/null
@@ -0,0 +1,27 @@
+SRCDIR = ../../../..
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m64
+
+CC = gcc
+AR = ar
+LD = ld
+
+CFLAGS := $(MACH)
+ifeq ($(BLDCFG), release)
+CFLAGS += -fPIC -O3
+else
+CFLAGS += -fPIC -O0 -g -Wall 
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(INCLUDE)
+LDFLAGS := $(MACH)
+
+include $(SRCDIR)/build/$(OS)/include.mk
+include ../rpa.mk
index ace6ca2..0b1cbe9 100644 (file)
@@ -3,18 +3,20 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m32
 
 CC = gcc
 AR = ar
 LD = ld
 
+CFLAGS += $(MACH)
 ifeq ($(BLDCFG), release)
-CFLAGS := -fPIC -O3
+CFLAGS += -fPIC -O3
 else
 ifeq ($(BLDCFG), profile)
-CFLAGS := -fPIC -O0 -pg -Wall 
+CFLAGS += -fPIC -O0 -pg -Wall 
 else
-CFLAGS := -fPIC -O0 -g -Wall 
+CFLAGS += -fPIC -O0 -g -Wall 
 endif
 endif
 
@@ -23,7 +25,7 @@ CFLAGS += -fprofile-arcs -ftest-coverage
 endif
 
 
-CFLAGS += $(MACH) $(INCLUDE)
+CFLAGS += $(INCLUDE)
 LDFLAGS := $(MACH)
 
 include $(SRCDIR)/build/$(OS)/include.mk
diff --git a/rvm/build/darwin/x86_64/Makefile b/rvm/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..a64eff9
--- /dev/null
@@ -0,0 +1,32 @@
+SRCDIR = ../../../..
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+INCLUDE = -I$(SRCDIR)/arch/$(OS)/$(ARCHDIR)
+MACH = -m64
+
+CC = gcc
+AR = ar
+LD = ld
+
+CFLAGS += $(MACH)
+ifeq ($(BLDCFG), release)
+CFLAGS += -fPIC -O3
+else
+ifeq ($(BLDCFG), profile)
+CFLAGS += -fPIC -O0 -pg -Wall 
+else
+CFLAGS += -fPIC -O0 -g -Wall 
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+
+CFLAGS += $(INCLUDE)
+LDFLAGS := $(MACH)
+
+include $(SRCDIR)/build/$(OS)/include.mk
+include ../rvm.mk
index d1ea48f..22e06b7 100644 (file)
@@ -2,7 +2,7 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 SRCDIR = ../../../../..
-
+MACH = -m32
 
 CC = gcc
 AR = ar
diff --git a/tests/testmisc/build/darwin/x86_64/Makefile b/tests/testmisc/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..afe6f4e
--- /dev/null
@@ -0,0 +1,29 @@
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+SRCDIR = ../../../../..
+MACH = -m64
+
+CC = gcc
+AR = ar
+ifeq ($(BLDCFG), release)
+CFLAGS = -O3
+else
+ifeq ($(BLDCFG), profile)
+CFLAGS = -O0 -pg
+else
+CFLAGS = -g -O0 -Wall 
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(MACH) $(INCLUDE)
+
+CFLAGS := $(CFLAGS)
+LDFLAGS = $(MACH)
+
+
+include ../misc-tests.mk
index d629c1d..82589ef 100644 (file)
@@ -2,7 +2,7 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 SRCDIR = ../../../../..
-
+MACH = -m32
 
 CC = gcc
 AR = ar
diff --git a/tests/testrjs/build/darwin/x86_64/Makefile b/tests/testrjs/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..f2fb1cb
--- /dev/null
@@ -0,0 +1,29 @@
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+SRCDIR = ../../../../..
+MACH = -m64
+
+CC = gcc
+AR = ar
+ifeq ($(BLDCFG), release)
+CFLAGS = -O3
+else
+ifeq ($(BLDCFG), profile)
+CFLAGS = -O0 -pg
+else
+CFLAGS = -g -O0 -Wall 
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(MACH) $(INCLUDE)
+
+CFLAGS := $(CFLAGS)
+LDFLAGS = $(MACH)
+
+
+include ../testrjs.mk
index 1598920..7b11aef 100644 (file)
@@ -2,7 +2,7 @@ ARCHDIR = $(shell basename $(shell pwd))
 OUTDIR = out
 OS = $(shell uname | tr "[:upper:]" "[:lower:]")
 SRCDIR = ../../../../..
-
+MACH = -m32
 
 CC = gcc
 AR = ar
diff --git a/tests/testrpa/build/darwin/x86_64/Makefile b/tests/testrpa/build/darwin/x86_64/Makefile
new file mode 100644 (file)
index 0000000..ebad7dc
--- /dev/null
@@ -0,0 +1,29 @@
+ARCHDIR = $(shell basename $(shell pwd))
+OUTDIR = out
+OS = $(shell uname | tr "[:upper:]" "[:lower:]")
+SRCDIR = ../../../../..
+MACH = -m64
+
+CC = gcc
+AR = ar
+ifeq ($(BLDCFG), release)
+CFLAGS = -O3
+else
+ifeq ($(BLDCFG), profile)
+CFLAGS = -O0 -pg
+else
+CFLAGS = -g -O0 -Wall 
+endif
+endif
+
+ifeq ($(CCBLD), yes)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+CFLAGS += $(MACH) $(INCLUDE)
+
+CFLAGS := $(CFLAGS)
+LDFLAGS = $(MACH)
+
+
+include ../testrpa2.mk