x64: Fix math.random() code generation.
[luajit-2.0.git] / src / Makefile
blobacde0dbbed39834559f60641f990c0873c186d63
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-2011 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=
58 CCDEBUG=
59 # Uncomment the next line to generate debug information:
60 #CCDEBUG= -g
62 CCWARN= -Wall
63 # Uncomment the next line to enable more warnings:
64 #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
66 ##############################################################################
68 ##############################################################################
69 ################################ BUILD MODE ################################
70 ##############################################################################
71 # The default build mode is mixed mode on POSIX. On Windows this is the same
72 # as dynamic mode.
74 # Mixed mode creates a static + dynamic library and a statically linked luajit.
75 BUILDMODE= mixed
77 # Static mode creates a static library and a statically linked luajit.
78 #BUILDMODE= static
80 # Dynamic mode creates a dynamic library and a dynamically linked luajit.
81 # Note: this executable will only run when the library is installed!
82 #BUILDMODE= dynamic
84 ##############################################################################
86 ##############################################################################
87 ################################# FEATURES #################################
88 ##############################################################################
89 # Enable/disable these features as needed, but make sure you force a full
90 # recompile with "make clean", followed by "make".
91 XCFLAGS=
93 # Permanently disable the FFI extension to reduce the size of the LuaJIT
94 # executable. But please consider that the FFI library is compiled-in,
95 # but NOT loaded by default. It only allocates any memory, if you actually
96 # make use of it.
97 #XCFLAGS+= -DLUAJIT_DISABLE_FFI
99 # Enable some upwards-compatible features from Lua 5.2 that are unlikely
100 # to break existing code (e.g. __pairs). Note that this does not provide
101 # full compatibility with Lua 5.2 at this time.
102 #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
104 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
105 #XCFLAGS+= -DLUAJIT_DISABLE_JIT
107 # x86 only: use SSE2 instead of x87 instructions in the interpreter
108 # (always enabled for x64). A pure interpreter built with this flag won't
109 # run on older CPUs (before P4 or K8). There isn't much of a speed
110 # difference, so this is not enabled by default.
111 # The JIT compiler is not affected by this flag. It always uses runtime
112 # CPU feature detection before emitting code for SSE2 up to SSE4.1.
113 #XCFLAGS+= -DLUAJIT_CPU_SSE2
115 # x86 only: Disable the use of CMOV and FCOMI*/FUCOMI* instructions in the
116 # interpreter. Do this only if you intend to use REALLY ANCIENT CPUs
117 # (before Pentium Pro, or on the VIA C3). This generally slows down the
118 # interpreter. Don't bother if your OS wouldn't run on them, anyway.
119 #XCFLAGS+= -DLUAJIT_CPU_NOCMOV
121 ##############################################################################
123 ##############################################################################
124 ############################ DEBUGGING SUPPORT #############################
125 ##############################################################################
126 # Enable these options as needed, but make sure you force a full recompile
127 # with "make clean", followed by "make".
128 # Note that most of these are NOT suitable for benchmarking or release mode!
130 # Use the system provided memory allocator (realloc) instead of the
131 # bundled memory allocator. This is slower, but sometimes helpful for
132 # debugging. It's helpful for Valgrind's memcheck tool, too. This option
133 # cannot be enabled on x64, since the built-in allocator is mandatory.
134 #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
136 # This define is required to run LuaJIT under Valgrind. The Valgrind
137 # header files must be installed. You should enable debug information, too.
138 #XCFLAGS+= -DLUAJIT_USE_VALGRIND
140 # This is the client for the GDB JIT API. GDB 7.0 or higher is required
141 # to make use of it. See lj_gdbjit.c for details. Enabling this causes
142 # a non-negligible overhead, even when not running under GDB.
143 #XCFLAGS+= -DLUAJIT_USE_GDBJIT
145 # Turn on assertions for the Lua/C API to debug problems with lua_* calls.
146 # This is rather slow -- use only while developing C libraries/embeddings.
147 #XCFLAGS+= -DLUA_USE_APICHECK
149 # Turn on assertions for the whole LuaJIT VM. This significantly slows down
150 # everything. Use only if you suspect a problem with LuaJIT itself.
151 #XCFLAGS+= -DLUA_USE_ASSERT
153 ##############################################################################
154 # You probably don't need to change anything below this line!
155 ##############################################################################
157 ##############################################################################
158 # Flags and options for host and target.
159 ##############################################################################
161 # You can override the following variables at the make command line:
162 # CC HOST_CC STATIC_CC DYNAMIC_CC
163 # CFLAGS HOST_CFLAGS TARGET_CFLAGS
164 # LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
165 # LIBS HOST_LIBS TARGET_LIBS
166 # CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
168 # Cross-compilation examples:
169 # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
170 # make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe- TARGET=ppcspe
172 CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
173 LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
175 TARGET_ARCH= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET))
177 HOST_CC= $(CC)
178 HOST_RM= rm -f
179 # NOTE: The LuaJIT distribution comes with pre-generated buildvm_*.h files.
180 # You DO NOT NEED an installed copy of (plain) Lua 5.1 to run DynASM unless
181 # you want to MODIFY the corresponding *.dasc file. You can also use LuaJIT
182 # itself (bootstrapped from a pre-generated file) to run DynASM of course.
183 HOST_LUA= lua
185 HOST_XCFLAGS=
186 HOST_XLDFLAGS=
187 HOST_XLIBS=
188 HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
189 HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
190 HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)
192 STATIC_CC = $(CROSS)$(CC)
193 DYNAMIC_CC = $(CROSS)$(CC) -fPIC
194 TARGET_CC= $(STATIC_CC)
195 TARGET_STCC= $(STATIC_CC)
196 TARGET_DYNCC= $(DYNAMIC_CC)
197 TARGET_LD= $(CROSS)$(CC)
198 TARGET_AR= $(CROSS)ar rcus
199 TARGET_STRIP= $(CROSS)strip
201 TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
202 TARGET_DYLIBNAME= libluajit-$(NODOTABIVER).$(MAJVER).dylib
203 TARGET_DYLIBPATH= $(or $(PREFIX),/usr/local)/lib/$(TARGET_DYLIBNAME)
204 TARGET_DLLNAME= lua$(NODOTABIVER).dll
205 TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
206 TARGET_DYNXLDOPTS=
208 TARGET_XCFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U_FORTIFY_SOURCE
209 TARGET_XLDFLAGS=
210 TARGET_XLIBS= -lm
211 TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS)
212 TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
213 TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
214 TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
216 ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
217 TARGET_XCFLAGS+= -fno-stack-protector
218 endif
220 TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_ACFLAGS) -E lj_arch.h -dM)
221 ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
222 TARGET_CCARCH= x64
223 TARGET_XCFLAGS+= $(CCOPT_X64)
224 else
225 ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
226 TARGET_CCARCH= x86
227 TARGET_XCFLAGS+= $(CCOPT_X86)
228 else
229 ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
230 TARGET_CCARCH= arm
231 TARGET_XCFLAGS+= $(CCOPT_ARM)
232 else
233 ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
234 TARGET_CCARCH= ppc
235 TARGET_XCFLAGS+= $(CCOPT_PPC)
236 else
237 ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
238 TARGET_CCARCH= ppcspe
239 TARGET_XCFLAGS+= $(CCOPT_PPCSPE)
240 else
241 $(error Unsupported target architecture)
242 endif
243 endif
244 endif
245 endif
246 endif
248 ifneq (,$(PREFIX))
249 ifneq (/usr/local,$(PREFIX))
250 TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\"
251 ifneq (/usr,$(PREFIX))
252 TARGET_DYNXLDOPTS= -Wl,-rpath,$(PREFIX)/lib
253 endif
254 endif
255 endif
257 ##############################################################################
258 # System detection.
259 ##############################################################################
261 ifneq (,$(findstring Windows,$(OS)))
262 HOST_SYS= Windows
263 else
264 HOST_SYS:= $(shell uname -s)
265 ifneq (,$(findstring CYGWIN,$(TARGET_SYS)))
266 HOST_SYS= Windows
267 endif
268 endif
269 ifeq (Windows,$(HOST_SYS))
270 HOST_RM= del
271 endif
273 TARGET_SYS= $(HOST_SYS)
274 ifeq (Windows,$(TARGET_SYS))
275 TARGET_STRIP+= --strip-unneeded
276 TARGET_XSHLDFLAGS= -shared
277 TARGET_DYNXLDOPTS=
278 else
279 ifeq (Darwin,$(TARGET_SYS))
280 export MACOSX_DEPLOYMENT_TARGET=10.4
281 TARGET_STRIP+= -x
282 TARGET_AR+= 2>/dev/null
283 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
284 TARGET_DYNXLDOPTS=
285 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
286 ifeq (x64,$(TARGET_CCARCH))
287 TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
288 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
289 endif
290 else
291 ifeq (iOS,$(TARGET_SYS))
292 TARGET_STRIP+= -x
293 TARGET_AR+= 2>/dev/null
294 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
295 TARGET_DYNXLDOPTS=
296 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
297 else
298 ifneq (SunOS,$(TARGET_SYS))
299 TARGET_XLDFLAGS+= -Wl,-E
300 endif
301 ifeq (Linux,$(TARGET_SYS))
302 TARGET_XLIBS+= -ldl
303 endif
304 ifeq (GNU/kFreeBSD,$(TARGET_SYS))
305 TARGET_XLIBS+= -ldl
306 endif
307 endif
308 endif
309 endif
311 ifneq ($(HOST_SYS),$(TARGET_SYS))
312 ifeq (Windows,$(TARGET_SYS))
313 HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
314 else
315 ifeq (Linux,$(TARGET_SYS))
316 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
317 else
318 ifeq (Darwin,$(TARGET_SYS))
319 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
320 else
321 ifeq (iOS,$(TARGET_SYS))
322 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
323 else
324 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
325 endif
326 endif
327 endif
328 endif
329 endif
331 ifneq (,$(CCDEBUG))
332 TARGET_STRIP= @:
333 endif
335 ##############################################################################
336 # Files and pathnames.
337 ##############################################################################
339 DASM_DIR= ../dynasm
340 DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
341 DASM_FLAGS=
342 DASM_DISTFLAGS= -LN
343 DASM_FLAGS_X86=
344 DASM_FLAGS_X64= -D X64
345 DASM_FLAGS_X64WIN= -D X64 -D X64WIN
346 DASM_FLAGS_ARM=
347 DASM_FLAGS_PPC=
348 DASM_FLAGS_PPCSPE=
350 BUILDVM_O= buildvm.o buildvm_asm.o buildvm_peobj.o buildvm_lib.o buildvm_fold.o
351 BUILDVM_T= buildvm
352 BUILDVM_X= ./$(BUILDVM_T)
354 HOST_O= $(BUILDVM_O)
355 HOST_T= $(BUILDVM_T)
357 LJVM_S= lj_vm.s
358 LJVM_O= lj_vm.o
359 LJVM_BOUT= $(LJVM_S)
360 LJVM_MODE= elfasm
362 LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
363 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
364 LJLIB_C= $(LJLIB_O:.o=.c)
366 LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \
367 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
368 lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_api.o \
369 lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o \
370 lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
371 lj_opt_dce.o lj_opt_loop.o lj_opt_split.o \
372 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
373 lj_asm.o lj_trace.o lj_gdbjit.o \
374 lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_carith.o lj_clib.o \
375 lj_cparse.o \
376 lj_lib.o lj_alloc.o lib_aux.o \
377 $(LJLIB_O) lib_init.o
379 LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
380 LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)
382 LIB_VMDEF= ../lib/vmdef.lua
383 LIB_VMDEFP= $(LIB_VMDEF)
385 LUAJIT_O= luajit.o
386 LUAJIT_A= libluajit.a
387 LUAJIT_SO= libluajit.so
388 LUAJIT_T= luajit
390 ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(BUILDVM_T)
391 ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
392 ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
393 ALL_DYNGEN= buildvm_x86.h buildvm_x64.h buildvm_x64win.h buildvm_arm.h \
394 buildvm_ppc.h buildvm_ppcspe.h
395 WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
396 ALL_RM= $(ALL_T) $(ALL_GEN) *.o $(WIN_RM)
398 ##############################################################################
399 # Build mode handling.
400 ##############################################################################
402 # Mixed mode defaults.
403 TARGET_O= $(LUAJIT_A)
404 TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
405 TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
407 ifeq (Windows,$(HOST_SYS))
408 BUILDVM_T= buildvm.exe
409 LIB_VMDEFP= $(subst /,\\,$(LIB_VMDEF))
410 endif
411 ifeq (Windows,$(TARGET_SYS))
412 TARGET_DYNCC= $(STATIC_CC)
413 LJVM_MODE= coffasm
414 LUAJIT_SO= $(TARGET_DLLNAME)
415 LUAJIT_T= luajit.exe
416 # Mixed mode is not supported on Windows. And static mode doesn't work well.
417 # C modules cannot be loaded, because they bind to lua51.dll.
418 ifneq (static,$(BUILDMODE))
419 BUILDMODE= dynamic
420 TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
421 endif
422 endif
423 ifeq (Darwin,$(TARGET_SYS))
424 LJVM_MODE= machasm
425 endif
426 ifeq (iOS,$(TARGET_SYS))
427 LJVM_MODE= machasm
428 endif
429 ifeq (SunOS,$(TARGET_SYS))
430 BUILDMODE= static
431 endif
433 ifeq (static,$(BUILDMODE))
434 TARGET_DYNCC= @:
435 TARGET_T= $(LUAJIT_T)
436 TARGET_DEP= $(LIB_VMDEF)
437 else
438 ifeq (dynamic,$(BUILDMODE))
439 ifneq (Windows,$(TARGET_SYS))
440 TARGET_CC= $(DYNAMIC_CC)
441 endif
442 TARGET_DYNCC= @:
443 LJVMCORE_DYNO= $(LJVMCORE_O)
444 TARGET_O= $(LUAJIT_SO)
445 TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
446 else
447 ifeq (Darwin,$(TARGET_SYS))
448 TARGET_DYNCC= @:
449 LJVMCORE_DYNO= $(LJVMCORE_O)
450 endif
451 ifeq (iOS,$(TARGET_SYS))
452 TARGET_DYNCC= @:
453 LJVMCORE_DYNO= $(LJVMCORE_O)
454 endif
455 endif
456 endif
458 Q= @
459 E= @echo
461 #E= @:
463 ##############################################################################
464 # Make targets.
465 ##############################################################################
467 default all: $(TARGET_T)
469 amalg:
470 @grep "^[+|]" ljamalg.c
471 $(MAKE) all "LJCORE_O=ljamalg.o"
473 clean:
474 $(HOST_RM) $(ALL_RM)
476 cleaner:
477 $(HOST_RM) $(ALL_RM) $(ALL_DYNGEN)
479 distclean: clean
480 $(E) "DYNASM $@"
481 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X86) -o buildvm_x86.h buildvm_x86.dasc
482 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64) -o buildvm_x64.h buildvm_x86.dasc
483 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64WIN) -o buildvm_x64win.h buildvm_x86.dasc
484 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_ARM) -o buildvm_arm.h buildvm_arm.dasc
485 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPC) -o buildvm_ppc.h buildvm_ppc.dasc
486 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPCSPE) -o buildvm_ppcspe.h buildvm_ppcspe.dasc
488 depend:
489 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
490 test -f $$file || touch $$file; \
491 done
492 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c | \
493 sed -e "s| [^ ]*/dasm_\S*\.h||g" \
494 -e "s| buildvm_\S*\.h||g" \
495 -e "s| lj_target_\S*\.h| lj_target_*.h|g" \
496 -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
497 -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
498 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
499 test -s $$file || $(HOST_RM) $$file; \
500 done
502 .PHONY: default all amalg clean cleaner distclean depend
504 ##############################################################################
505 # Rules for generated files.
506 ##############################################################################
508 buildvm_x86.h: buildvm_x86.dasc
509 $(E) "DYNASM $@"
510 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X86) -o $@ buildvm_x86.dasc
512 buildvm_x64.h: buildvm_x86.dasc
513 $(E) "DYNASM $@"
514 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64) -o $@ buildvm_x86.dasc
516 buildvm_x64win.h: buildvm_x86.dasc
517 $(E) "DYNASM $@"
518 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64WIN) -o $@ buildvm_x86.dasc
520 buildvm_arm.h: buildvm_arm.dasc
521 $(E) "DYNASM $@"
522 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_ARM) -o $@ buildvm_arm.dasc
524 buildvm_ppc.h: buildvm_ppc.dasc
525 $(E) "DYNASM $@"
526 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPC) -o $@ buildvm_ppc.dasc
528 buildvm_ppcspe.h: buildvm_ppcspe.dasc
529 $(E) "DYNASM $@"
530 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPCSPE) -o $@ buildvm_ppcspe.dasc
532 buildvm.o: $(ALL_DYNGEN) $(DASM_DIR)/dasm_*.h
534 $(BUILDVM_T): $(BUILDVM_O)
535 $(E) "HOSTLINK $@"
536 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
538 $(LJVM_BOUT): $(BUILDVM_T)
539 $(E) "BUILDVM $@"
540 $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
542 lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
543 $(E) "BUILDVM $@"
544 $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
546 lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
547 $(E) "BUILDVM $@"
548 $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
550 lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
551 $(E) "BUILDVM $@"
552 $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
554 lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
555 $(E) "BUILDVM $@"
556 $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
558 $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
559 $(E) "BUILDVM $@"
560 $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
562 lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
563 $(E) "BUILDVM $@"
564 $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c
566 ##############################################################################
567 # Object file rules.
568 ##############################################################################
570 %.o: %.c
571 $(E) "CC $@"
572 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
573 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
575 %.o: %.s
576 $(E) "ASM $@"
577 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
578 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
580 $(LUAJIT_O):
581 $(E) "CC $@"
582 $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<
584 $(HOST_O): %.o: %.c
585 $(E) "HOSTCC $@"
586 $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
588 include Makefile.dep
590 ##############################################################################
591 # Target file rules.
592 ##############################################################################
594 $(LUAJIT_A): $(LJVMCORE_O)
595 $(E) "AR $@"
596 $(Q)$(TARGET_AR) $@ $(LJVMCORE_O)
598 # The dependency on _O, but linking with _DYNO is intentional.
599 $(LUAJIT_SO): $(LJVMCORE_O)
600 $(E) "DYNLINK $@"
601 $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
602 $(Q)$(TARGET_STRIP) $@
604 $(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
605 $(E) "LINK $@"
606 $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
607 $(Q)$(TARGET_STRIP) $@
608 $(E) "OK Successfully built LuaJIT"
610 ##############################################################################