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-2023 Mike Pall. See Copyright Notice in luajit.h
11 ##############################################################################
18 ##############################################################################
19 ############################# COMPILER OPTIONS #############################
20 ##############################################################################
21 # These options mainly affect the speed of the JIT compiler itself, not the
22 # speed of the JIT-compiled code. Turn any of the optional settings on by
23 # removing the '#' in front of them. Make sure you force a full recompile
24 # with "make clean", followed by "make" if you change any options.
28 # LuaJIT builds as a native 32 or 64 bit binary by default.
31 # Use this if you want to force a 32 bit build on a 64 bit multilib OS.
32 #CC= $(DEFAULT_CC) -m32
34 # Since the assembler part does NOT maintain a frame pointer, it's pointless
35 # to slow down the C part by not omitting it. Debugging, tracebacks and
36 # unwinding are not affected -- the assembler part has frame unwind
37 # information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
38 CCOPT
= -O2
-fomit-frame-pointer
39 # Use this if you want to generate a smaller binary (but it's slower):
40 #CCOPT= -Os -fomit-frame-pointer
41 # Note: it's no longer recommended to use -O3 with GCC 4.x.
42 # The I-Cache bloat usually outweighs the benefits from aggressive inlining.
44 # Target-specific compiler options:
46 # x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
47 # the binaries to a different machine you could also use: -march=native
49 CCOPT_x86
= -march
=i686
-msse
-msse2
-mfpmath
=sse
57 # Uncomment the next line to generate debug information:
61 # Uncomment the next line to enable more warnings:
62 #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
64 ##############################################################################
66 ##############################################################################
67 ################################ BUILD MODE ################################
68 ##############################################################################
69 # The default build mode is mixed mode on POSIX. On Windows this is the same
72 # Mixed mode creates a static + dynamic library and a statically linked luajit.
75 # Static mode creates a static library and a statically linked luajit.
78 # Dynamic mode creates a dynamic library and a dynamically linked luajit.
79 # Note: this executable will only run when the library is installed!
82 ##############################################################################
84 ##############################################################################
85 ################################# FEATURES #################################
86 ##############################################################################
87 # Enable/disable these features as needed, but make sure you force a full
88 # recompile with "make clean", followed by "make".
91 # Permanently disable the FFI extension to reduce the size of the LuaJIT
92 # executable. But please consider that the FFI library is compiled-in,
93 # but NOT loaded by default. It only allocates any memory, if you actually
95 #XCFLAGS+= -DLUAJIT_DISABLE_FFI
97 # Features from Lua 5.2 that are unlikely to break existing code are
98 # enabled by default. Some other features that *might* break some existing
99 # code (e.g. __pairs or os.execute() return values) can be enabled here.
100 # Note: this does not provide full compatibility with Lua 5.2 at this time.
101 #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
103 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
104 #XCFLAGS+= -DLUAJIT_DISABLE_JIT
106 # Some architectures (e.g. PPC) can use either single-number (1) or
107 # dual-number (2) mode. Uncomment one of these lines to override the
108 # default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
109 #XCFLAGS+= -DLUAJIT_NUMMODE=1
110 #XCFLAGS+= -DLUAJIT_NUMMODE=2
112 # Disable LJ_GC64 mode for x64.
113 #XCFLAGS+= -DLUAJIT_DISABLE_GC64
115 ##############################################################################
117 ##############################################################################
118 ############################ DEBUGGING SUPPORT #############################
119 ##############################################################################
120 # Enable these options as needed, but make sure you force a full recompile
121 # with "make clean", followed by "make".
122 # Note that most of these are NOT suitable for benchmarking or release mode!
124 # Use the system provided memory allocator (realloc) instead of the
125 # bundled memory allocator. This is slower, but sometimes helpful for
126 # debugging. This option cannot be enabled on x64 without GC64, since
127 # realloc usually doesn't return addresses in the right address range.
128 # OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
129 # the only way to get useful results from it for all other architectures.
130 #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
132 # This define is required to run LuaJIT under Valgrind. The Valgrind
133 # header files must be installed. You should enable debug information, too.
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 # Host system detection.
155 ##############################################################################
157 ifeq (Windows
,$(findstring Windows
,$(OS
))$(MSYSTEM
)$(TERM
))
160 HOST_SYS
:= $(shell uname
-s
)
161 ifneq (,$(findstring MINGW
,$(HOST_SYS
)))
165 ifneq (,$(findstring MSYS
,$(HOST_SYS
)))
169 ifneq (,$(findstring CYGWIN
,$(HOST_SYS
)))
175 ##############################################################################
176 # Flags and options for host and target.
177 ##############################################################################
179 # You can override the following variables at the make command line:
180 # CC HOST_CC STATIC_CC DYNAMIC_CC
181 # CFLAGS HOST_CFLAGS TARGET_CFLAGS
182 # LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
183 # LIBS HOST_LIBS TARGET_LIBS
184 # CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
186 # Cross-compilation examples:
187 # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
188 # make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
190 ASOPTIONS
= $(CCOPT
) $(CCWARN
) $(XCFLAGS
) $(CFLAGS
)
191 CCOPTIONS
= $(CCDEBUG
) $(ASOPTIONS
)
192 LDOPTIONS
= $(CCDEBUG
) $(LDFLAGS
)
196 # If left blank, minilua is built and used. You can supply an installed
197 # copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
203 HOST_ACFLAGS
= $(CCOPTIONS
) $(HOST_XCFLAGS
) $(TARGET_ARCH
) $(HOST_CFLAGS
)
204 HOST_ALDFLAGS
= $(LDOPTIONS
) $(HOST_XLDFLAGS
) $(HOST_LDFLAGS
)
205 HOST_ALIBS
= $(HOST_XLIBS
) $(LIBS
) $(HOST_LIBS
)
207 STATIC_CC
= $(CROSS
)$(CC
)
208 DYNAMIC_CC
= $(CROSS
)$(CC
) -fPIC
209 TARGET_CC
= $(STATIC_CC
)
210 TARGET_STCC
= $(STATIC_CC
)
211 TARGET_DYNCC
= $(DYNAMIC_CC
)
212 TARGET_LD
= $(CROSS
)$(CC
)
213 TARGET_AR
= $(CROSS
)ar rcus
214 TARGET_STRIP
= $(CROSS
)strip
216 TARGET_LIBPATH
= $(or
$(PREFIX
),/usr
/local
)/$(or
$(MULTILIB
),lib
)
217 TARGET_SONAME
= libluajit-
$(ABIVER
).so.
$(MAJVER
)
218 TARGET_DYLIBNAME
= libluajit-
$(ABIVER
).
$(MAJVER
).dylib
219 TARGET_DYLIBPATH
= $(TARGET_LIBPATH
)/$(TARGET_DYLIBNAME
)
220 TARGET_DLLNAME
= lua
$(NODOTABIVER
).dll
221 TARGET_DLLDOTANAME
= libluajit-
$(ABIVER
).dll.a
222 TARGET_XSHLDFLAGS
= -shared
-fPIC
-Wl
,-soname
,$(TARGET_SONAME
)
225 TARGET_LFSFLAGS
= -D_FILE_OFFSET_BITS
=64 -D_LARGEFILE_SOURCE
226 TARGET_XCFLAGS
= $(TARGET_LFSFLAGS
) -U_FORTIFY_SOURCE
229 TARGET_TCFLAGS
= $(CCOPTIONS
) $(TARGET_XCFLAGS
) $(TARGET_FLAGS
) $(TARGET_CFLAGS
)
230 TARGET_ACFLAGS
= $(CCOPTIONS
) $(TARGET_XCFLAGS
) $(TARGET_FLAGS
) $(TARGET_CFLAGS
)
231 TARGET_ASFLAGS
= $(ASOPTIONS
) $(TARGET_XCFLAGS
) $(TARGET_FLAGS
) $(TARGET_CFLAGS
)
232 TARGET_ALDFLAGS
= $(LDOPTIONS
) $(TARGET_XLDFLAGS
) $(TARGET_FLAGS
) $(TARGET_LDFLAGS
)
233 TARGET_ASHLDFLAGS
= $(LDOPTIONS
) $(TARGET_XSHLDFLAGS
) $(TARGET_FLAGS
) $(TARGET_SHLDFLAGS
)
234 TARGET_ALIBS
= $(TARGET_XLIBS
) $(LIBS
) $(TARGET_LIBS
)
236 TARGET_TESTARCH
:=$(shell $(TARGET_CC
) $(TARGET_TCFLAGS
) -E lj_arch.h
-dM
)
237 ifneq (,$(findstring LJ_TARGET_X64
,$(TARGET_TESTARCH
)))
240 ifneq (,$(findstring LJ_TARGET_X86
,$(TARGET_TESTARCH
)))
243 ifneq (,$(findstring LJ_TARGET_ARM
,$(TARGET_TESTARCH
)))
246 ifneq (,$(findstring LJ_TARGET_ARM64
,$(TARGET_TESTARCH
)))
247 ifneq (,$(findstring __AARCH64EB__
,$(TARGET_TESTARCH
)))
248 TARGET_ARCH
= -D__AARCH64EB__
=1
252 ifneq (,$(findstring LJ_TARGET_PPC
,$(TARGET_TESTARCH
)))
253 ifneq (,$(findstring LJ_LE
1,$(TARGET_TESTARCH
)))
254 TARGET_ARCH
= -DLJ_ARCH_ENDIAN
=LUAJIT_LE
256 TARGET_ARCH
= -DLJ_ARCH_ENDIAN
=LUAJIT_BE
260 ifneq (,$(findstring LJ_TARGET_MIPS
,$(TARGET_TESTARCH
)))
261 ifneq (,$(findstring MIPSEL
,$(TARGET_TESTARCH
)))
262 TARGET_ARCH
= -D__MIPSEL__
=1
264 ifneq (,$(findstring LJ_TARGET_MIPS64
,$(TARGET_TESTARCH
)))
265 TARGET_LJARCH
= mips64
270 $(error Unsupported target architecture
)
278 ifneq (,$(findstring LJ_TARGET_PS3
1,$(TARGET_TESTARCH
)))
280 TARGET_ARCH
+= -D__CELLOS_LV2__
281 TARGET_XCFLAGS
+= -DLUAJIT_USE_SYSMALLOC
282 TARGET_XLIBS
+= -lpthread
285 TARGET_XCFLAGS
+= $(CCOPT_
$(TARGET_LJARCH
))
286 TARGET_ARCH
+= $(patsubst %,-DLUAJIT_TARGET
=LUAJIT_ARCH_
%,$(TARGET_LJARCH
))
289 ifneq (/usr
/local
,$(PREFIX
))
290 TARGET_XCFLAGS
+= -DLUA_ROOT
=\"$(PREFIX
)\"
291 ifneq (/usr
,$(PREFIX
))
292 TARGET_DYNXLDOPTS
= -Wl
,-rpath
,$(TARGET_LIBPATH
)
297 TARGET_XCFLAGS
+= -DLUA_MULTILIB
=\"$(MULTILIB
)\"
299 ifneq (,$(LMULTILIB
))
300 TARGET_XCFLAGS
+= -DLUA_LMULTILIB
=\"$(LMULTILIB
)\"
302 ifneq (,$(INSTALL_LJLIBD
))
303 TARGET_XCFLAGS
+= -DLUA_LJDIR
=\"$(INSTALL_LJLIBD
)\"
306 ##############################################################################
307 # Target system detection.
308 ##############################################################################
310 TARGET_SYS?
= $(HOST_SYS
)
311 ifeq (Windows
,$(TARGET_SYS
))
312 TARGET_STRIP
+= --strip-unneeded
313 TARGET_XSHLDFLAGS
= -shared
-Wl
,--out-implib
,$(TARGET_DLLDOTANAME
)
316 TARGET_AR
+= 2>/dev
/null
317 ifeq (,$(shell $(TARGET_CC
) -o
/dev
/null
-c
-x c
/dev
/null
-fno-stack-protector
2>/dev
/null || echo
1))
318 TARGET_XCFLAGS
+= -fno-stack-protector
320 ifeq (Darwin
,$(TARGET_SYS
))
321 ifeq (,$(MACOSX_DEPLOYMENT_TARGET
))
322 $(error missing
: export MACOSX_DEPLOYMENT_TARGET
=XX.YY
)
325 TARGET_XCFLAGS
+= -DLUAJIT_UNWIND_EXTERNAL
326 TARGET_XSHLDFLAGS
= -dynamiclib
-single_module
-undefined dynamic_lookup
-fPIC
328 TARGET_XSHLDFLAGS
+= -install_name
$(TARGET_DYLIBPATH
) -compatibility_version
$(MAJVER
).
$(MINVER
) -current_version
$(MAJVER
).
$(MINVER
).255
330 ifeq (iOS
,$(TARGET_SYS
))
332 TARGET_XSHLDFLAGS
= -dynamiclib
-single_module
-undefined dynamic_lookup
-fPIC
334 TARGET_XSHLDFLAGS
+= -install_name
$(TARGET_DYLIBPATH
) -compatibility_version
$(MAJVER
).
$(MINVER
) -current_version
$(MAJVER
).
$(MINVER
).255
335 ifeq (arm64
,$(TARGET_LJARCH
))
336 TARGET_XCFLAGS
+= -fno-omit-frame-pointer
339 ifeq (,$(findstring LJ_NO_UNWIND
1,$(TARGET_TESTARCH
)))
340 # Find out whether the target toolchain always generates unwind tables.
341 TARGET_TESTUNWIND
=$(shell exec
2>/dev
/null
; echo
'extern void b(void);int a(void){b();return 0;}' |
$(TARGET_CC
) -c
-x c
- -o tmpunwind.o
&& { grep
-qa
-e eh_frame
-e __unwind_info tmpunwind.o || grep
-qU
-e eh_frame
-e __unwind_info tmpunwind.o
; } && echo E
; rm -f tmpunwind.o
)
342 ifneq (,$(findstring E
,$(TARGET_TESTUNWIND
)))
343 TARGET_XCFLAGS
+= -DLUAJIT_UNWIND_EXTERNAL
346 ifneq (SunOS
,$(TARGET_SYS
))
347 ifneq (PS3
,$(TARGET_SYS
))
348 TARGET_XLDFLAGS
+= -Wl
,-E
351 ifeq (Linux
,$(TARGET_SYS
))
354 ifeq (GNU
/kFreeBSD
,$(TARGET_SYS
))
361 ifneq ($(HOST_SYS
),$(TARGET_SYS
))
362 ifeq (Windows
,$(TARGET_SYS
))
363 HOST_XCFLAGS
+= -malign-double
-DLUAJIT_OS
=LUAJIT_OS_WINDOWS
365 ifeq (Linux
,$(TARGET_SYS
))
366 HOST_XCFLAGS
+= -DLUAJIT_OS
=LUAJIT_OS_LINUX
368 ifeq (Darwin
,$(TARGET_SYS
))
369 HOST_XCFLAGS
+= -DLUAJIT_OS
=LUAJIT_OS_OSX
371 ifeq (iOS
,$(TARGET_SYS
))
372 HOST_XCFLAGS
+= -DLUAJIT_OS
=LUAJIT_OS_OSX
-DTARGET_OS_IPHONE
=1
374 HOST_XCFLAGS
+= -DLUAJIT_OS
=LUAJIT_OS_OTHER
385 ##############################################################################
386 # Files and pathnames.
387 ##############################################################################
389 MINILUA_O
= host
/minilua.o
391 MINILUA_T
= host
/minilua
392 MINILUA_X
= $(MINILUA_T
)
396 HOST_LUA
= $(MINILUA_X
)
397 MINILUA_DEP
= $(MINILUA_T
)
401 DASM
= $(HOST_LUA
) $(DASM_DIR
)/dynasm.lua
404 DASM_ARCH
= $(TARGET_LJARCH
)
406 ifneq (,$(findstring LJ_LE
1,$(TARGET_TESTARCH
)))
407 DASM_AFLAGS
+= -D ENDIAN_LE
409 DASM_AFLAGS
+= -D ENDIAN_BE
411 ifneq (,$(findstring LJ_ARCH_BITS
64,$(TARGET_TESTARCH
)))
414 ifneq (,$(findstring LJ_HASJIT
1,$(TARGET_TESTARCH
)))
417 ifneq (,$(findstring LJ_HASFFI
1,$(TARGET_TESTARCH
)))
420 ifneq (,$(findstring LJ_DUALNUM
1,$(TARGET_TESTARCH
)))
421 DASM_AFLAGS
+= -D DUALNUM
423 ifneq (,$(findstring LJ_ARCH_HASFPU
1,$(TARGET_TESTARCH
)))
425 TARGET_ARCH
+= -DLJ_ARCH_HASFPU
=1
427 TARGET_ARCH
+= -DLJ_ARCH_HASFPU
=0
429 ifeq (,$(findstring LJ_ABI_SOFTFP
1,$(TARGET_TESTARCH
)))
430 DASM_AFLAGS
+= -D HFABI
431 TARGET_ARCH
+= -DLJ_ABI_SOFTFP
=0
433 TARGET_ARCH
+= -DLJ_ABI_SOFTFP
=1
435 ifneq (,$(findstring LJ_NO_UNWIND
1,$(TARGET_TESTARCH
)))
436 DASM_AFLAGS
+= -D NO_UNWIND
437 TARGET_ARCH
+= -DLUAJIT_NO_UNWIND
439 ifneq (,$(findstring LJ_ABI_PAUTH
1,$(TARGET_TESTARCH
)))
440 DASM_AFLAGS
+= -D PAUTH
441 TARGET_ARCH
+= -DLJ_ABI_PAUTH
=1
443 DASM_AFLAGS
+= -D VER
=$(subst LJ_ARCH_VERSION_
,,$(filter LJ_ARCH_VERSION_
%,$(subst LJ_ARCH_VERSION
,LJ_ARCH_VERSION_
,$(TARGET_TESTARCH
))))
444 ifeq (Windows
,$(TARGET_SYS
))
447 ifeq (x64
,$(TARGET_LJARCH
))
448 ifeq (,$(findstring LJ_FR2
1,$(TARGET_TESTARCH
)))
452 ifeq (arm
,$(TARGET_LJARCH
))
453 ifeq (iOS
,$(TARGET_SYS
))
457 ifneq (,$(findstring LJ_TARGET_MIPSR6
,$(TARGET_TESTARCH
)))
458 DASM_AFLAGS
+= -D MIPSR6
460 ifeq (ppc
,$(TARGET_LJARCH
))
461 ifneq (,$(findstring LJ_ARCH_SQRT
1,$(TARGET_TESTARCH
)))
462 DASM_AFLAGS
+= -D SQRT
464 ifneq (,$(findstring LJ_ARCH_ROUND
1,$(TARGET_TESTARCH
)))
465 DASM_AFLAGS
+= -D ROUND
467 ifneq (,$(findstring LJ_ARCH_PPC32ON64
1,$(TARGET_TESTARCH
)))
468 DASM_AFLAGS
+= -D GPR64
470 ifeq (PS3
,$(TARGET_SYS
))
471 DASM_AFLAGS
+= -D PPE
-D TOC
477 DASM_FLAGS
= $(DASM_XFLAGS
) $(DASM_AFLAGS
)
478 DASM_DASC
= vm_
$(DASM_ARCH
).dasc
481 ifeq (Windows
,$(HOST_SYS
)$(HOST_MSYS
))
482 GIT_RELVER
= if exist ..\.git
( $(GIT
) show
-s
--format
=%%ct
>luajit_relver.txt
) else ( type ..\.relver
>luajit_relver.txt
)
484 GIT_RELVER
= [ -e ..
/.git
] && $(GIT
) show
-s
--format
=%ct
>luajit_relver.txt
2>/dev
/null || cat ..
/.relver
>luajit_relver.txt
2>/dev
/null ||
:
486 GIT_DEP
= $(wildcard ..
/.git
/HEAD ..
/.git
/refs
/heads
/*)
488 BUILDVM_O
= host
/buildvm.o host
/buildvm_asm.o host
/buildvm_peobj.o \
489 host
/buildvm_lib.o host
/buildvm_fold.o
490 BUILDVM_T
= host
/buildvm
491 BUILDVM_X
= $(BUILDVM_T
)
493 HOST_O
= $(MINILUA_O
) $(BUILDVM_O
)
494 HOST_T
= $(MINILUA_T
) $(BUILDVM_T
)
501 LJLIB_O
= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
502 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o \
504 LJLIB_C
= $(LJLIB_O
:.o
=.c
)
506 LJCORE_O
= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
507 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
508 lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \
509 lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_serialize.o \
510 lj_api.o lj_profile.o \
511 lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
512 lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
513 lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
514 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
515 lj_asm.o lj_trace.o lj_gdbjit.o \
516 lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
517 lj_carith.o lj_clib.o lj_cparse.o \
518 lj_lib.o lj_alloc.o lib_aux.o \
519 $(LJLIB_O
) lib_init.o
521 LJVMCORE_O
= $(LJVM_O
) $(LJCORE_O
)
522 LJVMCORE_DYNO
= $(LJVMCORE_O
:.o
=_dyn.o
)
524 LIB_VMDEF
= jit
/vmdef.lua
525 LIB_VMDEFP
= $(LIB_VMDEF
)
528 LUAJIT_A
= libluajit.a
529 LUAJIT_SO
= libluajit.so
532 ALL_T
= $(LUAJIT_T
) $(LUAJIT_A
) $(LUAJIT_SO
) $(HOST_T
)
533 ALL_HDRGEN
= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
534 host
/buildvm_arch.h luajit.h
535 ALL_GEN
= $(LJVM_S
) $(ALL_HDRGEN
) luajit_relver.txt
$(LIB_VMDEFP
)
536 WIN_RM
= *.obj
*.lib
*.exp
*.dll
*.exe
*.manifest
*.pdb
*.ilk
537 ALL_RM
= $(ALL_T
) $(ALL_GEN
) *.o host
/*.o
$(WIN_RM
)
539 ##############################################################################
540 # Build mode handling.
541 ##############################################################################
543 # Mixed mode defaults.
544 TARGET_O
= $(LUAJIT_A
)
545 TARGET_T
= $(LUAJIT_T
) $(LUAJIT_SO
)
546 TARGET_DEP
= $(LIB_VMDEF
) $(LUAJIT_SO
)
548 ifeq (Windows
,$(TARGET_SYS
))
549 TARGET_DYNCC
= $(STATIC_CC
)
553 ifeq (cygwin
,$(HOST_MSYS
))
554 LUAJIT_SO
= cyg
$(TARGET_DLLNAME
)
556 LUAJIT_SO
= $(TARGET_DLLNAME
)
558 # Mixed mode is not supported on Windows. And static mode doesn't work well.
559 # C modules cannot be loaded, because they bind to lua51.dll.
560 ifneq (static
,$(BUILDMODE
))
562 TARGET_XCFLAGS
+= -DLUA_BUILD_AS_DLL
565 ifeq (Darwin
,$(TARGET_SYS
))
568 ifeq (iOS
,$(TARGET_SYS
))
571 ifeq (SunOS
,$(TARGET_SYS
))
574 ifeq (PS3
,$(TARGET_SYS
))
578 ifeq (Windows
,$(HOST_SYS
))
579 MINILUA_T
= host
/minilua.exe
580 BUILDVM_T
= host
/buildvm.exe
582 MINILUA_X
= host\minilua
583 BUILDVM_X
= host
\buildvm
584 ALL_RM
:= $(subst /,\
,$(ALL_RM
))
589 ifeq (static
,$(BUILDMODE
))
591 TARGET_T
= $(LUAJIT_T
)
592 TARGET_DEP
= $(LIB_VMDEF
)
594 ifeq (dynamic
,$(BUILDMODE
))
595 ifneq (Windows
,$(TARGET_SYS
))
596 TARGET_CC
= $(DYNAMIC_CC
)
599 LJVMCORE_DYNO
= $(LJVMCORE_O
)
600 TARGET_O
= $(LUAJIT_SO
)
601 TARGET_XLDFLAGS
+= $(TARGET_DYNXLDOPTS
)
603 ifeq (Darwin
,$(TARGET_SYS
))
605 LJVMCORE_DYNO
= $(LJVMCORE_O
)
607 ifeq (iOS
,$(TARGET_SYS
))
609 LJVMCORE_DYNO
= $(LJVMCORE_O
)
619 ##############################################################################
621 ##############################################################################
623 default
all: $(TARGET_T
)
626 $(MAKE
) all "LJCORE_O=ljamalg.o"
632 .
/$(LUAJIT_T
) host
/genlibbc.lua
-o host
/buildvm_libbc.h
$(LJLIB_C
)
636 @for file in
$(ALL_HDRGEN
); do \
637 test -f
$$file || touch
$$file; \
639 @
$(HOST_CC
) $(HOST_ACFLAGS
) -MM
*.c host
/*.c | \
640 sed
-e
"s| [^ ]*/dasm_\S*\.h||g" \
641 -e
"s|^\([^l ]\)|host/\1|" \
642 -e
"s| lj_target_\S*\.h| lj_target_*.h|g" \
643 -e
"s| lj_emit_\S*\.h| lj_emit_*.h|g" \
644 -e
"s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
645 @for file in
$(ALL_HDRGEN
); do \
646 test -s
$$file ||
$(HOST_RM
) $$file; \
649 .PHONY
: default
all amalg
clean libbc depend
651 ##############################################################################
652 # Rules for generated files.
653 ##############################################################################
655 $(MINILUA_T
): $(MINILUA_O
)
657 $(Q
)$(HOST_CC
) $(HOST_ALDFLAGS
) -o
$@
$(MINILUA_O
) $(MINILUA_LIBS
) $(HOST_ALIBS
)
659 luajit.h
: $(MINILUA_DEP
) $(GIT_DEP
) luajit_rolling.h
662 $(Q
)$(HOST_LUA
) host
/genversion.lua
664 host
/buildvm_arch.h
: $(DASM_DASC
) $(MINILUA_DEP
) lj_arch.h lua.h luaconf.h
666 $(Q
)$(DASM
) $(DASM_FLAGS
) -o
$@
$(DASM_DASC
)
668 host
/buildvm.o
: $(DASM_DIR
)/dasm_
*.h
670 $(BUILDVM_T
): $(BUILDVM_O
)
672 $(Q
)$(HOST_CC
) $(HOST_ALDFLAGS
) -o
$@
$(BUILDVM_O
) $(HOST_ALIBS
)
674 $(LJVM_BOUT
): $(BUILDVM_T
)
676 $(Q
)$(BUILDVM_X
) -m
$(LJVM_MODE
) -o
$@
678 lj_bcdef.h
: $(BUILDVM_T
) $(LJLIB_C
)
680 $(Q
)$(BUILDVM_X
) -m bcdef
-o
$@
$(LJLIB_C
)
682 lj_ffdef.h
: $(BUILDVM_T
) $(LJLIB_C
)
684 $(Q
)$(BUILDVM_X
) -m ffdef
-o
$@
$(LJLIB_C
)
686 lj_libdef.h
: $(BUILDVM_T
) $(LJLIB_C
)
688 $(Q
)$(BUILDVM_X
) -m libdef
-o
$@
$(LJLIB_C
)
690 lj_recdef.h
: $(BUILDVM_T
) $(LJLIB_C
)
692 $(Q
)$(BUILDVM_X
) -m recdef
-o
$@
$(LJLIB_C
)
694 $(LIB_VMDEF
): $(BUILDVM_T
) $(LJLIB_C
)
696 $(Q
)$(BUILDVM_X
) -m vmdef
-o
$(LIB_VMDEFP
) $(LJLIB_C
)
698 lj_folddef.h
: $(BUILDVM_T
) lj_opt_fold.c
700 $(Q
)$(BUILDVM_X
) -m folddef
-o
$@ lj_opt_fold.c
702 ##############################################################################
704 ##############################################################################
708 $(Q
)$(TARGET_DYNCC
) $(TARGET_ACFLAGS
) -c
-o
$(@
:.o
=_dyn.o
) $<
709 $(Q
)$(TARGET_CC
) $(TARGET_ACFLAGS
) -c
-o
$@
$<
713 $(Q
)$(TARGET_DYNCC
) $(TARGET_ASFLAGS
) -c
-o
$(@
:.o
=_dyn.o
) $<
714 $(Q
)$(TARGET_CC
) $(TARGET_ASFLAGS
) -c
-o
$@
$<
718 $(Q
)$(TARGET_STCC
) $(TARGET_ACFLAGS
) -c
-o
$@
$<
722 $(Q
)$(HOST_CC
) $(HOST_ACFLAGS
) -c
-o
$@
$<
726 ##############################################################################
728 ##############################################################################
730 $(LUAJIT_A
): $(LJVMCORE_O
)
732 $(Q
)$(TARGET_AR
) $@
$(LJVMCORE_O
)
734 # The dependency on _O, but linking with _DYNO is intentional.
735 $(LUAJIT_SO
): $(LJVMCORE_O
)
737 $(Q
)$(TARGET_LD
) $(TARGET_ASHLDFLAGS
) -o
$@
$(LJVMCORE_DYNO
) $(TARGET_ALIBS
)
738 $(Q
)$(TARGET_STRIP
) $@
740 $(LUAJIT_T
): $(TARGET_O
) $(LUAJIT_O
) $(TARGET_DEP
)
742 $(Q
)$(TARGET_LD
) $(TARGET_ALDFLAGS
) -o
$@
$(LUAJIT_O
) $(TARGET_O
) $(TARGET_ALIBS
)
743 $(Q
)$(TARGET_STRIP
) $@
744 $(E
) "OK Successfully built LuaJIT"
746 ##############################################################################