Disable loading bytecode with an extra header (BOM or #!).
[luajit-2.0.git] / src / Makefile
blob65ab754fcc18b22571bb22f887053eeb486e57f6
1 ##############################################################################
2 # LuaJIT Makefile. Requires GNU Make.
4 # Please read doc/install.html before changing any variables!
6 # Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
7 # Also works with MinGW and Cygwin on Windows.
8 # Please check msvcbuild.bat for building with MSVC on Windows.
10 # Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
11 ##############################################################################
13 MAJVER= 2
14 MINVER= 0
15 RELVER= 0
16 ABIVER= 5.1
17 NODOTABIVER= 51
19 ##############################################################################
20 ############################# COMPILER OPTIONS #############################
21 ##############################################################################
22 # These options mainly affect the speed of the JIT compiler itself, not the
23 # speed of the JIT-compiled code. Turn any of the optional settings on by
24 # removing the '#' in front of them. Make sure you force a full recompile
25 # with "make clean", followed by "make" if you change any options.
27 # LuaJIT builds as a native 32 or 64 bit binary by default.
28 CC= gcc
30 # Use this if you want to force a 32 bit build on a 64 bit multilib OS.
31 #CC= gcc -m32
33 # Since the assembler part does NOT maintain a frame pointer, it's pointless
34 # to slow down the C part by not omitting it. Debugging, tracebacks and
35 # unwinding are not affected -- the assembler part has frame unwind
36 # information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
37 CCOPT= -O2 -fomit-frame-pointer
38 # Use this if you want to generate a smaller binary (but it's slower):
39 #CCOPT= -Os -fomit-frame-pointer
40 # Note: it's no longer recommended to use -O3 with GCC 4.x.
41 # The I-Cache bloat usually outweighs the benefits from aggressive inlining.
43 # Target-specific compiler options:
45 # x86 only: it's recommended to compile at least for i686. By default the
46 # assembler part of the interpreter makes use of CMOV/FCOMI*/FUCOMI*
47 # instructions, anyway.
49 # x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
50 # the binaries to a different machine you could also use: -march=native
52 CCOPT_X86= -march=i686
53 CCOPT_X64=
54 CCOPT_ARM=
55 CCOPT_PPC=
56 CCOPT_PPCSPE=
57 CCOPT_MIPS=
59 CCDEBUG=
60 # Uncomment the next line to generate debug information:
61 #CCDEBUG= -g
63 CCWARN= -Wall
64 # Uncomment the next line to enable more warnings:
65 #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
67 ##############################################################################
69 ##############################################################################
70 ################################ BUILD MODE ################################
71 ##############################################################################
72 # The default build mode is mixed mode on POSIX. On Windows this is the same
73 # as dynamic mode.
75 # Mixed mode creates a static + dynamic library and a statically linked luajit.
76 BUILDMODE= mixed
78 # Static mode creates a static library and a statically linked luajit.
79 #BUILDMODE= static
81 # Dynamic mode creates a dynamic library and a dynamically linked luajit.
82 # Note: this executable will only run when the library is installed!
83 #BUILDMODE= dynamic
85 ##############################################################################
87 ##############################################################################
88 ################################# FEATURES #################################
89 ##############################################################################
90 # Enable/disable these features as needed, but make sure you force a full
91 # recompile with "make clean", followed by "make".
92 XCFLAGS=
94 # Permanently disable the FFI extension to reduce the size of the LuaJIT
95 # executable. But please consider that the FFI library is compiled-in,
96 # but NOT loaded by default. It only allocates any memory, if you actually
97 # make use of it.
98 #XCFLAGS+= -DLUAJIT_DISABLE_FFI
100 # Enable some upwards-compatible features from Lua 5.2 that are unlikely
101 # to break existing code (e.g. __pairs). Note that this does not provide
102 # full compatibility with Lua 5.2 at this time.
103 #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
105 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
106 #XCFLAGS+= -DLUAJIT_DISABLE_JIT
108 # x86 only: use SSE2 instead of x87 instructions in the interpreter
109 # (always enabled for x64). A pure interpreter built with this flag won't
110 # run on older CPUs (before P4 or K8). There isn't much of a speed
111 # difference, so this is not enabled by default.
112 # The JIT compiler is not affected by this flag. It always uses runtime
113 # CPU feature detection before emitting code for SSE2 up to SSE4.1.
114 #XCFLAGS+= -DLUAJIT_CPU_SSE2
116 # x86 only: Disable the use of CMOV and FCOMI*/FUCOMI* instructions in the
117 # interpreter. Do this only if you intend to use REALLY ANCIENT CPUs
118 # (before Pentium Pro, or on the VIA C3). This generally slows down the
119 # interpreter. Don't bother if your OS wouldn't run on them, anyway.
120 #XCFLAGS+= -DLUAJIT_CPU_NOCMOV
122 # Some architectures (e.g. PPC) can use either single-number (1) or
123 # dual-number (2) mode. Uncomment one of these lines to override the
124 # default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
125 #XCFLAGS+= -DLUAJIT_NUMMODE=1
126 #XCFLAGS+= -DLUAJIT_NUMMODE=2
128 ##############################################################################
130 ##############################################################################
131 ############################ DEBUGGING SUPPORT #############################
132 ##############################################################################
133 # Enable these options as needed, but make sure you force a full recompile
134 # with "make clean", followed by "make".
135 # Note that most of these are NOT suitable for benchmarking or release mode!
137 # Use the system provided memory allocator (realloc) instead of the
138 # bundled memory allocator. This is slower, but sometimes helpful for
139 # debugging. It's helpful for Valgrind's memcheck tool, too. This option
140 # cannot be enabled on x64, since the built-in allocator is mandatory.
141 #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
143 # This define is required to run LuaJIT under Valgrind. The Valgrind
144 # header files must be installed. You should enable debug information, too.
145 # Use --suppressions=lj.supp to avoid some false positives.
146 #XCFLAGS+= -DLUAJIT_USE_VALGRIND
148 # This is the client for the GDB JIT API. GDB 7.0 or higher is required
149 # to make use of it. See lj_gdbjit.c for details. Enabling this causes
150 # a non-negligible overhead, even when not running under GDB.
151 #XCFLAGS+= -DLUAJIT_USE_GDBJIT
153 # Turn on assertions for the Lua/C API to debug problems with lua_* calls.
154 # This is rather slow -- use only while developing C libraries/embeddings.
155 #XCFLAGS+= -DLUA_USE_APICHECK
157 # Turn on assertions for the whole LuaJIT VM. This significantly slows down
158 # everything. Use only if you suspect a problem with LuaJIT itself.
159 #XCFLAGS+= -DLUA_USE_ASSERT
161 ##############################################################################
162 # You probably don't need to change anything below this line!
163 ##############################################################################
165 ##############################################################################
166 # Flags and options for host and target.
167 ##############################################################################
169 # You can override the following variables at the make command line:
170 # CC HOST_CC STATIC_CC DYNAMIC_CC
171 # CFLAGS HOST_CFLAGS TARGET_CFLAGS
172 # LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
173 # LIBS HOST_LIBS TARGET_LIBS
174 # CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
176 # Cross-compilation examples:
177 # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
178 # make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
180 CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
181 LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
183 HOST_CC= $(CC)
184 HOST_RM= rm -f
185 # NOTE: The LuaJIT distribution comes with pre-generated buildvm_*.h files.
186 # You DO NOT NEED an installed copy of (plain) Lua 5.1 to run DynASM unless
187 # you want to MODIFY the corresponding *.dasc file. You can also use LuaJIT
188 # itself (bootstrapped from a pre-generated file) to run DynASM of course.
189 HOST_LUA= lua
191 HOST_XCFLAGS=
192 HOST_XLDFLAGS=
193 HOST_XLIBS=
194 HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
195 HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
196 HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)
198 STATIC_CC = $(CROSS)$(CC)
199 DYNAMIC_CC = $(CROSS)$(CC) -fPIC
200 TARGET_CC= $(STATIC_CC)
201 TARGET_STCC= $(STATIC_CC)
202 TARGET_DYNCC= $(DYNAMIC_CC)
203 TARGET_LD= $(CROSS)$(CC)
204 TARGET_AR= $(CROSS)ar rcus
205 TARGET_STRIP= $(CROSS)strip
207 TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
208 TARGET_DYLIBNAME= libluajit-$(NODOTABIVER).$(MAJVER).dylib
209 TARGET_DYLIBPATH= $(or $(PREFIX),/usr/local)/lib/$(TARGET_DYLIBNAME)
210 TARGET_DLLNAME= lua$(NODOTABIVER).dll
211 TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
212 TARGET_DYNXLDOPTS=
214 TARGET_XCFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U_FORTIFY_SOURCE
215 TARGET_XLDFLAGS=
216 TARGET_XLIBS= -lm
217 TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
218 TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS)
219 TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
220 TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
221 TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
223 TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
224 ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
225 TARGET_CCARCH= x64
226 TARGET_XCFLAGS+= $(CCOPT_X64)
227 else
228 ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
229 TARGET_CCARCH= x86
230 TARGET_XCFLAGS+= $(CCOPT_X86)
231 else
232 ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
233 TARGET_CCARCH= arm
234 TARGET_XCFLAGS+= $(CCOPT_ARM)
235 else
236 ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
237 TARGET_CCARCH= ppc
238 TARGET_XCFLAGS+= $(CCOPT_PPC)
239 else
240 ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
241 TARGET_CCARCH= ppcspe
242 TARGET_XCFLAGS+= $(CCOPT_PPCSPE)
243 else
244 ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
245 ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
246 TARGET_ARCH= -D__MIPSEL__=1
247 endif
248 TARGET_CCARCH= mips
249 TARGET_XCFLAGS+= $(CCOPT_MIPS)
250 else
251 $(error Unsupported target architecture)
252 endif
253 endif
254 endif
255 endif
256 endif
257 endif
259 TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_CCARCH))
261 ifneq (,$(PREFIX))
262 ifneq (/usr/local,$(PREFIX))
263 TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\"
264 ifneq (/usr,$(PREFIX))
265 TARGET_DYNXLDOPTS= -Wl,-rpath,$(PREFIX)/lib
266 endif
267 endif
268 endif
270 ##############################################################################
271 # System detection.
272 ##############################################################################
274 ifneq (,$(findstring Windows,$(OS)))
275 HOST_SYS= Windows
276 else
277 HOST_SYS:= $(shell uname -s)
278 ifneq (,$(findstring CYGWIN,$(TARGET_SYS)))
279 HOST_SYS= Windows
280 endif
281 endif
282 ifeq (Windows,$(HOST_SYS))
283 HOST_RM= del
284 endif
286 TARGET_SYS= $(HOST_SYS)
287 ifeq (Windows,$(TARGET_SYS))
288 TARGET_STRIP+= --strip-unneeded
289 TARGET_XSHLDFLAGS= -shared
290 TARGET_DYNXLDOPTS=
291 else
292 ifeq (Darwin,$(TARGET_SYS))
293 ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
294 export MACOSX_DEPLOYMENT_TARGET=10.4
295 endif
296 TARGET_STRIP+= -x
297 TARGET_AR+= 2>/dev/null
298 TARGET_XCFLAGS+= -fno-stack-protector
299 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
300 TARGET_DYNXLDOPTS=
301 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
302 ifeq (x64,$(TARGET_CCARCH))
303 TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
304 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
305 endif
306 else
307 ifeq (iOS,$(TARGET_SYS))
308 TARGET_STRIP+= -x
309 TARGET_AR+= 2>/dev/null
310 TARGET_XCFLAGS+= -fno-stack-protector
311 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
312 TARGET_DYNXLDOPTS=
313 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
314 else
315 ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
316 TARGET_XCFLAGS+= -fno-stack-protector
317 endif
318 ifneq (SunOS,$(TARGET_SYS))
319 TARGET_XLDFLAGS+= -Wl,-E
320 endif
321 ifeq (Linux,$(TARGET_SYS))
322 TARGET_XLIBS+= -ldl
323 endif
324 ifeq (GNU/kFreeBSD,$(TARGET_SYS))
325 TARGET_XLIBS+= -ldl
326 endif
327 endif
328 endif
329 endif
331 ifneq ($(HOST_SYS),$(TARGET_SYS))
332 ifeq (Windows,$(TARGET_SYS))
333 HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
334 else
335 ifeq (Linux,$(TARGET_SYS))
336 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
337 else
338 ifeq (Darwin,$(TARGET_SYS))
339 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
340 else
341 ifeq (iOS,$(TARGET_SYS))
342 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
343 else
344 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
345 endif
346 endif
347 endif
348 endif
349 endif
351 ifneq (,$(CCDEBUG))
352 TARGET_STRIP= @:
353 endif
355 ##############################################################################
356 # Files and pathnames.
357 ##############################################################################
359 DASM_DIR= ../dynasm
360 DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
361 DASM_FLAGS=
362 DASM_DISTFLAGS= -LN
363 DASM_FLAGS_X86=
364 DASM_FLAGS_X64= -D X64
365 DASM_FLAGS_X64WIN= -D X64 -D X64WIN
366 DASM_FLAGS_ARM=
367 DASM_FLAGS_PPC=
368 DASM_FLAGS_PPCSPE=
369 DASM_FLAGS_MIPS=
371 BUILDVM_O= buildvm.o buildvm_asm.o buildvm_peobj.o buildvm_lib.o buildvm_fold.o
372 BUILDVM_T= buildvm
373 BUILDVM_X= ./$(BUILDVM_T)
375 HOST_O= $(BUILDVM_O)
376 HOST_T= $(BUILDVM_T)
378 LJVM_S= lj_vm.s
379 LJVM_O= lj_vm.o
380 LJVM_BOUT= $(LJVM_S)
381 LJVM_MODE= elfasm
383 LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
384 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
385 LJLIB_C= $(LJLIB_O:.o=.c)
387 LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \
388 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
389 lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_api.o \
390 lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o \
391 lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
392 lj_opt_dce.o lj_opt_loop.o lj_opt_split.o \
393 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
394 lj_asm.o lj_trace.o lj_gdbjit.o \
395 lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
396 lj_carith.o lj_clib.o lj_cparse.o \
397 lj_lib.o lj_alloc.o lib_aux.o \
398 $(LJLIB_O) lib_init.o
400 LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
401 LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)
403 LIB_VMDEF= ../lib/vmdef.lua
404 LIB_VMDEFP= $(LIB_VMDEF)
406 LUAJIT_O= luajit.o
407 LUAJIT_A= libluajit.a
408 LUAJIT_SO= libluajit.so
409 LUAJIT_T= luajit
411 ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(BUILDVM_T)
412 ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
413 ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
414 ALL_DYNGEN= buildvm_x86.h buildvm_x64.h buildvm_x64win.h buildvm_arm.h \
415 buildvm_ppc.h buildvm_ppcspe.h buildvm_mips.h
416 WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
417 ALL_RM= $(ALL_T) $(ALL_GEN) *.o $(WIN_RM)
419 ##############################################################################
420 # Build mode handling.
421 ##############################################################################
423 # Mixed mode defaults.
424 TARGET_O= $(LUAJIT_A)
425 TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
426 TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
428 ifeq (Windows,$(HOST_SYS))
429 BUILDVM_T= buildvm.exe
430 LIB_VMDEFP= $(subst /,\\,$(LIB_VMDEF))
431 endif
432 ifeq (Windows,$(TARGET_SYS))
433 TARGET_DYNCC= $(STATIC_CC)
434 LJVM_MODE= coffasm
435 LUAJIT_SO= $(TARGET_DLLNAME)
436 LUAJIT_T= luajit.exe
437 # Mixed mode is not supported on Windows. And static mode doesn't work well.
438 # C modules cannot be loaded, because they bind to lua51.dll.
439 ifneq (static,$(BUILDMODE))
440 BUILDMODE= dynamic
441 TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
442 endif
443 endif
444 ifeq (Darwin,$(TARGET_SYS))
445 LJVM_MODE= machasm
446 endif
447 ifeq (iOS,$(TARGET_SYS))
448 LJVM_MODE= machasm
449 endif
450 ifeq (SunOS,$(TARGET_SYS))
451 BUILDMODE= static
452 endif
454 ifeq (static,$(BUILDMODE))
455 TARGET_DYNCC= @:
456 TARGET_T= $(LUAJIT_T)
457 TARGET_DEP= $(LIB_VMDEF)
458 else
459 ifeq (dynamic,$(BUILDMODE))
460 ifneq (Windows,$(TARGET_SYS))
461 TARGET_CC= $(DYNAMIC_CC)
462 endif
463 TARGET_DYNCC= @:
464 LJVMCORE_DYNO= $(LJVMCORE_O)
465 TARGET_O= $(LUAJIT_SO)
466 TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
467 else
468 ifeq (Darwin,$(TARGET_SYS))
469 TARGET_DYNCC= @:
470 LJVMCORE_DYNO= $(LJVMCORE_O)
471 endif
472 ifeq (iOS,$(TARGET_SYS))
473 TARGET_DYNCC= @:
474 LJVMCORE_DYNO= $(LJVMCORE_O)
475 endif
476 endif
477 endif
479 Q= @
480 E= @echo
482 #E= @:
484 ##############################################################################
485 # Make targets.
486 ##############################################################################
488 default all: $(TARGET_T)
490 amalg:
491 @grep "^[+|]" ljamalg.c
492 $(MAKE) all "LJCORE_O=ljamalg.o"
494 clean:
495 $(HOST_RM) $(ALL_RM)
497 cleaner:
498 $(HOST_RM) $(ALL_RM) $(ALL_DYNGEN)
500 distclean: clean
501 $(E) "DYNASM $@"
502 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X86) -o buildvm_x86.h buildvm_x86.dasc
503 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64) -o buildvm_x64.h buildvm_x86.dasc
504 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64WIN) -o buildvm_x64win.h buildvm_x86.dasc
505 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_ARM) -o buildvm_arm.h buildvm_arm.dasc
506 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPC) -o buildvm_ppc.h buildvm_ppc.dasc
507 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPCSPE) -o buildvm_ppcspe.h buildvm_ppcspe.dasc
508 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_MIPS) -o buildvm_mips.h buildvm_mips.dasc
510 depend:
511 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
512 test -f $$file || touch $$file; \
513 done
514 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c | \
515 sed -e "s| [^ ]*/dasm_\S*\.h||g" \
516 -e "s| buildvm_\S*\.h||g" \
517 -e "s| lj_target_\S*\.h| lj_target_*.h|g" \
518 -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
519 -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
520 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
521 test -s $$file || $(HOST_RM) $$file; \
522 done
524 .PHONY: default all amalg clean cleaner distclean depend
526 ##############################################################################
527 # Rules for generated files.
528 ##############################################################################
530 buildvm_x86.h: buildvm_x86.dasc
531 $(E) "DYNASM $@"
532 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X86) -o $@ buildvm_x86.dasc
534 buildvm_x64.h: buildvm_x86.dasc
535 $(E) "DYNASM $@"
536 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64) -o $@ buildvm_x86.dasc
538 buildvm_x64win.h: buildvm_x86.dasc
539 $(E) "DYNASM $@"
540 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64WIN) -o $@ buildvm_x86.dasc
542 buildvm_arm.h: buildvm_arm.dasc
543 $(E) "DYNASM $@"
544 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_ARM) -o $@ buildvm_arm.dasc
546 buildvm_ppc.h: buildvm_ppc.dasc
547 $(E) "DYNASM $@"
548 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPC) -o $@ buildvm_ppc.dasc
550 buildvm_ppcspe.h: buildvm_ppcspe.dasc
551 $(E) "DYNASM $@"
552 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPCSPE) -o $@ buildvm_ppcspe.dasc
554 buildvm_mips.h: buildvm_mips.dasc
555 $(E) "DYNASM $@"
556 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_MIPS) -o $@ buildvm_mips.dasc
558 buildvm.o: $(ALL_DYNGEN) $(DASM_DIR)/dasm_*.h
560 $(BUILDVM_T): $(BUILDVM_O)
561 $(E) "HOSTLINK $@"
562 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
564 $(LJVM_BOUT): $(BUILDVM_T)
565 $(E) "BUILDVM $@"
566 $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
568 lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
569 $(E) "BUILDVM $@"
570 $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
572 lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
573 $(E) "BUILDVM $@"
574 $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
576 lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
577 $(E) "BUILDVM $@"
578 $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
580 lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
581 $(E) "BUILDVM $@"
582 $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
584 $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
585 $(E) "BUILDVM $@"
586 $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
588 lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
589 $(E) "BUILDVM $@"
590 $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c
592 ##############################################################################
593 # Object file rules.
594 ##############################################################################
596 %.o: %.c
597 $(E) "CC $@"
598 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
599 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
601 %.o: %.s
602 $(E) "ASM $@"
603 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
604 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
606 $(LUAJIT_O):
607 $(E) "CC $@"
608 $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<
610 $(HOST_O): %.o: %.c
611 $(E) "HOSTCC $@"
612 $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
614 include Makefile.dep
616 ##############################################################################
617 # Target file rules.
618 ##############################################################################
620 $(LUAJIT_A): $(LJVMCORE_O)
621 $(E) "AR $@"
622 $(Q)$(TARGET_AR) $@ $(LJVMCORE_O)
624 # The dependency on _O, but linking with _DYNO is intentional.
625 $(LUAJIT_SO): $(LJVMCORE_O)
626 $(E) "DYNLINK $@"
627 $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
628 $(Q)$(TARGET_STRIP) $@
630 $(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
631 $(E) "LINK $@"
632 $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
633 $(Q)$(TARGET_STRIP) $@
634 $(E) "OK Successfully built LuaJIT"
636 ##############################################################################