Added a #reset method to Debugger Frames and a #quit method to the Debugger itself.
[cslatevm.git] / common.mk
blob12e779d13014cd71fcad1280bf9c27e0e571c39f
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 DEVNULL := /dev/null
23 ## Build modes. Set on command line using QUIET=1, DEBUG=1 or PROFILE=1
25 ifndef QUIETNESS
26 QUIETNESS := -q
27 endif
29 ifdef QUIET
30 VERBOSE := 0
31 SILENT := @
32 SILENT_ERRORS := 2> $(DEVNULL)
33 LIBTOOL_FLAGS += --silent
34 endif
36 ifdef DEBUG
37 MODE := debug
38 COPTFLAGS += -g
39 CFLAGS += -DSLATE_BUILD_TYPE="\"Debug\""
40 else
41 ifdef PROFILE
42 MODE += profiled
43 COPTFLAGS += -pg -g -O2
44 CFLAGS += -DSLATE_BUILD_TYPE="\"Profile\""
45 else
46 MODE := optimized
47 CFLAGS += -DSLATE_BUILD_TYPE="\"Optimized\""
48 COPTFLAGS += -O2
49 endif
50 endif
55 ## All required executables
57 CC := gcc
58 CP := cp -f
59 LIBTOOL ?= libtool
60 ECHO := echo
61 WGET := wget -q --cache=off
62 SECHO := @$(ECHO)
63 INSTALL := install
64 TAR := tar
65 GZIP := gzip
66 ETAGS := etags
67 EMACS := emacs
69 ## Platform independent definitions
71 INCLUDES +=
72 CFLAGS += -DSLATE_DATADIR=$(datadir) -D_POSIX_SOURCE=200112L -D_POSIX_C_SOURCE=200112L
73 CFLAGS += $(COPTFLAGS) -std=c99 -Wall -pedantic -Wno-unknown-pragmas -pthread $(PRINT_DEBUG) $(INCLUDES)
75 ## Determine the host system's byte order.
76 ## This creates a temporary test executable in the $(slateroot) directory
77 ## since we can guarantee write permissions there on all platforms.
79 BYTE_ORDER := "int main(){union{long l;char c[sizeof(long)];}u;u.l=1;return(u.c[sizeof(long)-1]==1);}"
80 BYTE_ORDER := $(shell echo $(BYTE_ORDER) > $(slateroot)/byteorder.c)
81 BYTE_ORDER := $(shell $(CC) -o $(slateroot)/byteorder $(slateroot)/byteorder.c)
82 BYTE_ORDER := $(shell $(slateroot)/byteorder; echo $$?)
83 BYTE_ORDER_ := $(shell $(RM) $(slateroot)/byteorder.* $(slateroot)/byteorder 1>&2)
84 ifeq ($(BYTE_ORDER),0)
85 BYTE_ORDER := LITTLE_ENDIAN
86 BYTE_ORDER_PREFIX := little
87 else
88 BYTE_ORDER := BIG_ENDIAN
89 BYTE_ORDER_PREFIX := big
90 endif
92 ## Default variables
94 PLATFORM := unix
95 CCVERSION := $(shell $(CC) -dumpversion)
96 #WORD_SIZE := 32
97 LDFLAGS := # -avoid-version
98 LIBS := #-lm -ldl
99 #PLUGINS := platform.so posix.so pipe.so
100 #PLUGINS := x-windows.so
101 PLUGINS :=
102 HOST_SYSTEM := $(shell uname -s)
103 LIB_SO_EXT := .so
104 INSTALL_MODE := -m 644
105 CPU_TYPE := `uname -m`
106 VM_LIBRARIES = -lm -ldl -lpthread
109 VMNAME := vm
110 VMDIR := $(slateroot)/src/vm
111 VM := $(VMDIR)/$(VMNAME)
112 DEFAULT_IMAGE ?= slate.image
113 KERNEL_IMAGES := kernel.new.*.$(WORD_SIZE).*.image
114 DEFAULT_KERNEL_IMAGE ?= $(shell ls -t $(KERNEL_IMAGES) | head -1)
116 CFLAGS_x-windows.c=`pkg-config --cflags x11` `pkg-config --cflags cairo` -Werror
117 LDFLAGS_x-windows.lo=`pkg-config --libs x11` `pkg-config --libs cairo`
118 CFLAGS_cocoa-windows.c=`pkg-config --cflags cocoa` `pkg-config --cflags cairo`
119 LDFLAGS_cocoa-windows.lo=`pkg-config --libs cocoa` `pkg-config --libs cairo`
120 CFLAGS_glib-wrapper.c=`pkg-config --cflags glib-2.0`
121 LDFLAGS_glib-wrapper.lo=`pkg-config --libs glib-2.0` `pkg-config --libs gobject-2.0`
122 CFLAGS_gdk-wrapper.c=`pkg-config --cflags gdk-2.0`
123 LDFLAGS_gdk-wrapper.lo=`pkg-config --libs gdk-2.0` `pkg-config --libs gthread-2.0`
124 CFLAGS_gtk-wrapper.c=`pkg-config --cflags gtk+-2.0`
125 LDFLAGS_gtk-wrapper.lo=`pkg-config --libs gtk+-2.0`
126 CFLAGS_llvm-wrapper.c=`llvm-config --cflags`
127 LDFLAGS_llvm-wrapper.lo=
129 #CFLAGS_socket.c=
131 PRINT_DEBUG_G=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC_1 -DPRINT_DEBUG_OPCODES
132 PRINT_DEBUG_Y= -DPRINT_DEBUG_STACK_POINTER -DPRINT_DEBUG_STACK_PUSH -DPRINT_DEBUG_FOUND_ROLE -DPRINT_DEBUG_FUNCALL
133 PRINT_DEBUG_X=-DPRINT_DEBUG -DPRINT_DEBUG_OPCODES -DPRINT_DEBUG_INSTRUCTION_COUNT -DPRINT_DEBUG_CODE_POINTER -DPRINT_DEBUG_DISPATCH
134 PRINT_DEBUG_1=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC_1
135 PRINT_DEBUG_4=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC -DPRINT_DEBUG_OPCODES -DPRINT_DEBUG_CODE_POINTER -DPRINT_DEBUG_ENSURE -DPRINT_DEBUG_STACK
136 PRINT_DEBUG_3=-DPRINT_DEBUG_DEFUN -DPRINT_DEBUG_GC -DPRINT_DEBUG_OPTIMIZER -DPRINT_DEBUG_PIC_HITS -DPRINT_DEBUG_UNOPTIMIZER
137 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
138 PRINT_DEBUG=$(PRINT_DEBUG_1)
141 ## Determine CPU type
143 #ifeq ($(HOST_SYSTEM), Darwin)
144 # CPU_TYPE := powerpc
145 #endif
147 ## TODO: Sparc detection for SunOS?
148 ## TODO: Base CPU type on real information, not just generic OS variant
150 ## CPU-type specific overrides. Any of the variables above may be changed here.
152 ifdef ARCH
153 CFLAGS += -m$(ARCH)
154 endif
156 ifdef VERSION
157 CFLAGS += -DVERSION="\"$(VERSION)\""
158 endif
160 CFLAGS +=-DSLATE_DEFAULT_IMAGE=$(DEFAULT_IMAGE)
162 ifdef WORD_SIZE
163 CFLAGS += -m$(WORD_SIZE)
164 endif
165 #ifeq ($(CPU_TYPE), i686)
166 # CFLAGS += -m$(WORD_SIZE)
167 #endif
169 #ifeq ($(CPU_TYPE), x86_64)
170 # CFLAGS += -m$(WORD_SIZE)
171 #endif
173 ## Platform specific overrides. Any of the variables above may be changed here.
175 ifeq ($(HOST_SYSTEM), AIX)
176 LIB_SO_EXT := .a
177 PLUGINS := platform.so posix.so pipe.so
178 endif
180 ifeq ($(HOST_SYSTEM), BeOS)
181 PLATFORM := beos
182 endif
184 ifeq ($(findstring CYGWIN,$(HOST_SYSTEM)), CYGWIN)
185 PLATFORM := windows
186 LDFLAGS += -no-undefined
187 LIBS := -lm
188 LIB_SO_EXT := .dll
189 # DEVNULL := NUL # Required if using cmd.exe and not bash.
190 endif
192 ifeq ($(HOST_SYSTEM), Darwin)
193 # LIBTOOL := MACOSX_DEPLOYMENT_TARGET=10.3 glibtool
194 LIBTOOL := glibtool
195 PLUGINS := cocoa-windows.so
196 endif
198 ifeq ($(HOST_SYSTEM), DragonFly)
199 LIBS := -lm
200 endif
202 ifeq ($(HOST_SYSTEM), FreeBSD)
203 LIBS := -lm -lc_r
204 LIBTOOL := libtool13
205 endif
207 ifeq ($(HOST_SYSTEM), HP-UX)
208 LIBS := -lm -ldld
209 LIB_SO_EXT := .sl
210 PLUGINS := platform.so posix.so pipe.so
211 endif
213 ifeq ($(HOST_SYSTEM), Linux)
214 LIBS := -lm -ldl
215 PLUGINS += gtk-wrapper.so gdk-wrapper.so glib-wrapper.so llvm-wrapper.so
216 endif
218 ifeq ($(findstring MINGW,$(HOST_SYSTEM)), MINGW)
219 PLATFORM := windows
220 LIBS := -lm
221 endif
223 ifeq ($(HOST_SYSTEM), NetBSD)
224 LIBS := -lm
225 endif
227 ifeq ($(HOST_SYSTEM), SunOS)
228 PLUGINS := platform.so posix.so pipe.so
229 # Work around GCC Ultra SPARC alignment bug
230 # TODO: Should be CPU specific.
231 COPTFLAGS := $(subst -O2,-O0, $(COPTFLAGS))
232 endif
234 PLUGINS := $(subst .so,$(LIB_SO_EXT), $(PLUGINS))