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