summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Mohr <manuel.mohr@kit.edu>2013-09-04 14:24:40 +0200
committerManuel Mohr <manuel.mohr@kit.edu>2013-09-04 14:24:40 +0200
commit25124231c224fb77b2cc0265b46afe7ce4ead08e (patch)
tree232c23e333c112af60d694078e8e1c902878841d
parent4cabddd555cba6f4804bceaf685d9ab25824f6aa (diff)
Add clean Makefile suitable for Invasic usage.
-rw-r--r--.gitignore1
-rw-r--r--Makefile117
2 files changed, 117 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index cf10523..f05fba0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,7 +15,6 @@
/*.gc.log
/.deps/
/.libs/
-/Makefile
/add_gc_prefix
/base_lib
/bdw-gc.pc
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..131cfdf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,117 @@
+COMMON_SOURCES = \
+ allchblk.c \
+ alloc.c \
+ backgraph.c \
+ blacklst.c \
+ checksums.c \
+ dbg_mlc.c \
+ finalize.c \
+ fnlz_mlc.c \
+ gcj_mlc.c \
+ headers.c \
+ mach_dep.c \
+ malloc.c \
+ mallocx.c \
+ mark.c \
+ mark_rts.c \
+ misc.c \
+ new_hblk.c \
+ obj_map.c \
+ os_dep.c \
+ pcr_interface.c \
+ ptr_chck.c \
+ real_malloc.c \
+ reclaim.c \
+ specific.c \
+ stubborn.c \
+ thread_local_alloc.c \
+ typd_mlc.c
+
+LINUX_SOURCES = \
+ dyn_load.c \
+ gc_dlopen.c \
+ pthread_start.c \
+ pthread_stop_world.c \
+ pthread_support.c
+
+OCTOPOS_SOURCES = \
+ octopos_threads.c
+
+DARWIN_SOURCES = \
+ dyn_load.c \
+ darwin_stop_world.c \
+ gc_dlopen.c
+
+GUESSED_TARGET := $(shell $(CC) -dumpmachine)
+TARGET ?= $(GUESSED_TARGET)
+CC = $(TARGET)-gcc
+
+CPPFLAGS = -Iinclude/ -DATOMIC_UNCOLLECTABLE -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS
+CFLAGS = -O2 -g
+
+# Architecture-specific stuff
+ifeq ($(findstring x86_64, $(TARGET)), x86_64)
+ CFLAGS += -m32
+endif
+ifeq ($(findstring sparc, $(TARGET)), sparc)
+ CFLAGS += -msoft-float
+endif
+
+# Operating-system-specific stuff
+ifeq ($(findstring linux, $(TARGET)), linux)
+ SOURCES = $(COMMON_SOURCES) $(LINUX_SOURCES)
+ CPPFLAGS += -Ilibatomic_ops-install/include
+ CPPFLAGS += -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC
+ EXTRA_OBJECTS = libatomic_ops-install/lib/libatomic_ops.a
+endif
+ifeq ($(findstring octopos, $(TARGET)), octopos)
+ SOURCES = $(COMMON_SOURCES) $(OCTOPOS_SOURCES)
+endif
+ifeq ($(findstring darwin, $(TARGET)), darwin)
+ SOURCES = $(COMMON_SOURCES) $(DARWIN_SOURCES)
+endif
+
+# Platform-specific stuff
+OCTOPOS_RELEASE = current
+
+ifeq ($(TARGET), i686-invasic-octopos)
+ OCTOPOS_ARCH = x86guest
+ OCTOPOS_VARIANT = multitile
+ OCTOPOS_BASE = ../octopos-app/releases/$(OCTOPOS_RELEASE)/$(OCTOPOS_ARCH)/$(OCTOPOS_VARIANT)
+ GCC_INCLUDE = $(shell $(CC) --print-file-name=include)
+
+ CFLAGS += -fno-stack-protector -mfpmath=sse -msse2 -m32
+ CPPFLAGS += -nostdinc -Ulinux -U__linux -U__linux__ -U__gnu_linux__ -Uunix -U__unix -U__unix__ -I$(OCTOPOS_BASE)/include -D__OCTOPOS__ -isystem $(GCC_INCLUDE)
+endif
+ifeq ($(TARGET), sparc-invasic-octopos)
+ OCTOPOS_ARCH = leon
+ OCTOPOS_VARIANT = 4t-ml605
+ OCTOPOS_BASE = ../octopos-app/releases/$(OCTOPOS_RELEASE)/$(OCTOPOS_ARCH)/$(OCTOPOS_VARIANT)
+ GCC_INCLUDE = $(shell $(CC) --print-file-name=include)
+
+ CFLAGS += -fno-stack-protector
+ CPPFLAGS += -nostdinc -D__leon__ -I $(OCTOPOS_BASE)/include -isystem $(GCC_INCLUDE)
+endif
+
+BUILDDIR = build/$(TARGET)
+OBJECTS = $(SOURCES:%.c=$(BUILDDIR)/%.o)
+ARCHIVE = $(BUILDDIR)/gc.a
+Q = @
+
+all: $(ARCHIVE)
+
+$(ARCHIVE): $(BUILDDIR) $(OBJECTS)
+ $(Q)ar ru $(ARCHIVE) $(OBJECTS) $(EXTRA_OBJECTS)
+
+$(BUILDDIR)/%.o: %.c
+ $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+$(BUILDDIR):
+ $(Q)mkdir -p $(BUILDDIR)
+
+clean:
+ $(Q)rm -f $(OBJECTS)
+ $(Q)rm -f $(ARCHIVE)
+ $(Q)rm -rf $(BUILDDIR)
+
+.PHONY: all clean