Mercurial
comparison third_party/luajit/src/Makefile @ 178:94705b5986b3
[ThirdParty] Added WRK and luajit for load testing.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Thu, 22 Jan 2026 20:10:30 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 177:24fe8ff94056 | 178:94705b5986b3 |
|---|---|
| 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-2023 Mike Pall. See Copyright Notice in luajit.h | |
| 11 ############################################################################## | |
| 12 | |
| 13 MAJVER= 2 | |
| 14 MINVER= 1 | |
| 15 ABIVER= 5.1 | |
| 16 NODOTABIVER= 51 | |
| 17 | |
| 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. | |
| 25 # | |
| 26 DEFAULT_CC = gcc | |
| 27 # | |
| 28 # LuaJIT builds as a native 32 or 64 bit binary by default. | |
| 29 CC= $(DEFAULT_CC) | |
| 30 # | |
| 31 # Use this if you want to force a 32 bit build on a 64 bit multilib OS. | |
| 32 #CC= $(DEFAULT_CC) -m32 | |
| 33 # | |
| 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. | |
| 43 # | |
| 44 # Target-specific compiler options: | |
| 45 # | |
| 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 | |
| 48 # | |
| 49 CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse | |
| 50 CCOPT_x64= | |
| 51 CCOPT_arm= | |
| 52 CCOPT_arm64= | |
| 53 CCOPT_ppc= | |
| 54 CCOPT_mips= | |
| 55 # | |
| 56 CCDEBUG= | |
| 57 # Uncomment the next line to generate debug information: | |
| 58 #CCDEBUG= -g | |
| 59 # | |
| 60 CCWARN= -Wall | |
| 61 # Uncomment the next line to enable more warnings: | |
| 62 #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith | |
| 63 # | |
| 64 ############################################################################## | |
| 65 | |
| 66 ############################################################################## | |
| 67 ################################ BUILD MODE ################################ | |
| 68 ############################################################################## | |
| 69 # The default build mode is mixed mode on POSIX. On Windows this is the same | |
| 70 # as dynamic mode. | |
| 71 # | |
| 72 # Mixed mode creates a static + dynamic library and a statically linked luajit. | |
| 73 BUILDMODE= mixed | |
| 74 # | |
| 75 # Static mode creates a static library and a statically linked luajit. | |
| 76 #BUILDMODE= static | |
| 77 # | |
| 78 # Dynamic mode creates a dynamic library and a dynamically linked luajit. | |
| 79 # Note: this executable will only run when the library is installed! | |
| 80 #BUILDMODE= dynamic | |
| 81 # | |
| 82 ############################################################################## | |
| 83 | |
| 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". | |
| 89 XCFLAGS= | |
| 90 # | |
| 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 | |
| 94 # make use of it. | |
| 95 #XCFLAGS+= -DLUAJIT_DISABLE_FFI | |
| 96 # | |
| 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 | |
| 102 # | |
| 103 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. | |
| 104 #XCFLAGS+= -DLUAJIT_DISABLE_JIT | |
| 105 # | |
| 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 | |
| 111 # | |
| 112 # Disable LJ_GC64 mode for x64. | |
| 113 #XCFLAGS+= -DLUAJIT_DISABLE_GC64 | |
| 114 # | |
| 115 ############################################################################## | |
| 116 | |
| 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! | |
| 123 # | |
| 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 | |
| 131 # | |
| 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 | |
| 135 # | |
| 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 | |
| 140 # | |
| 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 | |
| 144 # | |
| 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 | |
| 148 # | |
| 149 ############################################################################## | |
| 150 # You probably don't need to change anything below this line! | |
| 151 ############################################################################## | |
| 152 | |
| 153 ############################################################################## | |
| 154 # Host system detection. | |
| 155 ############################################################################## | |
| 156 | |
| 157 ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) | |
| 158 HOST_SYS= Windows | |
| 159 else | |
| 160 HOST_SYS:= $(shell uname -s) | |
| 161 ifneq (,$(findstring MINGW,$(HOST_SYS))) | |
| 162 HOST_SYS= Windows | |
| 163 HOST_MSYS= mingw | |
| 164 endif | |
| 165 ifneq (,$(findstring MSYS,$(HOST_SYS))) | |
| 166 HOST_SYS= Windows | |
| 167 HOST_MSYS= mingw | |
| 168 endif | |
| 169 ifneq (,$(findstring CYGWIN,$(HOST_SYS))) | |
| 170 HOST_SYS= Windows | |
| 171 HOST_MSYS= cygwin | |
| 172 endif | |
| 173 endif | |
| 174 | |
| 175 ############################################################################## | |
| 176 # Flags and options for host and target. | |
| 177 ############################################################################## | |
| 178 | |
| 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 | |
| 185 # | |
| 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- | |
| 189 | |
| 190 ASOPTIONS= $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) | |
| 191 CCOPTIONS= $(CCDEBUG) $(ASOPTIONS) | |
| 192 LDOPTIONS= $(CCDEBUG) $(LDFLAGS) | |
| 193 | |
| 194 HOST_CC= $(CC) | |
| 195 HOST_RM?= rm -f | |
| 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 | |
| 198 HOST_LUA= | |
| 199 | |
| 200 HOST_XCFLAGS= -I. | |
| 201 HOST_XLDFLAGS= | |
| 202 HOST_XLIBS= | |
| 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) | |
| 206 | |
| 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 | |
| 215 | |
| 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) | |
| 223 TARGET_DYNXLDOPTS= | |
| 224 | |
| 225 TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE | |
| 226 TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE | |
| 227 TARGET_XLDFLAGS= | |
| 228 TARGET_XLIBS= -lm | |
| 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) | |
| 235 | |
| 236 TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) | |
| 237 ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) | |
| 238 TARGET_LJARCH= x64 | |
| 239 else | |
| 240 ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) | |
| 241 TARGET_LJARCH= x86 | |
| 242 else | |
| 243 ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) | |
| 244 TARGET_LJARCH= arm | |
| 245 else | |
| 246 ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH))) | |
| 247 ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH))) | |
| 248 TARGET_ARCH= -D__AARCH64EB__=1 | |
| 249 endif | |
| 250 TARGET_LJARCH= arm64 | |
| 251 else | |
| 252 ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) | |
| 253 ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH))) | |
| 254 TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE | |
| 255 else | |
| 256 TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE | |
| 257 endif | |
| 258 TARGET_LJARCH= ppc | |
| 259 else | |
| 260 ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) | |
| 261 ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) | |
| 262 TARGET_ARCH= -D__MIPSEL__=1 | |
| 263 endif | |
| 264 ifneq (,$(findstring LJ_TARGET_MIPS64 ,$(TARGET_TESTARCH))) | |
| 265 TARGET_LJARCH= mips64 | |
| 266 else | |
| 267 TARGET_LJARCH= mips | |
| 268 endif | |
| 269 else | |
| 270 $(error Unsupported target architecture) | |
| 271 endif | |
| 272 endif | |
| 273 endif | |
| 274 endif | |
| 275 endif | |
| 276 endif | |
| 277 | |
| 278 ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH))) | |
| 279 TARGET_SYS= PS3 | |
| 280 TARGET_ARCH+= -D__CELLOS_LV2__ | |
| 281 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC | |
| 282 TARGET_XLIBS+= -lpthread | |
| 283 endif | |
| 284 | |
| 285 TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) | |
| 286 TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) | |
| 287 | |
| 288 ifneq (,$(PREFIX)) | |
| 289 ifneq (/usr/local,$(PREFIX)) | |
| 290 TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\" | |
| 291 ifneq (/usr,$(PREFIX)) | |
| 292 TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH) | |
| 293 endif | |
| 294 endif | |
| 295 endif | |
| 296 ifneq (,$(MULTILIB)) | |
| 297 TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\" | |
| 298 endif | |
| 299 ifneq (,$(LMULTILIB)) | |
| 300 TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\" | |
| 301 endif | |
| 302 | |
| 303 ############################################################################## | |
| 304 # Target system detection. | |
| 305 ############################################################################## | |
| 306 | |
| 307 TARGET_SYS?= $(HOST_SYS) | |
| 308 ifeq (Windows,$(TARGET_SYS)) | |
| 309 TARGET_STRIP+= --strip-unneeded | |
| 310 TARGET_XSHLDFLAGS= -shared -Wl,--out-implib,$(TARGET_DLLDOTANAME) | |
| 311 TARGET_DYNXLDOPTS= | |
| 312 else | |
| 313 TARGET_AR+= 2>/dev/null | |
| 314 ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1)) | |
| 315 TARGET_XCFLAGS+= -fno-stack-protector | |
| 316 endif | |
| 317 ifeq (Darwin,$(TARGET_SYS)) | |
| 318 ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) | |
| 319 $(error missing: export MACOSX_DEPLOYMENT_TARGET=XX.YY) | |
| 320 endif | |
| 321 TARGET_STRIP+= -x | |
| 322 TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL | |
| 323 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC | |
| 324 TARGET_DYNXLDOPTS= | |
| 325 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 | |
| 326 else | |
| 327 ifeq (iOS,$(TARGET_SYS)) | |
| 328 TARGET_STRIP+= -x | |
| 329 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC | |
| 330 TARGET_DYNXLDOPTS= | |
| 331 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 | |
| 332 ifeq (arm64,$(TARGET_LJARCH)) | |
| 333 TARGET_XCFLAGS+= -fno-omit-frame-pointer | |
| 334 endif | |
| 335 else | |
| 336 ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) | |
| 337 # Find out whether the target toolchain always generates unwind tables. | |
| 338 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) | |
| 339 ifneq (,$(findstring E,$(TARGET_TESTUNWIND))) | |
| 340 TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL | |
| 341 endif | |
| 342 endif | |
| 343 ifneq (SunOS,$(TARGET_SYS)) | |
| 344 ifneq (PS3,$(TARGET_SYS)) | |
| 345 TARGET_XLDFLAGS+= -Wl,-E | |
| 346 endif | |
| 347 endif | |
| 348 ifeq (Linux,$(TARGET_SYS)) | |
| 349 TARGET_XLIBS+= -ldl | |
| 350 endif | |
| 351 ifeq (GNU/kFreeBSD,$(TARGET_SYS)) | |
| 352 TARGET_XLIBS+= -ldl | |
| 353 endif | |
| 354 endif | |
| 355 endif | |
| 356 endif | |
| 357 | |
| 358 ifneq ($(HOST_SYS),$(TARGET_SYS)) | |
| 359 ifeq (Windows,$(TARGET_SYS)) | |
| 360 HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS | |
| 361 else | |
| 362 ifeq (Linux,$(TARGET_SYS)) | |
| 363 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX | |
| 364 else | |
| 365 ifeq (Darwin,$(TARGET_SYS)) | |
| 366 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX | |
| 367 else | |
| 368 ifeq (iOS,$(TARGET_SYS)) | |
| 369 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1 | |
| 370 else | |
| 371 HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER | |
| 372 endif | |
| 373 endif | |
| 374 endif | |
| 375 endif | |
| 376 endif | |
| 377 | |
| 378 ifneq (,$(CCDEBUG)) | |
| 379 TARGET_STRIP= @: | |
| 380 endif | |
| 381 | |
| 382 ############################################################################## | |
| 383 # Files and pathnames. | |
| 384 ############################################################################## | |
| 385 | |
| 386 MINILUA_O= host/minilua.o | |
| 387 MINILUA_LIBS= -lm | |
| 388 MINILUA_T= host/minilua | |
| 389 MINILUA_X= $(MINILUA_T) | |
| 390 MINILUA_DEP= | |
| 391 | |
| 392 ifeq (,$(HOST_LUA)) | |
| 393 HOST_LUA= $(MINILUA_X) | |
| 394 MINILUA_DEP= $(MINILUA_T) | |
| 395 endif | |
| 396 | |
| 397 DASM_DIR= ../dynasm | |
| 398 DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua | |
| 399 DASM_XFLAGS= | |
| 400 DASM_AFLAGS= | |
| 401 DASM_ARCH= $(TARGET_LJARCH) | |
| 402 | |
| 403 ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH))) | |
| 404 DASM_AFLAGS+= -D ENDIAN_LE | |
| 405 else | |
| 406 DASM_AFLAGS+= -D ENDIAN_BE | |
| 407 endif | |
| 408 ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) | |
| 409 DASM_AFLAGS+= -D P64 | |
| 410 endif | |
| 411 ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH))) | |
| 412 DASM_AFLAGS+= -D JIT | |
| 413 endif | |
| 414 ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH))) | |
| 415 DASM_AFLAGS+= -D FFI | |
| 416 endif | |
| 417 ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH))) | |
| 418 DASM_AFLAGS+= -D DUALNUM | |
| 419 endif | |
| 420 ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH))) | |
| 421 DASM_AFLAGS+= -D FPU | |
| 422 TARGET_ARCH+= -DLJ_ARCH_HASFPU=1 | |
| 423 else | |
| 424 TARGET_ARCH+= -DLJ_ARCH_HASFPU=0 | |
| 425 endif | |
| 426 ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH))) | |
| 427 DASM_AFLAGS+= -D HFABI | |
| 428 TARGET_ARCH+= -DLJ_ABI_SOFTFP=0 | |
| 429 else | |
| 430 TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 | |
| 431 endif | |
| 432 ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) | |
| 433 DASM_AFLAGS+= -D NO_UNWIND | |
| 434 TARGET_ARCH+= -DLUAJIT_NO_UNWIND | |
| 435 endif | |
| 436 ifneq (,$(findstring LJ_ABI_PAUTH 1,$(TARGET_TESTARCH))) | |
| 437 DASM_AFLAGS+= -D PAUTH | |
| 438 TARGET_ARCH+= -DLJ_ABI_PAUTH=1 | |
| 439 endif | |
| 440 DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) | |
| 441 ifeq (Windows,$(TARGET_SYS)) | |
| 442 DASM_AFLAGS+= -D WIN | |
| 443 endif | |
| 444 ifeq (x64,$(TARGET_LJARCH)) | |
| 445 ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH))) | |
| 446 DASM_ARCH= x86 | |
| 447 endif | |
| 448 else | |
| 449 ifeq (arm,$(TARGET_LJARCH)) | |
| 450 ifeq (iOS,$(TARGET_SYS)) | |
| 451 DASM_AFLAGS+= -D IOS | |
| 452 endif | |
| 453 else | |
| 454 ifneq (,$(findstring LJ_TARGET_MIPSR6 ,$(TARGET_TESTARCH))) | |
| 455 DASM_AFLAGS+= -D MIPSR6 | |
| 456 endif | |
| 457 ifeq (ppc,$(TARGET_LJARCH)) | |
| 458 ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH))) | |
| 459 DASM_AFLAGS+= -D SQRT | |
| 460 endif | |
| 461 ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) | |
| 462 DASM_AFLAGS+= -D ROUND | |
| 463 endif | |
| 464 ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH))) | |
| 465 DASM_AFLAGS+= -D GPR64 | |
| 466 endif | |
| 467 ifeq (PS3,$(TARGET_SYS)) | |
| 468 DASM_AFLAGS+= -D PPE -D TOC | |
| 469 endif | |
| 470 endif | |
| 471 endif | |
| 472 endif | |
| 473 | |
| 474 DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) | |
| 475 DASM_DASC= vm_$(DASM_ARCH).dasc | |
| 476 | |
| 477 GIT= git | |
| 478 GIT_RELVER= [ -d ../.git ] && $(GIT) show -s --format=%ct >luajit_relver.txt 2>/dev/null || cat ../.relver >luajit_relver.txt 2>/dev/null || : | |
| 479 GIT_DEP= $(wildcard ../.git/HEAD ../.git/refs/heads/*) | |
| 480 | |
| 481 BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ | |
| 482 host/buildvm_lib.o host/buildvm_fold.o | |
| 483 BUILDVM_T= host/buildvm | |
| 484 BUILDVM_X= $(BUILDVM_T) | |
| 485 | |
| 486 HOST_O= $(MINILUA_O) $(BUILDVM_O) | |
| 487 HOST_T= $(MINILUA_T) $(BUILDVM_T) | |
| 488 | |
| 489 LJVM_S= lj_vm.S | |
| 490 LJVM_O= lj_vm.o | |
| 491 LJVM_BOUT= $(LJVM_S) | |
| 492 LJVM_MODE= elfasm | |
| 493 | |
| 494 LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ | |
| 495 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o \ | |
| 496 lib_buffer.o | |
| 497 LJLIB_C= $(LJLIB_O:.o=.c) | |
| 498 | |
| 499 LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \ | |
| 500 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ | |
| 501 lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \ | |
| 502 lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_serialize.o \ | |
| 503 lj_api.o lj_profile.o \ | |
| 504 lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \ | |
| 505 lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \ | |
| 506 lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \ | |
| 507 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \ | |
| 508 lj_asm.o lj_trace.o lj_gdbjit.o \ | |
| 509 lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \ | |
| 510 lj_carith.o lj_clib.o lj_cparse.o \ | |
| 511 lj_lib.o lj_alloc.o lib_aux.o \ | |
| 512 $(LJLIB_O) lib_init.o | |
| 513 | |
| 514 LJVMCORE_O= $(LJVM_O) $(LJCORE_O) | |
| 515 LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) | |
| 516 | |
| 517 LIB_VMDEF= jit/vmdef.lua | |
| 518 LIB_VMDEFP= $(LIB_VMDEF) | |
| 519 | |
| 520 LUAJIT_O= luajit.o | |
| 521 LUAJIT_A= libluajit.a | |
| 522 LUAJIT_SO= libluajit.so | |
| 523 LUAJIT_T= luajit | |
| 524 | |
| 525 ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) | |
| 526 ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ | |
| 527 host/buildvm_arch.h luajit.h | |
| 528 ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) luajit_relver.txt $(LIB_VMDEFP) | |
| 529 WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk | |
| 530 ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) | |
| 531 | |
| 532 ############################################################################## | |
| 533 # Build mode handling. | |
| 534 ############################################################################## | |
| 535 | |
| 536 # Mixed mode defaults. | |
| 537 TARGET_O= $(LUAJIT_A) | |
| 538 TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) | |
| 539 TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) | |
| 540 | |
| 541 ifeq (Windows,$(TARGET_SYS)) | |
| 542 TARGET_DYNCC= $(STATIC_CC) | |
| 543 LJVM_MODE= peobj | |
| 544 LJVM_BOUT= $(LJVM_O) | |
| 545 LUAJIT_T= luajit.exe | |
| 546 ifeq (cygwin,$(HOST_MSYS)) | |
| 547 LUAJIT_SO= cyg$(TARGET_DLLNAME) | |
| 548 else | |
| 549 LUAJIT_SO= $(TARGET_DLLNAME) | |
| 550 endif | |
| 551 # Mixed mode is not supported on Windows. And static mode doesn't work well. | |
| 552 # C modules cannot be loaded, because they bind to lua51.dll. | |
| 553 ifneq (static,$(BUILDMODE)) | |
| 554 BUILDMODE= dynamic | |
| 555 TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL | |
| 556 endif | |
| 557 endif | |
| 558 ifeq (Darwin,$(TARGET_SYS)) | |
| 559 LJVM_MODE= machasm | |
| 560 endif | |
| 561 ifeq (iOS,$(TARGET_SYS)) | |
| 562 LJVM_MODE= machasm | |
| 563 endif | |
| 564 ifeq (SunOS,$(TARGET_SYS)) | |
| 565 BUILDMODE= static | |
| 566 endif | |
| 567 ifeq (PS3,$(TARGET_SYS)) | |
| 568 BUILDMODE= static | |
| 569 endif | |
| 570 | |
| 571 ifeq (Windows,$(HOST_SYS)) | |
| 572 MINILUA_T= host/minilua.exe | |
| 573 BUILDVM_T= host/buildvm.exe | |
| 574 ifeq (,$(HOST_MSYS)) | |
| 575 MINILUA_X= host\minilua | |
| 576 BUILDVM_X= host\buildvm | |
| 577 ALL_RM:= $(subst /,\,$(ALL_RM)) | |
| 578 HOST_RM= del | |
| 579 endif | |
| 580 endif | |
| 581 | |
| 582 ifeq (static,$(BUILDMODE)) | |
| 583 TARGET_DYNCC= @: | |
| 584 TARGET_T= $(LUAJIT_T) | |
| 585 TARGET_DEP= $(LIB_VMDEF) | |
| 586 else | |
| 587 ifeq (dynamic,$(BUILDMODE)) | |
| 588 ifneq (Windows,$(TARGET_SYS)) | |
| 589 TARGET_CC= $(DYNAMIC_CC) | |
| 590 endif | |
| 591 TARGET_DYNCC= @: | |
| 592 LJVMCORE_DYNO= $(LJVMCORE_O) | |
| 593 TARGET_O= $(LUAJIT_SO) | |
| 594 TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS) | |
| 595 else | |
| 596 ifeq (Darwin,$(TARGET_SYS)) | |
| 597 TARGET_DYNCC= @: | |
| 598 LJVMCORE_DYNO= $(LJVMCORE_O) | |
| 599 endif | |
| 600 ifeq (iOS,$(TARGET_SYS)) | |
| 601 TARGET_DYNCC= @: | |
| 602 LJVMCORE_DYNO= $(LJVMCORE_O) | |
| 603 endif | |
| 604 endif | |
| 605 endif | |
| 606 | |
| 607 Q= @ | |
| 608 E= @echo | |
| 609 #Q= | |
| 610 #E= @: | |
| 611 | |
| 612 ############################################################################## | |
| 613 # Make targets. | |
| 614 ############################################################################## | |
| 615 | |
| 616 default all: $(TARGET_T) | |
| 617 | |
| 618 amalg: | |
| 619 $(MAKE) all "LJCORE_O=ljamalg.o" | |
| 620 | |
| 621 clean: | |
| 622 $(HOST_RM) $(ALL_RM) | |
| 623 | |
| 624 libbc: | |
| 625 ./$(LUAJIT_T) host/genlibbc.lua -o host/buildvm_libbc.h $(LJLIB_C) | |
| 626 $(MAKE) all | |
| 627 | |
| 628 depend: | |
| 629 @for file in $(ALL_HDRGEN); do \ | |
| 630 test -f $$file || touch $$file; \ | |
| 631 done | |
| 632 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \ | |
| 633 sed -e "s| [^ ]*/dasm_\S*\.h||g" \ | |
| 634 -e "s|^\([^l ]\)|host/\1|" \ | |
| 635 -e "s| lj_target_\S*\.h| lj_target_*.h|g" \ | |
| 636 -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ | |
| 637 -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep | |
| 638 @for file in $(ALL_HDRGEN); do \ | |
| 639 test -s $$file || $(HOST_RM) $$file; \ | |
| 640 done | |
| 641 | |
| 642 .PHONY: default all amalg clean libbc depend | |
| 643 | |
| 644 ############################################################################## | |
| 645 # Rules for generated files. | |
| 646 ############################################################################## | |
| 647 | |
| 648 $(MINILUA_T): $(MINILUA_O) | |
| 649 $(E) "HOSTLINK $@" | |
| 650 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) | |
| 651 | |
| 652 luajit.h: $(MINILUA_DEP) $(GIT_DEP) luajit_rolling.h | |
| 653 $(E) "VERSION $@" | |
| 654 $(Q)$(GIT_RELVER) | |
| 655 $(Q)$(HOST_LUA) host/genversion.lua | |
| 656 | |
| 657 host/buildvm_arch.h: $(DASM_DASC) $(MINILUA_DEP) lj_arch.h lua.h luaconf.h | |
| 658 $(E) "DYNASM $@" | |
| 659 $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) | |
| 660 | |
| 661 host/buildvm.o: $(DASM_DIR)/dasm_*.h | |
| 662 | |
| 663 $(BUILDVM_T): $(BUILDVM_O) | |
| 664 $(E) "HOSTLINK $@" | |
| 665 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS) | |
| 666 | |
| 667 $(LJVM_BOUT): $(BUILDVM_T) | |
| 668 $(E) "BUILDVM $@" | |
| 669 $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ | |
| 670 | |
| 671 lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) | |
| 672 $(E) "BUILDVM $@" | |
| 673 $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) | |
| 674 | |
| 675 lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) | |
| 676 $(E) "BUILDVM $@" | |
| 677 $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) | |
| 678 | |
| 679 lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) | |
| 680 $(E) "BUILDVM $@" | |
| 681 $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) | |
| 682 | |
| 683 lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) | |
| 684 $(E) "BUILDVM $@" | |
| 685 $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) | |
| 686 | |
| 687 $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C) | |
| 688 $(E) "BUILDVM $@" | |
| 689 $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) | |
| 690 | |
| 691 lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c | |
| 692 $(E) "BUILDVM $@" | |
| 693 $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c | |
| 694 | |
| 695 ############################################################################## | |
| 696 # Object file rules. | |
| 697 ############################################################################## | |
| 698 | |
| 699 %.o: %.c | |
| 700 $(E) "CC $@" | |
| 701 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< | |
| 702 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< | |
| 703 | |
| 704 %.o: %.S | |
| 705 $(E) "ASM $@" | |
| 706 $(Q)$(TARGET_DYNCC) $(TARGET_ASFLAGS) -c -o $(@:.o=_dyn.o) $< | |
| 707 $(Q)$(TARGET_CC) $(TARGET_ASFLAGS) -c -o $@ $< | |
| 708 | |
| 709 $(LUAJIT_O): | |
| 710 $(E) "CC $@" | |
| 711 $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $< | |
| 712 | |
| 713 $(HOST_O): %.o: %.c | |
| 714 $(E) "HOSTCC $@" | |
| 715 $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< | |
| 716 | |
| 717 include Makefile.dep | |
| 718 | |
| 719 ############################################################################## | |
| 720 # Target file rules. | |
| 721 ############################################################################## | |
| 722 | |
| 723 $(LUAJIT_A): $(LJVMCORE_O) | |
| 724 $(E) "AR $@" | |
| 725 $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) | |
| 726 | |
| 727 # The dependency on _O, but linking with _DYNO is intentional. | |
| 728 $(LUAJIT_SO): $(LJVMCORE_O) | |
| 729 $(E) "DYNLINK $@" | |
| 730 $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS) | |
| 731 $(Q)$(TARGET_STRIP) $@ | |
| 732 | |
| 733 $(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP) | |
| 734 $(E) "LINK $@" | |
| 735 $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS) | |
| 736 $(Q)$(TARGET_STRIP) $@ | |
| 737 $(E) "OK Successfully built LuaJIT" | |
| 738 | |
| 739 ############################################################################## |