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