Fixed allSelectorsSent because a simpler implementation was overriding the original.
[cslatevm.git] / common.mk
blob4ac806a36771030aa70968cf5aecbd7a791867f2
1 ##
2 # Variables included by all Makefiles.
3 ##
5 ## Directory definitions
7 libdir = $(slateroot)/lib
8 srcdir = $(slateroot)/src
9 mobiusdir = $(srcdir)/mobius
10 pluginsdir = $(srcdir)/plugins
11 testdir = $(slateroot)/tests
13 prefix = /usr/local
14 datadir = $(prefix)/share/slate
15 slatesrcdir = $(datadir)/src
16 slate_dirs := core lib syntax mobius
17 exec_prefix = $(prefix)/bin
18 execname = slate
19 includedir = $(prefix)/include
20 mandir = $(prefix)/share/man
21 man1dir = $(mandir)/man1
22 infodir = $(prefix)/info
23 lispdir = $(prefix)/share/emacs/site-lisp
24 vimdir = $(prefix)/share/vim
25 DEVNULL := /dev/null
27 ## Build modes. Set on command line using QUIET=1, DEBUG=1 or PROFILE=1
29 ifndef QUIETNESS
30 QUIETNESS := -q
31 endif
33 ifdef QUIET
34 VERBOSE := 0
35 SILENT := @
36 SILENT_ERRORS := 2> $(DEVNULL)
37 LIBTOOL_FLAGS += --silent
38 endif
40 ifdef DEBUG
41 MODE := debug
42 COPTFLAGS += -g
43 CFLAGS += -DSLATE_BUILD_TYPE="\"Debug\""
44 else
45 ifdef PROFILE
46 MODE += profiled
47 COPTFLAGS += -pg -g -O2 -fprofile-arcs -ftest-coverage
48 CFLAGS += -DSLATE_BUILD_TYPE="\"Profile\""
49 else
50 MODE := optimized
51 CFLAGS += -DSLATE_BUILD_TYPE="\"Optimized\""
52 COPTFLAGS += -O2
53 endif
54 endif
56 ## All required executables
58 CC := gcc
59 CPP := g++
60 CP := cp -f
61 LIBTOOL ?= libtool
62 ECHO := echo
63 WGET := wget -q -c --cache=off
64 SECHO := @$(ECHO)
65 INSTALL := install
66 TAR := tar
67 GZIP := gzip
68 ETAGS := etags
69 EMACS := emacs
71 ## Platform independent definitions
73 INCLUDES +=
74 #CFLAGS += -DSLATE_DATADIR=$(datadir) -D_POSIX_SOURCE=200112L -D_POSIX_C_SOURCE=200112L
75 CFLAGS += -DSLATE_DATADIR=$(datadir) -D_XOPEN_SOURCE=600
76 CFLAGS += $(COPTFLAGS) -Wall -Wno-unknown-pragmas -pthread $(PRINT_DEBUG) $(EXTRACFLAGS) $(INCLUDES)
77 # include -pedantic later fixme
79 ## Determine the host system's byte order.
80 ## This creates a temporary test executable in the $(slateroot) directory
81 ## since we can guarantee write permissions there on all platforms.
83 BYTE_ORDER_FN := $(slateroot)/byteorder
84 BYTE_ORDER_SRC := "int main(){union{long l;char c[sizeof(long)];}u;u.l=1;return(u.c[sizeof(long)-1]==1);}"
85 BYTE_ORDER := $(shell echo $(BYTE_ORDER_SRC) > $(BYTE_ORDER_FN).c)
86 BYTE_ORDER := $(shell $(CC) -o $(BYTE_ORDER_FN) $(BYTE_ORDER_FN).c)
87 BYTE_ORDER := $(shell $(BYTE_ORDER_FN); echo $$?)
88 BYTE_ORDER_ := $(shell $(RM) $(BYTE_ORDER_FN).* $(BYTE_ORDER_FN) 1>&2)
89 ifeq ($(BYTE_ORDER),0)
90 BYTE_ORDER := LITTLE_ENDIAN
91 BYTE_ORDER_PREFIX := little
92 LITTLE_ENDIAN_SLATE := True
93 else
94 BYTE_ORDER := BIG_ENDIAN
95 BYTE_ORDER_PREFIX := big
96 LITTLE_ENDIAN_SLATE := False
97 endif
99 WORD_SIZE_FN := $(slateroot)/wordsize
100 WORD_SIZE_SRC := "int main(){return sizeof(long)*8;}"
101 WORD_SIZE := $(shell echo $(WORD_SIZE_SRC) > $(WORD_SIZE_FN).c)
102 WORD_SIZE := $(shell $(CC) -o $(WORD_SIZE_FN) $(WORD_SIZE_FN).c)
103 WORD_SIZE := $(shell $(WORD_SIZE_FN); echo $$?)
104 WORD_SIZE_ := $(shell $(RM) $(WORD_SIZE_FN).* $(WORD_SIZE_FN) 1>&2)
106 ## Default variables
108 PLATFORM := unix
109 CCVERSION := $(shell $(CC) -dumpversion)
110 WORD_SIZE := 32
111 LDFLAGS := # -avoid-version
112 LIBS := #-lm -ldl
113 #PLUGINS := platform.so posix.so pipe.so
114 #PLUGINS := x-windows.so
115 PLUGINS :=
116 HOST_SYSTEM := $(shell uname -s)
117 LIB_SO_EXT := .so
118 INSTALL_MODE := -m 644
119 CPU_TYPE := `uname -m`
120 VM_LIBRARIES = -lm -ldl -lpthread
122 VMNAME := vm
123 VMDIR := $(srcdir)/vm
124 VM := $(VMDIR)/$(VMNAME)
125 SOURCES ?= $(VMDIR)/*.cpp
126 HEADERS ?= $(VMDIR)/*.hpp
127 DEFAULT_IMAGE ?= slate.image
128 KERNEL_IMAGES := kernel.new.*.$(WORD_SIZE).*.image
129 DEFAULT_KERNEL_IMAGE ?= $(shell ls -t $(KERNEL_IMAGES) | head -1)
130 LATEST_SLATE_IMAGE_RELEASE_DATE = 2011-02-15
131 LATEST_SLATE_IMAGE_RELEASE_NAME ?= slate.$(BYTE_ORDER_PREFIX).$(WORD_SIZE).$(LATEST_SLATE_IMAGE_RELEASE_DATE).image
132 LATEST_SLATE_IMAGE_URL ?= http://slate-language.googlecode.com/files/$(LATEST_SLATE_IMAGE_RELEASE_NAME).bz2
133 BOOTSTRAP_DIR := $(slateroot)
135 CFLAGS_x-windows.c=`pkg-config --cflags x11` `pkg-config --cflags cairo` -Werror
136 LDFLAGS_x-windows.lo=`pkg-config --libs x11` `pkg-config --libs cairo`
137 CFLAGS_cocoa-windows.c=`pkg-config --cflags cocoa` `pkg-config --cflags cairo`
138 LDFLAGS_cocoa-windows.lo=`pkg-config --libs cocoa` `pkg-config --libs cairo`
139 CFLAGS_glib-wrapper.c=`pkg-config --cflags glib-2.0`
140 LDFLAGS_glib-wrapper.lo=`pkg-config --libs glib-2.0` `pkg-config --libs gobject-2.0`
141 CFLAGS_gdk-wrapper.c=`pkg-config --cflags gdk-2.0`
142 LDFLAGS_gdk-wrapper.lo=`pkg-config --libs gdk-2.0` `pkg-config --libs gthread-2.0`
143 CFLAGS_gtk-wrapper.c=`pkg-config --cflags gtk+-2.0`
144 LDFLAGS_gtk-wrapper.lo=`pkg-config --libs gtk+-2.0`
145 CFLAGS_llvm-wrapper.c=`llvm-config --cflags`
146 LDFLAGS_llvm-wrapper.lo=
148 #CFLAGS_socket.c=
150 PRINT_DEBUG_G=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC_1 -DPRINT_DEBUG_OPCODES
151 PRINT_DEBUG_Y=-DPRINT_DEBUG_STACK_POINTER -DPRINT_DEBUG_STACK_PUSH -DPRINT_DEBUG_FOUND_ROLE -DPRINT_DEBUG_FUNCALL
152 PRINT_DEBUG_X=-DPRINT_DEBUG -DPRINT_DEBUG_OPCODES -DPRINT_DEBUG_INSTRUCTION_COUNT -DPRINT_DEBUG_CODE_POINTER -DPRINT_DEBUG_DISPATCH
153 PRINT_DEBUG_4=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC -DPRINT_DEBUG_OPCODES -DPRINT_DEBUG_CODE_POINTER -DPRINT_DEBUG_ENSURE -DPRINT_DEBUG_STACK
154 PRINT_DEBUG_3=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC -DPRINT_DEBUG_OPTIMIZER -DPRINT_DEBUG_PIC_HITS -DPRINT_DEBUG_UNOPTIMIZER
155 PRINT_DEBUG_2=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG -DPRINT_DEBUG_OPCODES -DPRINT_DEBUG_INSTRUCTION_COUNT -DPRINT_DEBUG_CODE_POINTER -DPRINT_DEBUG_DISPATCH -DPRINT_DEBUG_GC_MARKINGS
156 PRINT_DEBUG_1=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC_1
157 PRINT_DEBUG_0=
158 PRINT_DEBUG=$(PRINT_DEBUG_0)
160 ## Determine CPU type
162 ## TODO: Sparc detection for SunOS?
163 ## TODO: Base CPU type on real information, not just generic OS variant
165 ## CPU-type specific overrides. Any of the variables above may be changed here.
167 ifdef ARCH
168 CFLAGS += -m$(ARCH)
169 endif
171 ifdef VERSION
172 CFLAGS += -DVERSION="\"$(VERSION)\""
173 endif
175 CFLAGS +=-DSLATE_DEFAULT_IMAGE=$(DEFAULT_IMAGE)
177 ifdef WORD_SIZE
178 CFLAGS += -m$(WORD_SIZE)
179 CFLAGS += -D_FILE_OFFSET_BITS=$(WORD_SIZE)
180 endif
182 #ifeq ($(CPU_TYPE), i686)
183 # CFLAGS += -m$(WORD_SIZE)
184 #endif
186 #ifeq ($(CPU_TYPE), x86_64)
187 # CFLAGS += -m$(WORD_SIZE)
188 #endif
190 ## Platform specific overrides. Any of the variables above may be changed here.
192 ifeq ($(HOST_SYSTEM), AIX)
193 LIB_SO_EXT := .a
194 PLUGINS := platform.so posix.so pipe.so
195 endif
197 ifeq ($(HOST_SYSTEM), BeOS)
198 PLATFORM := beos
199 endif
201 ifeq ($(findstring CYGWIN,$(HOST_SYSTEM)), CYGWIN)
202 PLATFORM := windows
203 LDFLAGS += -no-undefined
204 LIBS := -lm
205 LIB_SO_EXT := .dll
206 # DEVNULL := NUL # Required if using cmd.exe and not bash.
207 endif
209 ifeq ($(HOST_SYSTEM), Darwin)
210 # LIBTOOL := MACOSX_DEPLOYMENT_TARGET=10.3 glibtool
211 LIBTOOL := glibtool
212 PLUGINS := cocoa-windows.so
213 endif
215 ifeq ($(HOST_SYSTEM), DragonFly)
216 LIBS := -lm
217 endif
219 ifeq ($(HOST_SYSTEM), FreeBSD)
220 LIBS := -lm -lc_r
221 LIBTOOL := libtool13
222 endif
224 ifeq ($(HOST_SYSTEM), HP-UX)
225 LIBS := -lm -ldld
226 LIB_SO_EXT := .sl
227 PLUGINS := platform.so posix.so pipe.so
228 endif
230 ifeq ($(HOST_SYSTEM), Linux)
231 LIBS := -lm -ldl
232 PLUGINS += gtk-wrapper.so gdk-wrapper.so glib-wrapper.so llvm-wrapper.so x-windows.so
233 endif
235 ifeq ($(findstring MINGW,$(HOST_SYSTEM)), MINGW)
236 PLATFORM := windows
237 LIBS := -lm
238 endif
240 ifeq ($(HOST_SYSTEM), NetBSD)
241 LIBS := -lm
242 endif
244 ifeq ($(HOST_SYSTEM), SunOS)
245 PLUGINS := platform.so posix.so pipe.so
246 # Work around GCC Ultra SPARC alignment bug
247 # TODO: Should be CPU specific.
248 COPTFLAGS := $(subst -O2,-O0, $(COPTFLAGS))
249 endif
251 PLUGINS := $(subst .so,$(LIB_SO_EXT), $(PLUGINS))