RELEASE LuaJIT-2.0.4
[luajit-2.0.git] / src / Makefile
blob1d38fa2516b0532bbfa5d7b8ed2c32712c2c6111
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-2015 Mike Pall. See Copyright Notice in luajit.h
11 ##############################################################################
13 MAJVER= 2
14 MINVER= 0
15 RELVER= 4
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. Better yet,
46 # compile for an architecture that has SSE2, too (-msse -msse2).
48 # x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
49 # the binaries to a different machine you could also use: -march=native
51 CCOPT_x86= -march=i686
52 CCOPT_x64=
53 CCOPT_arm=
54 CCOPT_ppc=
55 CCOPT_ppcspe=
56 CCOPT_mips=
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 # Features from Lua 5.2 that are unlikely to break existing code are
100 # enabled by default. Some other features that *might* break some existing
101 # code (e.g. __pairs or os.execute() return values) can be enabled here.
102 # Note: this does not provide 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 # Some architectures (e.g. PPC) can use either single-number (1) or
109 # dual-number (2) mode. Uncomment one of these lines to override the
110 # default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
111 #XCFLAGS+= -DLUAJIT_NUMMODE=1
112 #XCFLAGS+= -DLUAJIT_NUMMODE=2
114 ##############################################################################
116 ##############################################################################
117 ############################ DEBUGGING SUPPORT #############################
118 ##############################################################################
119 # Enable these options as needed, but make sure you force a full recompile
120 # with "make clean", followed by "make".
121 # Note that most of these are NOT suitable for benchmarking or release mode!
123 # Use the system provided memory allocator (realloc) instead of the
124 # bundled memory allocator. This is slower, but sometimes helpful for
125 # debugging. This option cannot be enabled on x64, since realloc usually
126 # doesn't return addresses in the right address range.
127 # OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
128 # the only way to get useful results from it for all other architectures.
129 #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
131 # This define is required to run LuaJIT under Valgrind. The Valgrind
132 # header files must be installed. You should enable debug information, too.
133 # Use --suppressions=lj.supp to avoid some false positives.
134 #XCFLAGS+= -DLUAJIT_USE_VALGRIND
136 # This is the client for the GDB JIT API. GDB 7.0 or higher is required
137 # to make use of it. See lj_gdbjit.c for details. Enabling this causes
138 # a non-negligible overhead, even when not running under GDB.
139 #XCFLAGS+= -DLUAJIT_USE_GDBJIT
141 # Turn on assertions for the Lua/C API to debug problems with lua_* calls.
142 # This is rather slow -- use only while developing C libraries/embeddings.
143 #XCFLAGS+= -DLUA_USE_APICHECK
145 # Turn on assertions for the whole LuaJIT VM. This significantly slows down
146 # everything. Use only if you suspect a problem with LuaJIT itself.
147 #XCFLAGS+= -DLUA_USE_ASSERT
149 ##############################################################################
150 # You probably don't need to change anything below this line!
151 ##############################################################################
153 ##############################################################################
154 # Flags and options for host and target.
155 ##############################################################################
157 # You can override the following variables at the make command line:
158 # CC HOST_CC STATIC_CC DYNAMIC_CC
159 # CFLAGS HOST_CFLAGS TARGET_CFLAGS
160 # LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
161 # LIBS HOST_LIBS TARGET_LIBS
162 # CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
164 # Cross-compilation examples:
165 # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
166 # make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
168 CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
169 LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
171 HOST_CC= $(CC)
172 HOST_RM= rm -f
173 # If left blank, minilua is built and used. You can supply an installed
174 # copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
175 HOST_LUA=
177 HOST_XCFLAGS= -I.
178 HOST_XLDFLAGS=
179 HOST_XLIBS=
180 HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
181 HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
182 HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)
184 STATIC_CC = $(CROSS)$(CC)
185 DYNAMIC_CC = $(CROSS)$(CC) -fPIC
186 TARGET_CC= $(STATIC_CC)
187 TARGET_STCC= $(STATIC_CC)
188 TARGET_DYNCC= $(DYNAMIC_CC)
189 TARGET_LD= $(CROSS)$(CC)
190 TARGET_AR= $(CROSS)ar rcus
191 TARGET_STRIP= $(CROSS)strip
193 TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
194 TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
195 TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
196 TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
197 TARGET_DLLNAME= lua$(NODOTABIVER).dll
198 TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
199 TARGET_DYNXLDOPTS=
201 TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
202 TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
203 TARGET_XLDFLAGS=
204 TARGET_XLIBS= -lm
205 TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
206 TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
207 TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
208 TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
209 TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
211 TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
212 ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
213 TARGET_LJARCH= x64
214 else
215 ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
216 TARGET_LJARCH= x86
217 else
218 ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
219 TARGET_LJARCH= arm
220 else
221 ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
222 TARGET_LJARCH= ppc
223 else
224 ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
225 TARGET_LJARCH= ppcspe
226 else
227 ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
228 ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
229 TARGET_ARCH= -D__MIPSEL__=1
230 endif
231 TARGET_LJARCH= mips
232 else
233 $(error Unsupported target architecture)
234 endif
235 endif
236 endif
237 endif
238 endif
239 endif
241 ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
242 TARGET_SYS= PS3
243 TARGET_ARCH+= -D__CELLOS_LV2__
244 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
245 endif
246 ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
247 TARGET_ARCH+= -DLUAJIT_NO_UNWIND
248 endif
250 TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
251 TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
253 ifneq (,$(PREFIX))
254 ifneq (/usr/local,$(PREFIX))
255 TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
256 ifneq (/usr,$(PREFIX))
257 TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH)
258 endif
259 endif
260 endif
261 ifneq (,$(MULTILIB))
262 TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
263 endif
264 ifneq (,$(LMULTILIB))
265 TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
266 endif
268 ##############################################################################
269 # System detection.
270 ##############################################################################
272 ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
273 HOST_SYS= Windows
274 HOST_RM= del
275 else
276 HOST_SYS:= $(shell uname -s)
277 ifneq (,$(findstring MINGW,$(HOST_SYS)))
278 HOST_SYS= Windows
279 HOST_MSYS= mingw
280 endif
281 ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
282 HOST_SYS= Windows
283 HOST_MSYS= cygwin
284 endif
285 endif
287 TARGET_SYS?= $(HOST_SYS)
288 ifeq (Windows,$(TARGET_SYS))
289 TARGET_STRIP+= --strip-unneeded
290 TARGET_XSHLDFLAGS= -shared
291 TARGET_DYNXLDOPTS=
292 else
293 ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
294 TARGET_XCFLAGS+= -fno-stack-protector
295 endif
296 ifeq (Darwin,$(TARGET_SYS))
297 ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
298 export MACOSX_DEPLOYMENT_TARGET=10.4
299 endif
300 TARGET_STRIP+= -x
301 TARGET_AR+= 2>/dev/null
302 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
303 TARGET_DYNXLDOPTS=
304 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
305 ifeq (x64,$(TARGET_LJARCH))
306 TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
307 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
308 endif
309 else
310 ifeq (iOS,$(TARGET_SYS))
311 TARGET_STRIP+= -x
312 TARGET_AR+= 2>/dev/null
313 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
314 TARGET_DYNXLDOPTS=
315 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
316 else
317 ifneq (SunOS,$(TARGET_SYS))
318 ifneq (PS3,$(TARGET_SYS))
319 TARGET_XLDFLAGS+= -Wl,-E
320 endif
321 endif
322 ifeq (Linux,$(TARGET_SYS))
323 TARGET_XLIBS+= -ldl
324 endif
325 ifeq (GNU/kFreeBSD,$(TARGET_SYS))
326 TARGET_XLIBS+= -ldl
327 endif
328 endif
329 endif
330 endif
332 ifneq ($(HOST_SYS),$(TARGET_SYS))
333 ifeq (Windows,$(TARGET_SYS))
334 HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
335 else
336 ifeq (Linux,$(TARGET_SYS))
337 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
338 else
339 ifeq (Darwin,$(TARGET_SYS))
340 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
341 else
342 ifeq (iOS,$(TARGET_SYS))
343 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
344 else
345 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
346 endif
347 endif
348 endif
349 endif
350 endif
352 ifneq (,$(CCDEBUG))
353 TARGET_STRIP= @:
354 endif
356 ##############################################################################
357 # Files and pathnames.
358 ##############################################################################
360 MINILUA_O= host/minilua.o
361 MINILUA_LIBS= -lm
362 MINILUA_T= host/minilua
363 MINILUA_X= $(MINILUA_T)
365 ifeq (,$(HOST_LUA))
366 HOST_LUA= $(MINILUA_X)
367 DASM_DEP= $(MINILUA_T)
368 endif
370 DASM_DIR= ../dynasm
371 DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
372 DASM_XFLAGS=
373 DASM_AFLAGS=
374 DASM_ARCH= $(TARGET_LJARCH)
376 ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
377 DASM_AFLAGS+= -D P64
378 endif
379 ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH)))
380 DASM_AFLAGS+= -D JIT
381 endif
382 ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH)))
383 DASM_AFLAGS+= -D FFI
384 endif
385 ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH)))
386 DASM_AFLAGS+= -D DUALNUM
387 endif
388 ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
389 DASM_AFLAGS+= -D FPU
390 TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
391 else
392 TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
393 endif
394 ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
395 DASM_AFLAGS+= -D HFABI
396 TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
397 else
398 TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
399 endif
400 DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
401 ifeq (Windows,$(TARGET_SYS))
402 DASM_AFLAGS+= -D WIN
403 endif
404 ifeq (x86,$(TARGET_LJARCH))
405 ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH)))
406 DASM_AFLAGS+= -D SSE
407 endif
408 else
409 ifeq (x64,$(TARGET_LJARCH))
410 DASM_ARCH= x86
411 else
412 ifeq (arm,$(TARGET_LJARCH))
413 ifeq (iOS,$(TARGET_SYS))
414 DASM_AFLAGS+= -D IOS
415 endif
416 else
417 ifeq (ppc,$(TARGET_LJARCH))
418 ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
419 DASM_AFLAGS+= -D SQRT
420 endif
421 ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
422 DASM_AFLAGS+= -D ROUND
423 endif
424 ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH)))
425 DASM_AFLAGS+= -D GPR64
426 endif
427 ifeq (PS3,$(TARGET_SYS))
428 DASM_AFLAGS+= -D PPE -D TOC
429 endif
430 endif
431 endif
432 endif
433 endif
435 DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
436 DASM_DASC= vm_$(DASM_ARCH).dasc
438 BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \
439 host/buildvm_lib.o host/buildvm_fold.o
440 BUILDVM_T= host/buildvm
441 BUILDVM_X= $(BUILDVM_T)
443 HOST_O= $(MINILUA_O) $(BUILDVM_O)
444 HOST_T= $(MINILUA_T) $(BUILDVM_T)
446 LJVM_S= lj_vm.s
447 LJVM_O= lj_vm.o
448 LJVM_BOUT= $(LJVM_S)
449 LJVM_MODE= elfasm
451 LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
452 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
453 LJLIB_C= $(LJLIB_O:.o=.c)
455 LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \
456 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
457 lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \
458 lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
459 lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
460 lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
461 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
462 lj_asm.o lj_trace.o lj_gdbjit.o \
463 lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
464 lj_carith.o lj_clib.o lj_cparse.o \
465 lj_lib.o lj_alloc.o lib_aux.o \
466 $(LJLIB_O) lib_init.o
468 LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
469 LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)
471 LIB_VMDEF= jit/vmdef.lua
472 LIB_VMDEFP= $(LIB_VMDEF)
474 LUAJIT_O= luajit.o
475 LUAJIT_A= libluajit.a
476 LUAJIT_SO= libluajit.so
477 LUAJIT_T= luajit
479 ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
480 ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
481 host/buildvm_arch.h
482 ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
483 WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
484 ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
486 ##############################################################################
487 # Build mode handling.
488 ##############################################################################
490 # Mixed mode defaults.
491 TARGET_O= $(LUAJIT_A)
492 TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
493 TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
495 ifeq (Windows,$(TARGET_SYS))
496 TARGET_DYNCC= $(STATIC_CC)
497 LJVM_MODE= peobj
498 LJVM_BOUT= $(LJVM_O)
499 LUAJIT_T= luajit.exe
500 ifeq (cygwin,$(HOST_MSYS))
501 LUAJIT_SO= cyg$(TARGET_DLLNAME)
502 else
503 LUAJIT_SO= $(TARGET_DLLNAME)
504 endif
505 # Mixed mode is not supported on Windows. And static mode doesn't work well.
506 # C modules cannot be loaded, because they bind to lua51.dll.
507 ifneq (static,$(BUILDMODE))
508 BUILDMODE= dynamic
509 TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
510 endif
511 endif
512 ifeq (Darwin,$(TARGET_SYS))
513 LJVM_MODE= machasm
514 endif
515 ifeq (iOS,$(TARGET_SYS))
516 LJVM_MODE= machasm
517 endif
518 ifeq (SunOS,$(TARGET_SYS))
519 BUILDMODE= static
520 endif
521 ifeq (PS3,$(TARGET_SYS))
522 BUILDMODE= static
523 endif
525 ifeq (Windows,$(HOST_SYS))
526 MINILUA_T= host/minilua.exe
527 BUILDVM_T= host/buildvm.exe
528 ifeq (,$(HOST_MSYS))
529 MINILUA_X= host\minilua
530 BUILDVM_X= host\buildvm
531 ALL_RM:= $(subst /,\,$(ALL_RM))
532 endif
533 endif
535 ifeq (static,$(BUILDMODE))
536 TARGET_DYNCC= @:
537 TARGET_T= $(LUAJIT_T)
538 TARGET_DEP= $(LIB_VMDEF)
539 else
540 ifeq (dynamic,$(BUILDMODE))
541 ifneq (Windows,$(TARGET_SYS))
542 TARGET_CC= $(DYNAMIC_CC)
543 endif
544 TARGET_DYNCC= @:
545 LJVMCORE_DYNO= $(LJVMCORE_O)
546 TARGET_O= $(LUAJIT_SO)
547 TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
548 else
549 ifeq (Darwin,$(TARGET_SYS))
550 TARGET_DYNCC= @:
551 LJVMCORE_DYNO= $(LJVMCORE_O)
552 endif
553 ifeq (iOS,$(TARGET_SYS))
554 TARGET_DYNCC= @:
555 LJVMCORE_DYNO= $(LJVMCORE_O)
556 endif
557 endif
558 endif
560 Q= @
561 E= @echo
563 #E= @:
565 ##############################################################################
566 # Make targets.
567 ##############################################################################
569 default all: $(TARGET_T)
571 amalg:
572 @grep "^[+|]" ljamalg.c
573 $(MAKE) all "LJCORE_O=ljamalg.o"
575 clean:
576 $(HOST_RM) $(ALL_RM)
578 depend:
579 @for file in $(ALL_HDRGEN); do \
580 test -f $$file || touch $$file; \
581 done
582 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \
583 sed -e "s| [^ ]*/dasm_\S*\.h||g" \
584 -e "s|^\([^l ]\)|host/\1|" \
585 -e "s| lj_target_\S*\.h| lj_target_*.h|g" \
586 -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
587 -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
588 @for file in $(ALL_HDRGEN); do \
589 test -s $$file || $(HOST_RM) $$file; \
590 done
592 .PHONY: default all amalg clean depend
594 ##############################################################################
595 # Rules for generated files.
596 ##############################################################################
598 $(MINILUA_T): $(MINILUA_O)
599 $(E) "HOSTLINK $@"
600 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
602 host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
603 $(E) "DYNASM $@"
604 $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
606 host/buildvm.o: $(DASM_DIR)/dasm_*.h
608 $(BUILDVM_T): $(BUILDVM_O)
609 $(E) "HOSTLINK $@"
610 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
612 $(LJVM_BOUT): $(BUILDVM_T)
613 $(E) "BUILDVM $@"
614 $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
616 lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
617 $(E) "BUILDVM $@"
618 $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
620 lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
621 $(E) "BUILDVM $@"
622 $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
624 lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
625 $(E) "BUILDVM $@"
626 $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
628 lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
629 $(E) "BUILDVM $@"
630 $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
632 $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
633 $(E) "BUILDVM $@"
634 $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
636 lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
637 $(E) "BUILDVM $@"
638 $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c
640 ##############################################################################
641 # Object file rules.
642 ##############################################################################
644 %.o: %.c
645 $(E) "CC $@"
646 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
647 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
649 %.o: %.s
650 $(E) "ASM $@"
651 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
652 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
654 $(LUAJIT_O):
655 $(E) "CC $@"
656 $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<
658 $(HOST_O): %.o: %.c
659 $(E) "HOSTCC $@"
660 $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
662 include Makefile.dep
664 ##############################################################################
665 # Target file rules.
666 ##############################################################################
668 $(LUAJIT_A): $(LJVMCORE_O)
669 $(E) "AR $@"
670 $(Q)$(TARGET_AR) $@ $(LJVMCORE_O)
672 # The dependency on _O, but linking with _DYNO is intentional.
673 $(LUAJIT_SO): $(LJVMCORE_O)
674 $(E) "DYNLINK $@"
675 $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
676 $(Q)$(TARGET_STRIP) $@
678 $(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
679 $(E) "LINK $@"
680 $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
681 $(Q)$(TARGET_STRIP) $@
682 $(E) "OK Successfully built LuaJIT"
684 ##############################################################################