2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
|
|
|
# LuaJIT Makefile. Requires GNU Make.
|
|
|
|
#
|
2010-10-04 23:36:54 +00:00
|
|
|
# Please read doc/install.html before changing any variables!
|
|
|
|
#
|
2009-12-08 18:46:35 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2021-01-02 20:49:41 +00:00
|
|
|
# Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h
|
2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
MAJVER= 2
|
2013-06-03 19:21:45 +00:00
|
|
|
MINVER= 1
|
2009-12-08 18:49:20 +00:00
|
|
|
RELVER= 0
|
|
|
|
ABIVER= 5.1
|
|
|
|
NODOTABIVER= 51
|
|
|
|
|
2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
2010-11-30 15:19:20 +00:00
|
|
|
############################# COMPILER OPTIONS #############################
|
|
|
|
##############################################################################
|
|
|
|
# These options mainly affect the speed of the JIT compiler itself, not the
|
|
|
|
# speed of the JIT-compiled code. Turn any of the optional settings on by
|
|
|
|
# removing the '#' in front of them. Make sure you force a full recompile
|
|
|
|
# with "make clean", followed by "make" if you change any options.
|
2009-12-08 18:46:35 +00:00
|
|
|
#
|
2015-10-24 17:10:40 +00:00
|
|
|
DEFAULT_CC = gcc
|
|
|
|
#
|
2010-03-04 15:23:28 +00:00
|
|
|
# LuaJIT builds as a native 32 or 64 bit binary by default.
|
2015-10-24 17:10:40 +00:00
|
|
|
CC= $(DEFAULT_CC)
|
2009-12-08 18:46:35 +00:00
|
|
|
#
|
2010-03-04 15:23:28 +00:00
|
|
|
# Use this if you want to force a 32 bit build on a 64 bit multilib OS.
|
2015-10-24 17:10:40 +00:00
|
|
|
#CC= $(DEFAULT_CC) -m32
|
2010-02-28 20:45:38 +00:00
|
|
|
#
|
2009-12-08 18:46:35 +00:00
|
|
|
# Since the assembler part does NOT maintain a frame pointer, it's pointless
|
2010-02-28 20:45:38 +00:00
|
|
|
# to slow down the C part by not omitting it. Debugging, tracebacks and
|
|
|
|
# unwinding are not affected -- the assembler part has frame unwind
|
|
|
|
# information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
|
2009-12-08 18:46:35 +00:00
|
|
|
CCOPT= -O2 -fomit-frame-pointer
|
|
|
|
# Use this if you want to generate a smaller binary (but it's slower):
|
|
|
|
#CCOPT= -Os -fomit-frame-pointer
|
|
|
|
# Note: it's no longer recommended to use -O3 with GCC 4.x.
|
|
|
|
# The I-Cache bloat usually outweighs the benefits from aggressive inlining.
|
|
|
|
#
|
2010-11-30 15:19:20 +00:00
|
|
|
# Target-specific compiler options:
|
|
|
|
#
|
|
|
|
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
|
|
|
|
# the binaries to a different machine you could also use: -march=native
|
|
|
|
#
|
2013-02-21 15:56:59 +00:00
|
|
|
CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse
|
2012-06-09 13:04:03 +00:00
|
|
|
CCOPT_x64=
|
|
|
|
CCOPT_arm=
|
2015-01-03 14:28:33 +00:00
|
|
|
CCOPT_arm64=
|
2012-06-09 13:04:03 +00:00
|
|
|
CCOPT_ppc=
|
|
|
|
CCOPT_mips=
|
2010-03-04 15:23:28 +00:00
|
|
|
#
|
2009-12-08 18:46:35 +00:00
|
|
|
CCDEBUG=
|
|
|
|
# Uncomment the next line to generate debug information:
|
|
|
|
#CCDEBUG= -g
|
|
|
|
#
|
|
|
|
CCWARN= -Wall
|
|
|
|
# Uncomment the next line to enable more warnings:
|
|
|
|
#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
2010-11-30 15:19:20 +00:00
|
|
|
################################ BUILD MODE ################################
|
|
|
|
##############################################################################
|
|
|
|
# The default build mode is mixed mode on POSIX. On Windows this is the same
|
|
|
|
# as dynamic mode.
|
|
|
|
#
|
|
|
|
# Mixed mode creates a static + dynamic library and a statically linked luajit.
|
|
|
|
BUILDMODE= mixed
|
|
|
|
#
|
|
|
|
# Static mode creates a static library and a statically linked luajit.
|
|
|
|
#BUILDMODE= static
|
|
|
|
#
|
|
|
|
# Dynamic mode creates a dynamic library and a dynamically linked luajit.
|
|
|
|
# Note: this executable will only run when the library is installed!
|
|
|
|
#BUILDMODE= dynamic
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
################################# FEATURES #################################
|
|
|
|
##############################################################################
|
|
|
|
# Enable/disable these features as needed, but make sure you force a full
|
|
|
|
# recompile with "make clean", followed by "make".
|
2009-12-08 18:46:35 +00:00
|
|
|
XCFLAGS=
|
|
|
|
#
|
2010-11-30 20:56:57 +00:00
|
|
|
# Permanently disable the FFI extension to reduce the size of the LuaJIT
|
|
|
|
# executable. But please consider that the FFI library is compiled-in,
|
|
|
|
# but NOT loaded by default. It only allocates any memory, if you actually
|
|
|
|
# make use of it.
|
|
|
|
#XCFLAGS+= -DLUAJIT_DISABLE_FFI
|
|
|
|
#
|
2012-10-04 11:55:34 +00:00
|
|
|
# Features from Lua 5.2 that are unlikely to break existing code are
|
|
|
|
# enabled by default. Some other features that *might* break some existing
|
|
|
|
# code (e.g. __pairs or os.execute() return values) can be enabled here.
|
|
|
|
# Note: this does not provide full compatibility with Lua 5.2 at this time.
|
2010-11-19 16:00:11 +00:00
|
|
|
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
|
|
|
|
#
|
2010-11-30 15:19:20 +00:00
|
|
|
# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
|
|
|
|
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
|
2009-12-08 18:46:35 +00:00
|
|
|
#
|
2011-10-24 14:35:17 +00:00
|
|
|
# Some architectures (e.g. PPC) can use either single-number (1) or
|
|
|
|
# dual-number (2) mode. Uncomment one of these lines to override the
|
|
|
|
# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
|
|
|
|
#XCFLAGS+= -DLUAJIT_NUMMODE=1
|
|
|
|
#XCFLAGS+= -DLUAJIT_NUMMODE=2
|
|
|
|
#
|
2019-12-08 20:21:30 +00:00
|
|
|
# Disable LJ_GC64 mode for x64.
|
|
|
|
#XCFLAGS+= -DLUAJIT_DISABLE_GC64
|
2017-01-17 11:21:12 +00:00
|
|
|
#
|
2010-11-30 15:19:20 +00:00
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
############################ DEBUGGING SUPPORT #############################
|
|
|
|
##############################################################################
|
|
|
|
# Enable these options as needed, but make sure you force a full recompile
|
|
|
|
# with "make clean", followed by "make".
|
|
|
|
# Note that most of these are NOT suitable for benchmarking or release mode!
|
2009-12-08 18:46:35 +00:00
|
|
|
#
|
|
|
|
# Use the system provided memory allocator (realloc) instead of the
|
|
|
|
# bundled memory allocator. This is slower, but sometimes helpful for
|
2016-06-03 04:42:35 +00:00
|
|
|
# debugging. This option cannot be enabled on x64 without GC64, since
|
|
|
|
# realloc usually doesn't return addresses in the right address range.
|
2014-04-21 20:26:46 +00:00
|
|
|
# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
|
|
|
|
# the only way to get useful results from it for all other architectures.
|
2009-12-08 18:46:35 +00:00
|
|
|
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
|
|
|
#
|
|
|
|
# This define is required to run LuaJIT under Valgrind. The Valgrind
|
|
|
|
# header files must be installed. You should enable debug information, too.
|
|
|
|
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
|
|
|
|
#
|
|
|
|
# This is the client for the GDB JIT API. GDB 7.0 or higher is required
|
|
|
|
# to make use of it. See lj_gdbjit.c for details. Enabling this causes
|
|
|
|
# a non-negligible overhead, even when not running under GDB.
|
|
|
|
#XCFLAGS+= -DLUAJIT_USE_GDBJIT
|
|
|
|
#
|
|
|
|
# Turn on assertions for the Lua/C API to debug problems with lua_* calls.
|
|
|
|
# This is rather slow -- use only while developing C libraries/embeddings.
|
|
|
|
#XCFLAGS+= -DLUA_USE_APICHECK
|
|
|
|
#
|
|
|
|
# Turn on assertions for the whole LuaJIT VM. This significantly slows down
|
|
|
|
# everything. Use only if you suspect a problem with LuaJIT itself.
|
2011-06-23 17:40:21 +00:00
|
|
|
#XCFLAGS+= -DLUA_USE_ASSERT
|
2009-12-08 18:46:35 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
2010-11-30 15:19:20 +00:00
|
|
|
# You probably don't need to change anything below this line!
|
2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2015-10-24 17:10:40 +00:00
|
|
|
##############################################################################
|
|
|
|
# Host system detection.
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
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
|
2019-01-10 11:02:15 +00:00
|
|
|
ifneq (,$(findstring MSYS,$(HOST_SYS)))
|
|
|
|
HOST_SYS= Windows
|
|
|
|
HOST_MSYS= mingw
|
|
|
|
endif
|
2015-10-24 17:10:40 +00:00
|
|
|
ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
|
|
|
|
HOST_SYS= Windows
|
|
|
|
HOST_MSYS= cygwin
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Flags and options for host and target.
|
|
|
|
##############################################################################
|
|
|
|
|
2010-11-30 15:19:20 +00:00
|
|
|
# You can override the following variables at the make command line:
|
2009-12-08 21:27:14 +00:00
|
|
|
# CC HOST_CC STATIC_CC DYNAMIC_CC
|
|
|
|
# CFLAGS HOST_CFLAGS TARGET_CFLAGS
|
|
|
|
# LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
|
|
|
|
# LIBS HOST_LIBS TARGET_LIBS
|
2011-04-17 10:48:01 +00:00
|
|
|
# CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
|
2009-12-08 21:27:14 +00:00
|
|
|
#
|
2010-08-27 16:32:24 +00:00
|
|
|
# Cross-compilation examples:
|
|
|
|
# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
|
2011-12-15 18:16:06 +00:00
|
|
|
# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
|
2009-12-08 21:27:14 +00:00
|
|
|
|
2014-12-16 01:32:53 +00:00
|
|
|
ASOPTIONS= $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
|
|
|
|
CCOPTIONS= $(CCDEBUG) $(ASOPTIONS)
|
2009-12-08 18:46:35 +00:00
|
|
|
LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
|
|
|
|
|
|
|
|
HOST_CC= $(CC)
|
2019-01-10 11:37:09 +00:00
|
|
|
HOST_RM?= rm -f
|
2012-06-09 13:04:03 +00:00
|
|
|
# If left blank, minilua is built and used. You can supply an installed
|
2012-07-08 14:25:38 +00:00
|
|
|
# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
|
2012-06-09 13:04:03 +00:00
|
|
|
HOST_LUA=
|
2009-12-08 18:49:20 +00:00
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
HOST_XCFLAGS= -I.
|
2009-12-08 18:46:35 +00:00
|
|
|
HOST_XLDFLAGS=
|
|
|
|
HOST_XLIBS=
|
2009-12-08 21:27:14 +00:00
|
|
|
HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
|
|
|
|
HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
|
|
|
|
HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)
|
2009-12-08 18:49:20 +00:00
|
|
|
|
|
|
|
STATIC_CC = $(CROSS)$(CC)
|
|
|
|
DYNAMIC_CC = $(CROSS)$(CC) -fPIC
|
|
|
|
TARGET_CC= $(STATIC_CC)
|
|
|
|
TARGET_STCC= $(STATIC_CC)
|
|
|
|
TARGET_DYNCC= $(DYNAMIC_CC)
|
|
|
|
TARGET_LD= $(CROSS)$(CC)
|
2020-06-15 09:23:04 +00:00
|
|
|
TARGET_AR= $(CROSS)ar rcus 2>/dev/null
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_STRIP= $(CROSS)strip
|
|
|
|
|
2013-07-09 15:25:05 +00:00
|
|
|
TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
|
2012-06-11 16:49:40 +00:00
|
|
|
TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
|
2013-07-09 15:25:05 +00:00
|
|
|
TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_DLLNAME= lua$(NODOTABIVER).dll
|
2019-12-08 18:19:12 +00:00
|
|
|
TARGET_DLLDOTANAME= libluajit-$(ABIVER).dll.a
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
|
|
|
|
TARGET_DYNXLDOPTS=
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2012-06-04 22:12:43 +00:00
|
|
|
TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
|
|
|
TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
|
2009-12-08 21:27:14 +00:00
|
|
|
TARGET_XLDFLAGS=
|
|
|
|
TARGET_XLIBS= -lm
|
2011-12-15 18:16:06 +00:00
|
|
|
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
|
2012-06-09 23:38:44 +00:00
|
|
|
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
|
2014-12-16 01:32:53 +00:00
|
|
|
TARGET_ASFLAGS= $(ASOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
|
2011-04-17 10:48:01 +00:00
|
|
|
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
|
|
|
|
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
|
2009-12-08 21:27:14 +00:00
|
|
|
TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
|
|
|
|
|
2011-12-15 18:16:06 +00:00
|
|
|
TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
|
2010-08-27 16:17:29 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
|
2012-06-09 13:04:03 +00:00
|
|
|
TARGET_LJARCH= x64
|
2010-08-27 16:17:29 +00:00
|
|
|
else
|
|
|
|
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
|
2012-06-09 13:04:03 +00:00
|
|
|
TARGET_LJARCH= x86
|
2010-03-04 15:23:28 +00:00
|
|
|
else
|
2011-01-25 17:50:24 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
|
2012-06-09 13:04:03 +00:00
|
|
|
TARGET_LJARCH= arm
|
2011-01-25 17:50:24 +00:00
|
|
|
else
|
2015-01-03 14:28:33 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
|
2017-03-30 09:17:15 +00:00
|
|
|
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
|
|
|
|
TARGET_ARCH= -D__AARCH64EB__=1
|
|
|
|
endif
|
2015-01-03 14:28:33 +00:00
|
|
|
TARGET_LJARCH= arm64
|
|
|
|
else
|
2011-07-03 13:15:11 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
|
2015-04-11 23:23:01 +00:00
|
|
|
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
|
|
|
|
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE
|
|
|
|
else
|
|
|
|
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE
|
|
|
|
endif
|
2012-06-09 13:04:03 +00:00
|
|
|
TARGET_LJARCH= ppc
|
2011-07-03 13:15:11 +00:00
|
|
|
else
|
2011-12-15 19:39:30 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
|
|
|
|
ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
|
|
|
|
TARGET_ARCH= -D__MIPSEL__=1
|
|
|
|
endif
|
2016-05-28 03:10:55 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_MIPS64 ,$(TARGET_TESTARCH)))
|
|
|
|
TARGET_LJARCH= mips64
|
|
|
|
else
|
|
|
|
TARGET_LJARCH= mips
|
|
|
|
endif
|
2010-08-27 16:17:29 +00:00
|
|
|
else
|
|
|
|
$(error Unsupported target architecture)
|
|
|
|
endif
|
2010-03-04 15:23:28 +00:00
|
|
|
endif
|
2011-01-25 17:50:24 +00:00
|
|
|
endif
|
2011-07-03 13:15:11 +00:00
|
|
|
endif
|
2011-12-15 19:39:30 +00:00
|
|
|
endif
|
2015-01-03 14:28:33 +00:00
|
|
|
endif
|
2010-03-04 15:23:28 +00:00
|
|
|
|
2012-06-10 14:41:00 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
|
2012-06-09 23:38:44 +00:00
|
|
|
TARGET_SYS= PS3
|
|
|
|
TARGET_ARCH+= -D__CELLOS_LV2__
|
|
|
|
TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
2013-09-09 23:02:09 +00:00
|
|
|
TARGET_XLIBS+= -lpthread
|
2012-06-09 23:38:44 +00:00
|
|
|
endif
|
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
|
|
|
|
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
|
2011-12-15 18:16:06 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
ifneq (,$(PREFIX))
|
|
|
|
ifneq (/usr/local,$(PREFIX))
|
2013-07-09 15:25:05 +00:00
|
|
|
TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
|
2009-12-08 18:49:20 +00:00
|
|
|
ifneq (/usr,$(PREFIX))
|
2013-07-09 15:25:05 +00:00
|
|
|
TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH)
|
2009-12-08 18:49:20 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2013-07-09 15:25:05 +00:00
|
|
|
ifneq (,$(MULTILIB))
|
|
|
|
TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
|
|
|
|
endif
|
|
|
|
ifneq (,$(LMULTILIB))
|
|
|
|
TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
|
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
|
|
|
|
##############################################################################
|
2015-10-24 17:10:40 +00:00
|
|
|
# Target system detection.
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2012-06-09 23:38:44 +00:00
|
|
|
TARGET_SYS?= $(HOST_SYS)
|
2009-12-08 18:46:35 +00:00
|
|
|
ifeq (Windows,$(TARGET_SYS))
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_STRIP+= --strip-unneeded
|
2019-12-08 18:19:12 +00:00
|
|
|
TARGET_XSHLDFLAGS= -shared -Wl,--out-implib,$(TARGET_DLLDOTANAME)
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_DYNXLDOPTS=
|
2009-12-08 18:46:35 +00:00
|
|
|
else
|
2014-12-08 01:07:05 +00:00
|
|
|
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
|
2009-12-08 18:46:35 +00:00
|
|
|
ifeq (Darwin,$(TARGET_SYS))
|
2012-03-28 08:17:28 +00:00
|
|
|
ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
|
2019-12-08 18:22:00 +00:00
|
|
|
$(error missing: export MACOSX_DEPLOYMENT_TARGET=XX.YY)
|
2012-03-28 08:17:28 +00:00
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_STRIP+= -x
|
2021-03-25 18:16:56 +00:00
|
|
|
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
|
2011-07-03 15:58:26 +00:00
|
|
|
TARGET_DYNXLDOPTS=
|
|
|
|
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
|
2011-04-28 17:41:34 +00:00
|
|
|
else
|
|
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
|
|
TARGET_STRIP+= -x
|
|
|
|
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
|
2011-07-03 15:58:26 +00:00
|
|
|
TARGET_DYNXLDOPTS=
|
|
|
|
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
|
2015-01-07 19:59:37 +00:00
|
|
|
ifeq (arm64,$(TARGET_LJARCH))
|
|
|
|
TARGET_XCFLAGS+= -fno-omit-frame-pointer
|
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
else
|
2021-03-25 18:16:56 +00:00
|
|
|
ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
|
|
|
|
# Find out whether the target toolchain always generates unwind tables.
|
2021-03-26 17:31:42 +00:00
|
|
|
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 -qU -e eh_frame -e __unwind_info tmpunwind.o && echo E; rm -f tmpunwind.o)
|
2021-03-25 18:16:56 +00:00
|
|
|
ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
|
|
|
|
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
|
|
|
|
endif
|
|
|
|
endif
|
2011-06-14 14:44:20 +00:00
|
|
|
ifneq (SunOS,$(TARGET_SYS))
|
2012-06-09 23:38:44 +00:00
|
|
|
ifneq (PS3,$(TARGET_SYS))
|
|
|
|
TARGET_XLDFLAGS+= -Wl,-E
|
|
|
|
endif
|
2011-06-14 14:44:20 +00:00
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
ifeq (Linux,$(TARGET_SYS))
|
2011-06-23 17:40:21 +00:00
|
|
|
TARGET_XLIBS+= -ldl
|
2009-12-08 18:49:20 +00:00
|
|
|
endif
|
2009-12-20 17:41:55 +00:00
|
|
|
ifeq (GNU/kFreeBSD,$(TARGET_SYS))
|
|
|
|
TARGET_XLIBS+= -ldl
|
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
endif
|
|
|
|
endif
|
2011-04-28 17:41:34 +00:00
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2011-04-29 07:23:00 +00:00
|
|
|
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))
|
2020-06-23 09:28:46 +00:00
|
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1
|
2011-04-29 07:23:00 +00:00
|
|
|
else
|
|
|
|
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2009-12-08 18:46:35 +00:00
|
|
|
ifneq (,$(CCDEBUG))
|
|
|
|
TARGET_STRIP= @:
|
|
|
|
endif
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Files and pathnames.
|
|
|
|
##############################################################################
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
MINILUA_O= host/minilua.o
|
|
|
|
MINILUA_LIBS= -lm
|
|
|
|
MINILUA_T= host/minilua
|
|
|
|
MINILUA_X= $(MINILUA_T)
|
|
|
|
|
|
|
|
ifeq (,$(HOST_LUA))
|
|
|
|
HOST_LUA= $(MINILUA_X)
|
|
|
|
DASM_DEP= $(MINILUA_T)
|
|
|
|
endif
|
|
|
|
|
2009-12-08 18:46:35 +00:00
|
|
|
DASM_DIR= ../dynasm
|
2009-12-08 18:49:20 +00:00
|
|
|
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
|
2012-06-09 13:04:03 +00:00
|
|
|
DASM_XFLAGS=
|
|
|
|
DASM_AFLAGS=
|
|
|
|
DASM_ARCH= $(TARGET_LJARCH)
|
|
|
|
|
2016-01-29 06:03:36 +00:00
|
|
|
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D ENDIAN_LE
|
|
|
|
else
|
|
|
|
DASM_AFLAGS+= -D ENDIAN_BE
|
|
|
|
endif
|
2012-06-12 01:50:22 +00:00
|
|
|
ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D P64
|
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
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_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D FPU
|
2012-07-29 10:22:18 +00:00
|
|
|
TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
|
|
|
|
else
|
|
|
|
TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
|
2012-06-10 14:41:00 +00:00
|
|
|
endif
|
|
|
|
ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
|
2012-07-29 10:22:18 +00:00
|
|
|
DASM_AFLAGS+= -D HFABI
|
|
|
|
TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
|
|
|
|
else
|
|
|
|
TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
|
2012-06-10 14:41:00 +00:00
|
|
|
endif
|
2015-06-09 19:56:58 +00:00
|
|
|
ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D NO_UNWIND
|
|
|
|
TARGET_ARCH+= -DLUAJIT_NO_UNWIND
|
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
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
|
2012-06-09 13:04:03 +00:00
|
|
|
ifeq (x64,$(TARGET_LJARCH))
|
2015-01-03 14:28:33 +00:00
|
|
|
ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_ARCH= x86
|
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
else
|
2012-06-10 22:49:47 +00:00
|
|
|
ifeq (arm,$(TARGET_LJARCH))
|
|
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
|
|
DASM_AFLAGS+= -D IOS
|
|
|
|
endif
|
|
|
|
else
|
2020-01-20 21:15:45 +00:00
|
|
|
ifneq (,$(findstring LJ_TARGET_MIPSR6 ,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D MIPSR6
|
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
ifeq (ppc,$(TARGET_LJARCH))
|
|
|
|
ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D SQRT
|
2012-06-09 13:04:03 +00:00
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
|
|
|
|
DASM_AFLAGS+= -D ROUND
|
|
|
|
endif
|
2015-03-06 02:47:45 +00:00
|
|
|
ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH)))
|
2012-06-13 00:32:24 +00:00
|
|
|
DASM_AFLAGS+= -D GPR64
|
|
|
|
endif
|
2012-06-10 14:41:00 +00:00
|
|
|
ifeq (PS3,$(TARGET_SYS))
|
2012-06-13 00:32:24 +00:00
|
|
|
DASM_AFLAGS+= -D PPE -D TOC
|
2012-06-10 14:41:00 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2012-06-09 13:04:03 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
|
|
|
|
DASM_DASC= vm_$(DASM_ARCH).dasc
|
|
|
|
|
|
|
|
BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \
|
|
|
|
host/buildvm_lib.o host/buildvm_fold.o
|
|
|
|
BUILDVM_T= host/buildvm
|
|
|
|
BUILDVM_X= $(BUILDVM_T)
|
|
|
|
|
|
|
|
HOST_O= $(MINILUA_O) $(BUILDVM_O)
|
|
|
|
HOST_T= $(MINILUA_T) $(BUILDVM_T)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2014-12-08 00:58:05 +00:00
|
|
|
LJVM_S= lj_vm.S
|
2009-12-08 18:46:35 +00:00
|
|
|
LJVM_O= lj_vm.o
|
|
|
|
LJVM_BOUT= $(LJVM_S)
|
2009-12-08 20:28:49 +00:00
|
|
|
LJVM_MODE= elfasm
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
|
2021-03-25 01:21:31 +00:00
|
|
|
lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o \
|
|
|
|
lib_buffer.o
|
2009-12-08 18:46:35 +00:00
|
|
|
LJLIB_C= $(LJLIB_O:.o=.c)
|
|
|
|
|
2020-06-12 22:52:54 +00:00
|
|
|
LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
|
2011-06-07 19:37:24 +00:00
|
|
|
lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
|
2020-06-15 10:21:05 +00:00
|
|
|
lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \
|
2021-03-25 01:21:31 +00:00
|
|
|
lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_serialize.o \
|
|
|
|
lj_api.o lj_profile.o \
|
2013-05-12 20:37:02 +00:00
|
|
|
lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
|
2009-12-08 18:46:35 +00:00
|
|
|
lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
|
2012-07-02 21:47:12 +00:00
|
|
|
lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
|
2010-12-08 01:11:18 +00:00
|
|
|
lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
|
2010-12-05 16:12:34 +00:00
|
|
|
lj_asm.o lj_trace.o lj_gdbjit.o \
|
2011-11-14 13:15:57 +00:00
|
|
|
lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
|
|
|
|
lj_carith.o lj_clib.o lj_cparse.o \
|
2009-12-08 18:46:35 +00:00
|
|
|
lj_lib.o lj_alloc.o lib_aux.o \
|
|
|
|
$(LJLIB_O) lib_init.o
|
|
|
|
|
|
|
|
LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
|
2009-12-08 18:49:20 +00:00
|
|
|
LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)
|
|
|
|
|
2012-06-08 18:54:47 +00:00
|
|
|
LIB_VMDEF= jit/vmdef.lua
|
2009-12-08 18:49:20 +00:00
|
|
|
LIB_VMDEFP= $(LIB_VMDEF)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
LUAJIT_O= luajit.o
|
2009-12-08 18:49:20 +00:00
|
|
|
LUAJIT_A= libluajit.a
|
|
|
|
LUAJIT_SO= libluajit.so
|
2009-12-08 18:46:35 +00:00
|
|
|
LUAJIT_T= luajit
|
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
|
|
|
|
ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
|
|
|
|
host/buildvm_arch.h
|
2010-08-27 15:20:16 +00:00
|
|
|
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
|
2009-12-08 18:49:20 +00:00
|
|
|
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
|
2012-06-09 13:04:03 +00:00
|
|
|
ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Build mode handling.
|
|
|
|
##############################################################################
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
# Mixed mode defaults.
|
|
|
|
TARGET_O= $(LUAJIT_A)
|
|
|
|
TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
|
|
|
|
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
ifeq (Windows,$(TARGET_SYS))
|
2009-12-08 21:27:14 +00:00
|
|
|
TARGET_DYNCC= $(STATIC_CC)
|
2013-05-15 16:48:06 +00:00
|
|
|
LJVM_MODE= peobj
|
|
|
|
LJVM_BOUT= $(LJVM_O)
|
2009-12-08 18:46:35 +00:00
|
|
|
LUAJIT_T= luajit.exe
|
2012-06-22 09:36:58 +00:00
|
|
|
ifeq (cygwin,$(HOST_MSYS))
|
|
|
|
LUAJIT_SO= cyg$(TARGET_DLLNAME)
|
|
|
|
else
|
|
|
|
LUAJIT_SO= $(TARGET_DLLNAME)
|
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
# Mixed mode is not supported on Windows. And static mode doesn't work well.
|
|
|
|
# C modules cannot be loaded, because they bind to lua51.dll.
|
|
|
|
ifneq (static,$(BUILDMODE))
|
|
|
|
BUILDMODE= dynamic
|
|
|
|
TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
|
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
endif
|
2009-12-08 20:28:49 +00:00
|
|
|
ifeq (Darwin,$(TARGET_SYS))
|
|
|
|
LJVM_MODE= machasm
|
|
|
|
endif
|
2011-04-28 17:41:34 +00:00
|
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
|
|
LJVM_MODE= machasm
|
|
|
|
endif
|
2011-06-14 14:44:20 +00:00
|
|
|
ifeq (SunOS,$(TARGET_SYS))
|
|
|
|
BUILDMODE= static
|
|
|
|
endif
|
2012-06-09 23:38:44 +00:00
|
|
|
ifeq (PS3,$(TARGET_SYS))
|
|
|
|
BUILDMODE= static
|
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2012-06-22 09:36:58 +00:00
|
|
|
ifeq (Windows,$(HOST_SYS))
|
|
|
|
MINILUA_T= host/minilua.exe
|
|
|
|
BUILDVM_T= host/buildvm.exe
|
|
|
|
ifeq (,$(HOST_MSYS))
|
|
|
|
MINILUA_X= host\minilua
|
|
|
|
BUILDVM_X= host\buildvm
|
|
|
|
ALL_RM:= $(subst /,\,$(ALL_RM))
|
2020-04-28 14:52:28 +00:00
|
|
|
HOST_RM= del
|
2012-06-22 09:36:58 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
ifeq (static,$(BUILDMODE))
|
|
|
|
TARGET_DYNCC= @:
|
|
|
|
TARGET_T= $(LUAJIT_T)
|
|
|
|
TARGET_DEP= $(LIB_VMDEF)
|
|
|
|
else
|
|
|
|
ifeq (dynamic,$(BUILDMODE))
|
2009-12-08 21:27:14 +00:00
|
|
|
ifneq (Windows,$(TARGET_SYS))
|
|
|
|
TARGET_CC= $(DYNAMIC_CC)
|
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
TARGET_DYNCC= @:
|
|
|
|
LJVMCORE_DYNO= $(LJVMCORE_O)
|
|
|
|
TARGET_O= $(LUAJIT_SO)
|
2009-12-08 21:27:14 +00:00
|
|
|
TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
|
2009-12-08 18:49:20 +00:00
|
|
|
else
|
|
|
|
ifeq (Darwin,$(TARGET_SYS))
|
|
|
|
TARGET_DYNCC= @:
|
|
|
|
LJVMCORE_DYNO= $(LJVMCORE_O)
|
|
|
|
endif
|
2011-04-28 17:41:34 +00:00
|
|
|
ifeq (iOS,$(TARGET_SYS))
|
|
|
|
TARGET_DYNCC= @:
|
|
|
|
LJVMCORE_DYNO= $(LJVMCORE_O)
|
|
|
|
endif
|
2009-12-08 18:49:20 +00:00
|
|
|
endif
|
|
|
|
endif
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
Q= @
|
|
|
|
E= @echo
|
|
|
|
#Q=
|
|
|
|
#E= @:
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Make targets.
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
default all: $(TARGET_T)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
amalg:
|
|
|
|
$(MAKE) all "LJCORE_O=ljamalg.o"
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
clean:
|
|
|
|
$(HOST_RM) $(ALL_RM)
|
|
|
|
|
2013-02-22 00:40:41 +00:00
|
|
|
libbc:
|
2013-02-22 11:29:54 +00:00
|
|
|
./$(LUAJIT_T) host/genlibbc.lua -o host/buildvm_libbc.h $(LJLIB_C)
|
2013-02-22 00:40:41 +00:00
|
|
|
$(MAKE) all
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
depend:
|
2012-06-09 13:04:03 +00:00
|
|
|
@for file in $(ALL_HDRGEN); do \
|
2010-08-27 15:20:16 +00:00
|
|
|
test -f $$file || touch $$file; \
|
|
|
|
done
|
2012-06-09 13:04:03 +00:00
|
|
|
@$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \
|
2010-08-03 20:09:12 +00:00
|
|
|
sed -e "s| [^ ]*/dasm_\S*\.h||g" \
|
2012-06-09 13:04:03 +00:00
|
|
|
-e "s|^\([^l ]\)|host/\1|" \
|
2011-05-11 23:35:09 +00:00
|
|
|
-e "s| lj_target_\S*\.h| lj_target_*.h|g" \
|
|
|
|
-e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
|
|
|
|
-e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
|
2012-06-09 13:04:03 +00:00
|
|
|
@for file in $(ALL_HDRGEN); do \
|
2010-08-27 15:20:16 +00:00
|
|
|
test -s $$file || $(HOST_RM) $$file; \
|
|
|
|
done
|
2009-12-08 18:49:20 +00:00
|
|
|
|
2013-02-22 00:40:41 +00:00
|
|
|
.PHONY: default all amalg clean libbc depend
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Rules for generated files.
|
2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
$(MINILUA_T): $(MINILUA_O)
|
|
|
|
$(E) "HOSTLINK $@"
|
|
|
|
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
|
2010-08-27 15:20:16 +00:00
|
|
|
|
2020-08-05 12:17:41 +00:00
|
|
|
host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(DASM_DIR)/*.lua lj_arch.h lua.h luaconf.h
|
2011-12-15 19:39:30 +00:00
|
|
|
$(E) "DYNASM $@"
|
2012-06-09 13:04:03 +00:00
|
|
|
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
|
2011-12-15 19:39:30 +00:00
|
|
|
|
2012-06-09 13:04:03 +00:00
|
|
|
host/buildvm.o: $(DASM_DIR)/dasm_*.h
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
$(BUILDVM_T): $(BUILDVM_O)
|
|
|
|
$(E) "HOSTLINK $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
$(LJVM_BOUT): $(BUILDVM_T)
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2010-02-13 03:51:56 +00:00
|
|
|
lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
|
2010-02-05 19:15:01 +00:00
|
|
|
$(E) "BUILDVM $@"
|
2010-02-13 03:51:56 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
|
2010-02-05 19:15:01 +00:00
|
|
|
|
2009-12-08 18:46:35 +00:00
|
|
|
lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
|
|
|
|
$(E) "BUILDVM $@"
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
##############################################################################
|
2009-12-08 18:49:20 +00:00
|
|
|
# Object file rules.
|
|
|
|
##############################################################################
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(E) "CC $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
|
|
|
|
$(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2014-12-08 00:58:05 +00:00
|
|
|
%.o: %.S
|
2009-12-08 18:46:35 +00:00
|
|
|
$(E) "ASM $@"
|
2014-12-16 01:32:53 +00:00
|
|
|
$(Q)$(TARGET_DYNCC) $(TARGET_ASFLAGS) -c -o $(@:.o=_dyn.o) $<
|
|
|
|
$(Q)$(TARGET_CC) $(TARGET_ASFLAGS) -c -o $@ $<
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
$(LUAJIT_O):
|
|
|
|
$(E) "CC $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<
|
2009-12-08 18:49:20 +00:00
|
|
|
|
2009-12-08 18:46:35 +00:00
|
|
|
$(HOST_O): %.o: %.c
|
|
|
|
$(E) "HOSTCC $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
include Makefile.dep
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
##############################################################################
|
|
|
|
# Target file rules.
|
2009-12-08 18:46:35 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
$(LUAJIT_A): $(LJVMCORE_O)
|
|
|
|
$(E) "AR $@"
|
|
|
|
$(Q)$(TARGET_AR) $@ $(LJVMCORE_O)
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
# The dependency on _O, but linking with _DYNO is intentional.
|
|
|
|
$(LUAJIT_SO): $(LJVMCORE_O)
|
|
|
|
$(E) "DYNLINK $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(TARGET_STRIP) $@
|
2009-12-08 18:46:35 +00:00
|
|
|
|
2009-12-08 18:49:20 +00:00
|
|
|
$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
|
|
|
|
$(E) "LINK $@"
|
2009-12-08 21:27:14 +00:00
|
|
|
$(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
|
2009-12-08 18:49:20 +00:00
|
|
|
$(Q)$(TARGET_STRIP) $@
|
|
|
|
$(E) "OK Successfully built LuaJIT"
|
2009-12-08 18:46:35 +00:00
|
|
|
|
|
|
|
##############################################################################
|