was reported this speeds up the savegame load on join significantly stolen from srb2netplus lel
408 lines
12 KiB
INI
408 lines
12 KiB
INI
##############################################################################
|
|
# LuaJIT Makefile. Requires GNU Make.
|
|
#
|
|
# Please read doc/install.html before changing any variables!
|
|
#
|
|
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
|
|
# Also works with MinGW and Cygwin on Windows.
|
|
# Please check msvcbuild.bat for building with MSVC on Windows.
|
|
#
|
|
# Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
|
|
##############################################################################
|
|
|
|
# this is a very dumbed down version of the LuaJIT makefile.
|
|
# to get the original makefile, visit
|
|
# https://github.com/GenericHeroGuy/bluajit
|
|
|
|
XCFLAGS=
|
|
XCFLAGS+= -DLUAJIT_DISABLE_FFI
|
|
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
|
|
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
|
|
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
|
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
|
|
#XCFLAGS+= -DLUAJIT_USE_GDBJIT
|
|
#XCFLAGS+= -DLUA_USE_APICHECK
|
|
#XCFLAGS+= -DLUA_USE_ASSERT
|
|
XCFLAGS+= -DLUAJIT_DISABLE_BYTECODE
|
|
|
|
# load standard libraries in debug mode, so jit.dump etc works
|
|
ifndef DEBUGMODE
|
|
XCFLAGS+= -DLUAJIT_SRB2LIB -DLUAJIT_DISABLE_BUFFER
|
|
endif
|
|
# additional functions
|
|
#XCFLAGS+= -DLUAJIT_SRB2LIB_OS
|
|
XCFLAGS+= -DLUAJIT_SRB2LIB_DEBUG
|
|
XCFLAGS+= -DLUAJIT_SRB2LIB_IO
|
|
|
|
# don't touch these unless you wanna have a bad time
|
|
XCFLAGS+= -DLUAJIT_NUMMODE=2
|
|
XCFLAGS+= -DLUAJIT_INTONLY
|
|
# needed for the headers
|
|
OPTS+=-DLUAJIT_INTONLY
|
|
|
|
ifdef MINGW
|
|
TARGET_SYS= Windows
|
|
HOST_MSYS= mingw
|
|
endif
|
|
|
|
ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
|
|
HOST_SYS= Windows
|
|
else
|
|
HOST_SYS:= $(shell uname -s)
|
|
ifneq (,$(findstring MINGW,$(HOST_SYS)))
|
|
HOST_SYS= Windows
|
|
HOST_MSYS= mingw
|
|
endif
|
|
ifneq (,$(findstring MSYS,$(HOST_SYS)))
|
|
HOST_SYS= Windows
|
|
HOST_MSYS= mingw
|
|
endif
|
|
ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
|
|
HOST_SYS= Windows
|
|
HOST_MSYS= cygwin
|
|
endif
|
|
endif
|
|
|
|
ASOPTIONS= $(CCOPT) $(XCFLAGS) $(CFLAGS)
|
|
CCOPTIONS= $(ASOPTIONS)
|
|
|
|
HOST_CC= $(CC)
|
|
HOST_RM?= rm -f
|
|
|
|
HOST_XCFLAGS= -Ibluajit
|
|
HOST_XLIBS=
|
|
HOST_ACFLAGS= $(XCFLAGS) $(HOST_XCFLAGS) $(TARGET_ARCH)
|
|
|
|
TARGET_CC= $(CROSS)$(CC)
|
|
|
|
TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
|
TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
|
|
TARGET_XLIBS= -lm
|
|
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS)
|
|
TARGET_ASFLAGS= $(ASOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS)
|
|
TARGET_ACFLAGS+= $(LUA_CFLAGS)
|
|
|
|
TARGET_TESTARCH:=$(shell $(TARGET_CC) $(TARGET_ACFLAGS) -E bluajit/lj_arch.h -dM)
|
|
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
|
|
TARGET_LJARCH= x64
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
|
|
TARGET_LJARCH= x86
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
|
|
TARGET_LJARCH= arm
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
|
|
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
|
|
TARGET_ARCH= -D__AARCH64EB__=1
|
|
endif
|
|
TARGET_LJARCH= arm64
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
|
|
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
|
|
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE
|
|
else
|
|
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE
|
|
endif
|
|
TARGET_LJARCH= ppc
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
|
|
ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
|
|
TARGET_ARCH= -D__MIPSEL__=1
|
|
endif
|
|
ifneq (,$(findstring LJ_TARGET_MIPS64 ,$(TARGET_TESTARCH)))
|
|
TARGET_LJARCH= mips64
|
|
else
|
|
TARGET_LJARCH= mips
|
|
endif
|
|
else
|
|
$(error Unsupported target architecture)
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
|
|
TARGET_SYS= PS3
|
|
TARGET_ARCH+= -D__CELLOS_LV2__
|
|
TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
|
TARGET_XLIBS+= -lpthread
|
|
endif
|
|
|
|
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
|
|
|
|
ifneq (,$(PREFIX))
|
|
ifneq (/usr/local,$(PREFIX))
|
|
TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
|
|
endif
|
|
endif
|
|
ifneq (,$(MULTILIB))
|
|
TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
|
|
endif
|
|
ifneq (,$(LMULTILIB))
|
|
TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
|
|
endif
|
|
ifneq (,$(INSTALL_LJLIBD))
|
|
TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\"
|
|
endif
|
|
|
|
##############################################################################
|
|
# Target system detection.
|
|
##############################################################################
|
|
|
|
TARGET_SYS?= $(HOST_SYS)
|
|
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
|
|
TARGET_XCFLAGS+= -fno-stack-protector
|
|
endif
|
|
ifeq (Darwin,$(TARGET_SYS))
|
|
ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
|
|
$(error missing: export MACOSX_DEPLOYMENT_TARGET=XX.YY)
|
|
endif
|
|
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
|
|
else
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
ifeq (arm64,$(TARGET_LJARCH))
|
|
TARGET_XCFLAGS+= -fno-omit-frame-pointer
|
|
endif
|
|
else
|
|
ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
|
|
# Find out whether the target toolchain always generates unwind tables.
|
|
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)
|
|
ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
|
|
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
|
|
endif
|
|
endif
|
|
ifeq (Linux,$(TARGET_SYS))
|
|
TARGET_XLIBS+= -ldl
|
|
endif
|
|
ifeq (GNU/kFreeBSD,$(TARGET_SYS))
|
|
TARGET_XLIBS+= -ldl
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
ifneq ($(HOST_SYS),$(TARGET_SYS))
|
|
ifeq (Windows,$(TARGET_SYS))
|
|
HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
|
|
else
|
|
ifeq (Linux,$(TARGET_SYS))
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
|
|
else
|
|
ifeq (Darwin,$(TARGET_SYS))
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
|
|
else
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1
|
|
else
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
##############################################################################
|
|
# Files and pathnames.
|
|
##############################################################################
|
|
|
|
MINILUA_O= $(OBJDIR)/minilua.o
|
|
MINILUA_LIBS= -lm
|
|
MINILUA_T= $(OBJDIR)/minilua
|
|
MINILUA_X= $(MINILUA_T)
|
|
MINILUA_DEP=
|
|
|
|
HOST_LUA= $(MINILUA_X)
|
|
MINILUA_DEP= $(MINILUA_T)
|
|
|
|
DASM_DIR= bluajit/dynasm
|
|
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
|
|
DASM_XFLAGS=
|
|
DASM_AFLAGS=
|
|
DASM_ARCH= $(TARGET_LJARCH)
|
|
|
|
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D ENDIAN_LE
|
|
else
|
|
DASM_AFLAGS+= -D ENDIAN_BE
|
|
endif
|
|
ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D P64
|
|
endif
|
|
ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D JIT
|
|
endif
|
|
ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D FFI
|
|
endif
|
|
ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D DUALNUM
|
|
endif
|
|
ifneq (,$(findstring LJ_INTONLY 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D INTONLY
|
|
endif
|
|
ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D FPU
|
|
TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
|
|
else
|
|
TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
|
|
endif
|
|
ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D HFABI
|
|
TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
|
|
else
|
|
TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
|
|
endif
|
|
ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D NO_UNWIND
|
|
TARGET_ARCH+= -DLUAJIT_NO_UNWIND
|
|
endif
|
|
ifneq (,$(findstring LJ_ABI_PAUTH 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D PAUTH
|
|
TARGET_ARCH+= -DLJ_ABI_PAUTH=1
|
|
endif
|
|
DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
|
|
ifeq (Windows,$(TARGET_SYS))
|
|
DASM_AFLAGS+= -D WIN
|
|
endif
|
|
ifeq (x64,$(TARGET_LJARCH))
|
|
ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH)))
|
|
DASM_ARCH= x86
|
|
endif
|
|
else
|
|
ifeq (arm,$(TARGET_LJARCH))
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
DASM_AFLAGS+= -D IOS
|
|
endif
|
|
else
|
|
ifneq (,$(findstring LJ_TARGET_MIPSR6 ,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D MIPSR6
|
|
endif
|
|
ifeq (ppc,$(TARGET_LJARCH))
|
|
ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D SQRT
|
|
endif
|
|
ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D ROUND
|
|
endif
|
|
ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH)))
|
|
DASM_AFLAGS+= -D GPR64
|
|
endif
|
|
ifeq (PS3,$(TARGET_SYS))
|
|
DASM_AFLAGS+= -D PPE -D TOC
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
|
|
DASM_DASC= bluajit/vm_$(DASM_ARCH).dasc
|
|
|
|
GIT= git
|
|
ifeq (Windows,$(HOST_SYS)$(HOST_MSYS))
|
|
GIT_RELVER= if exist ..\.git ( $(GIT) show -s --format=%%ct >bluajit/luajit_relver.txt ) else ( type ..\.relver >bluajit/luajit_relver.txt )
|
|
else
|
|
GIT_RELVER= [ -e ../.git ] && $(GIT) show -s --format=%ct >bluajit/luajit_relver.txt 2>/dev/null || cat ../.relver >bluajit/luajit_relver.txt 2>/dev/null || :
|
|
endif
|
|
GIT_DEP= $(wildcard ../.git/HEAD ../.git/refs/heads/*)
|
|
|
|
BUILDVM_O= $(OBJDIR)/buildvm.o $(OBJDIR)/buildvm_asm.o $(OBJDIR)/buildvm_peobj.o \
|
|
$(OBJDIR)/buildvm_lib.o $(OBJDIR)/buildvm_fold.o
|
|
BUILDVM_T= $(OBJDIR)/buildvm
|
|
BUILDVM_X= $(BUILDVM_T)
|
|
|
|
HOST_O= $(MINILUA_O) $(BUILDVM_O)
|
|
HOST_T= $(MINILUA_T) $(BUILDVM_T)
|
|
|
|
LJVM_S= $(OBJDIR)/lj_vm.S
|
|
LJVM_O= $(OBJDIR)/lj_vm.o
|
|
LJVM_BOUT= $(LJVM_S)
|
|
LJVM_MODE= elfasm
|
|
|
|
LJLIB_O= lib_base.o lib_string.o lib_table.o lib_io.o lib_jit.o
|
|
ifeq (,$(filter -DLUAJIT_SRB2LIB,$(XCFLAGS)))
|
|
LJLIB_O+= lib_math.o lib_bit.o lib_os.o lib_package.o lib_debug.o lib_ffi.o lib_buffer.o
|
|
else
|
|
ifneq (,$(filter -DLUAJIT_SRB2LIB_OS,$(XCFLAGS)))
|
|
LJLIB_O+= lib_os.o
|
|
endif
|
|
ifneq (,$(filter -DLUAJIT_SRB2LIB_DEBUG,$(XCFLAGS)))
|
|
LJLIB_O+= lib_debug.o
|
|
endif
|
|
endif
|
|
LJLIB_C= $(addprefix bluajit/,$(LJLIB_O:.o=.c))
|
|
|
|
LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
|
|
lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
|
|
lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \
|
|
lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_serialize.o \
|
|
lj_api.o lj_profile.o \
|
|
lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
|
|
lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
|
|
lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
|
|
lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
|
|
lj_asm.o lj_trace.o lj_gdbjit.o \
|
|
lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
|
|
lj_carith.o lj_clib.o lj_cparse.o \
|
|
lj_lib.o lj_alloc.o lib_aux.o \
|
|
$(LJLIB_O) lib_init.o
|
|
|
|
LJCORE_O:= $(addprefix $(OBJDIR)/,$(LJCORE_O))
|
|
LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
|
|
|
|
LIB_VMDEF= bluajit/jit/vmdef.lua
|
|
LIB_VMDEFP= $(LIB_VMDEF)
|
|
|
|
ALL_T= $(HOST_T)
|
|
ALL_HDRGEN:= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
|
|
host/buildvm_arch.h luajit.h
|
|
ALL_HDRGEN:= $(addprefix bluajit/,$(ALL_HDRGEN))
|
|
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) bluajit/luajit_relver.txt $(LIB_VMDEFP)
|
|
|
|
##############################################################################
|
|
# Build mode handling.
|
|
##############################################################################
|
|
|
|
ifeq (Windows,$(TARGET_SYS))
|
|
LJVM_MODE= peobj
|
|
LJVM_BOUT= $(LJVM_O)
|
|
endif
|
|
ifeq (Darwin,$(TARGET_SYS))
|
|
LJVM_MODE= machasm
|
|
endif
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
LJVM_MODE= machasm
|
|
endif
|
|
|
|
ifeq (Windows,$(TARGET_SYS))
|
|
MINILUA_T= $(OBJDIR)/minilua.exe
|
|
BUILDVM_T= $(OBJDIR)/buildvm.exe
|
|
ifeq (,$(HOST_MSYS))
|
|
MINILUA_X= $(OBJDIR)\minilua
|
|
BUILDVM_X= $(OBJDIR)\buildvm
|
|
HOST_RM= del
|
|
endif
|
|
endif
|
|
|
|
|
|
OBJS:=$(OBJS) \
|
|
$(LJVMCORE_O) \
|
|
$(OBJDIR)/lua_script.o \
|
|
$(OBJDIR)/lua_baselib.o \
|
|
$(OBJDIR)/lua_blockmaplib.o \
|
|
$(OBJDIR)/lua_mathlib.o \
|
|
$(OBJDIR)/lua_hooklib.o \
|
|
$(OBJDIR)/lua_consolelib.o \
|
|
$(OBJDIR)/lua_infolib.o \
|
|
$(OBJDIR)/lua_mobjlib.o \
|
|
$(OBJDIR)/lua_playerlib.o \
|
|
$(OBJDIR)/lua_skinlib.o \
|
|
$(OBJDIR)/lua_thinkerlib.o \
|
|
$(OBJDIR)/lua_maplib.o \
|
|
$(OBJDIR)/hashtable.o \
|
|
$(OBJDIR)/lua_hudlib.o \
|
|
$(OBJDIR)/lua_hudlib_drawlist.o \
|
|
$(OBJDIR)/lua_udatalib.o \
|
|
$(OBJDIR)/lua_glib.o
|