units.si: add four new si units
[factor.git] / GNUmakefile
1 ifdef CONFIG
2         VERSION = 0.99
3         GIT_LABEL = $(shell echo `git describe --all`-`git rev-parse HEAD`)
4         BUNDLE = Factor.app
5         DEBUG ?= 0
6         REPRODUCIBLE ?= 0
7
8         # gmake's default CXX is g++, we prefer c++
9         SHELL_CXX = $(shell printenv CXX)
10         ifeq ($(SHELL_CXX),)
11                 CXX=c++
12         else
13                 CXX=$(SHELL_CXX)
14         endif
15
16         XCODE_PATH ?= /Applications/Xcode.app
17         MACOSX_32_SDK ?= MacOSX10.11.sdk
18
19         include $(CONFIG)
20
21         CFLAGS += -Wall \
22                 -Wextra \
23                 -pedantic \
24                 -DFACTOR_VERSION="$(VERSION)" \
25                 -DFACTOR_GIT_LABEL="$(GIT_LABEL)" \
26                 $(SITE_CFLAGS)
27
28         CXXFLAGS += -std=c++11
29
30         # SANITIZER=address ./build.sh compile
31         # address,thread,undefined,leak
32         ifdef SANITIZER
33                 CFLAGS += -fsanitize=$(SANITIZER)
34                 CXXFLAGS += -fsanitize=$(SANITIZER)
35         endif
36
37         ifneq ($(DEBUG), 0)
38                 CFLAGS += -g -DFACTOR_DEBUG
39         else
40                 CFLAGS += -O3
41         endif
42
43         ifneq ($(REPRODUCIBLE), 0)
44                 CFLAGS += -DFACTOR_REPRODUCIBLE
45         endif
46
47         ENGINE = $(DLL_PREFIX)factor$(DLL_SUFFIX)$(DLL_EXTENSION)
48         EXECUTABLE = factor$(EXE_SUFFIX)$(EXE_EXTENSION)
49         CONSOLE_EXECUTABLE = factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION)
50
51         DLL_OBJS = $(PLAF_DLL_OBJS) \
52                 vm/aging_collector.o \
53                 vm/alien.o \
54                 vm/arrays.o \
55                 vm/bignum.o \
56                 vm/byte_arrays.o \
57                 vm/callbacks.o \
58                 vm/callstack.o \
59                 vm/code_blocks.o \
60                 vm/code_heap.o \
61                 vm/compaction.o \
62                 vm/contexts.o \
63                 vm/data_heap.o \
64                 vm/data_heap_checker.o \
65                 vm/debug.o \
66                 vm/dispatch.o \
67                 vm/entry_points.o \
68                 vm/errors.o \
69                 vm/factor.o \
70                 vm/full_collector.o \
71                 vm/gc.o \
72                 vm/image.o \
73                 vm/inline_cache.o \
74                 vm/instruction_operands.o \
75                 vm/io.o \
76                 vm/jit.o \
77                 vm/math.o \
78                 vm/mvm.o \
79                 vm/nursery_collector.o \
80                 vm/object_start_map.o \
81                 vm/objects.o \
82                 vm/primitives.o \
83                 vm/quotations.o \
84                 vm/run.o \
85                 vm/safepoints.o \
86                 vm/sampling_profiler.o \
87                 vm/strings.o \
88                 vm/to_tenured_collector.o \
89                 vm/tuples.o \
90                 vm/utilities.o \
91                 vm/vm.o \
92                 vm/words.o
93
94         MASTER_HEADERS = $(PLAF_MASTER_HEADERS) \
95                 vm/assert.hpp \
96                 vm/debug.hpp \
97                 vm/layouts.hpp \
98                 vm/platform.hpp \
99                 vm/primitives.hpp \
100                 vm/segments.hpp \
101                 vm/gc_info.hpp \
102                 vm/contexts.hpp \
103                 vm/run.hpp \
104                 vm/objects.hpp \
105                 vm/sampling_profiler.hpp \
106                 vm/errors.hpp \
107                 vm/bignumint.hpp \
108                 vm/bignum.hpp \
109                 vm/booleans.hpp \
110                 vm/instruction_operands.hpp \
111                 vm/code_blocks.hpp \
112                 vm/bump_allocator.hpp \
113                 vm/bitwise_hacks.hpp \
114                 vm/mark_bits.hpp \
115                 vm/free_list.hpp \
116                 vm/fixup.hpp \
117                 vm/write_barrier.hpp \
118                 vm/object_start_map.hpp \
119                 vm/aging_space.hpp \
120                 vm/tenured_space.hpp \
121                 vm/data_heap.hpp \
122                 vm/code_heap.hpp \
123                 vm/gc.hpp \
124                 vm/float_bits.hpp \
125                 vm/io.hpp \
126                 vm/image.hpp \
127                 vm/callbacks.hpp \
128                 vm/dispatch.hpp \
129                 vm/vm.hpp \
130                 vm/allot.hpp \
131                 vm/tagged.hpp \
132                 vm/data_roots.hpp \
133                 vm/code_roots.hpp \
134                 vm/generic_arrays.hpp \
135                 vm/callstack.hpp \
136                 vm/slot_visitor.hpp \
137                 vm/to_tenured_collector.hpp \
138                 vm/arrays.hpp \
139                 vm/math.hpp \
140                 vm/byte_arrays.hpp \
141                 vm/jit.hpp \
142                 vm/quotations.hpp \
143                 vm/inline_cache.hpp \
144                 vm/mvm.hpp \
145                 vm/factor.hpp \
146                 vm/utilities.hpp
147
148         EXE_OBJS = $(PLAF_EXE_OBJS)
149
150         FFI_TEST_LIBRARY = libfactor-ffi-test$(SHARED_DLL_EXTENSION)
151
152         TEST_OBJS = vm/ffi_test.o
153 endif
154
155 default:
156         $(MAKE) `./build.sh make-target`
157
158 help:
159         @echo "Run '$(MAKE)' with one of the following parameters:"
160         @echo ""
161         @echo "linux-x86-32"
162         @echo "linux-x86-64"
163         @echo "linux-ppc-32"
164         @echo "linux-ppc-64"
165         @echo "linux-arm-64"
166         @echo "freebsd-x86-32"
167         @echo "freebsd-x86-64"
168         @echo "macosx-x86-32"
169         @echo "macosx-x86-64"
170         @echo "macosx-x86-fat"
171         @echo "macosx-arm64"
172         @echo "windows-x86-32"
173         @echo "windows-x86-64"
174         @echo ""
175         @echo "Additional modifiers:"
176         @echo ""
177         @echo "DEBUG=1  compile VM with debugging information"
178         @echo "REPRODUCIBLE=1  compile VM without timestamp"
179         @echo "SITE_CFLAGS=...  additional optimization flags"
180         @echo "X11=1  force link with X11 libraries instead of Cocoa (only on Mac OS X)"
181
182 ALL = factor factor-ffi-test factor-lib
183
184 freebsd-x86-32:
185         $(MAKE) $(ALL) CONFIG=vm/Config.freebsd.x86.32
186
187 freebsd-x86-64:
188         $(MAKE) $(ALL) CONFIG=vm/Config.freebsd.x86.64
189
190 macosx-x86-32:
191         $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.x86.32
192
193 macosx-x86-64:
194         $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.x86.64
195
196 macosx-x86-fat:
197         $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.x86.fat
198
199 macosx-arm64:
200         $(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.arm64
201
202 linux-arm-32:
203         $(MAKE) $(ALL) CONFIG=vm/Config.linux.arm.32
204
205 linux-arm-64:
206         $(MAKE) $(ALL) CONFIG=vm/Config.linux.arm.64
207
208 linux-x86-32:
209         $(MAKE) $(ALL) CONFIG=vm/Config.linux.x86.32
210
211 linux-x86-64:
212         $(MAKE) $(ALL) CONFIG=vm/Config.linux.x86.64
213
214 linux-ppc-32:
215         $(MAKE) $(ALL) CONFIG=vm/Config.linux.ppc.32
216
217 linux-ppc-64:
218         $(MAKE) $(ALL) CONFIG=vm/Config.linux.ppc.64
219
220 windows-x86-32:
221         $(MAKE) $(ALL) CONFIG=vm/Config.windows.x86.32
222         $(MAKE) factor-console CONFIG=vm/Config.windows.x86.32
223
224 windows-x86-64:
225         $(MAKE) $(ALL) CONFIG=vm/Config.windows.x86.64
226         $(MAKE) factor-console CONFIG=vm/Config.windows.x86.64
227
228 ifdef CONFIG
229
230 macosx.app: factor
231         mkdir -p $(BUNDLE)/Contents/MacOS
232         mkdir -p $(BUNDLE)/Contents/Frameworks
233         mv $(EXECUTABLE) $(BUNDLE)/Contents/MacOS/factor
234         ln -s $(BUNDLE)/Contents/MacOS/factor ./factor
235
236 $(ENGINE): $(DLL_OBJS)
237         $(TOOLCHAIN_PREFIX)$(LINKER) $(ENGINE) $(DLL_OBJS)
238
239 factor-lib: $(ENGINE)
240
241 factor: $(EXE_OBJS) $(DLL_OBJS)
242         $(TOOLCHAIN_PREFIX)$(CXX) -L. $(DLL_OBJS) \
243                 $(CFLAGS) $(CXXFLAGS) -o $(EXECUTABLE) $(LIBS) $(EXE_OBJS)
244
245 factor-console: $(EXE_OBJS) $(DLL_OBJS)
246         $(TOOLCHAIN_PREFIX)$(CXX) -L. $(DLL_OBJS) \
247                 $(CFLAGS) $(CXXFLAGS) $(CFLAGS_CONSOLE) -o $(CONSOLE_EXECUTABLE) $(LIBS) $(EXE_OBJS)
248
249 factor-ffi-test: $(FFI_TEST_LIBRARY)
250
251 $(FFI_TEST_LIBRARY): vm/ffi_test.o
252         $(TOOLCHAIN_PREFIX)$(CC) $(CFLAGS) $(FFI_TEST_CFLAGS) $(SHARED_FLAG) -o $(FFI_TEST_LIBRARY) $(TEST_OBJS)
253
254 vm/resources.o:
255         $(TOOLCHAIN_PREFIX)$(WINDRES) vm/factor.rs vm/resources.o
256
257 vm/ffi_test.o: vm/ffi_test.c
258         $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(FFI_TEST_CFLAGS) -std=c99 -o $@ $<
259
260 vm/master.hpp.gch: vm/master.hpp $(MASTER_HEADERS)
261         $(TOOLCHAIN_PREFIX)$(CXX) -c -x c++-header $(CFLAGS) $(CXXFLAGS) -o $@ $<
262
263 %.o: %.cpp vm/master.hpp.gch
264         $(TOOLCHAIN_PREFIX)$(CXX) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
265
266 %.o: %.S
267         $(TOOLCHAIN_PREFIX)$(CC) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
268
269 %.o: %.mm vm/master.hpp.gch
270         $(TOOLCHAIN_PREFIX)$(CXX) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
271
272 .SUFFIXES: .mm
273
274 endif
275
276 clean:
277         rm -f vm/*.gch
278         rm -f vm/*.o
279         rm -f factor.dll
280         rm -f factor.lib
281         rm -f factor.dll.lib
282         rm -f libfactor.*
283         rm -f libfactor-ffi-test.*
284         rm -f Factor.app/Contents/Frameworks/libfactor.dylib
285
286 .PHONY: factor factor-lib factor-console factor-ffi-test tags clean macosx.app
287 .PHONY: linux-x86-32 linux-x86-64 linux-ppc-32 linux-ppc-64 linux-arm-64 freebsd-x86-32 freebsd-x86-64 macosx-x86-32 macosx-x86-64 macosx-x86-fat macosx-arm64 windows-x86-32 windows-x86-64