aboutsummaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile87
1 files changed, 57 insertions, 30 deletions
diff --git a/src/Makefile b/src/Makefile
index f7f81a4e..f56465d1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,8 +11,8 @@
11############################################################################## 11##############################################################################
12 12
13MAJVER= 2 13MAJVER= 2
14MINVER= 0 14MINVER= 1
15RELVER= 5 15RELVER= 0
16ABIVER= 5.1 16ABIVER= 5.1
17NODOTABIVER= 51 17NODOTABIVER= 51
18 18
@@ -44,17 +44,14 @@ CCOPT= -O2 -fomit-frame-pointer
44# 44#
45# Target-specific compiler options: 45# Target-specific compiler options:
46# 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 47# 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 48# the binaries to a different machine you could also use: -march=native
52# 49#
53CCOPT_x86= -march=i686 50CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse
54CCOPT_x64= 51CCOPT_x64=
55CCOPT_arm= 52CCOPT_arm=
53CCOPT_arm64=
56CCOPT_ppc= 54CCOPT_ppc=
57CCOPT_ppcspe=
58CCOPT_mips= 55CCOPT_mips=
59# 56#
60CCDEBUG= 57CCDEBUG=
@@ -113,6 +110,9 @@ XCFLAGS=
113#XCFLAGS+= -DLUAJIT_NUMMODE=1 110#XCFLAGS+= -DLUAJIT_NUMMODE=1
114#XCFLAGS+= -DLUAJIT_NUMMODE=2 111#XCFLAGS+= -DLUAJIT_NUMMODE=2
115# 112#
113# Enable GC64 mode for x64.
114#XCFLAGS+= -DLUAJIT_ENABLE_GC64
115#
116############################################################################## 116##############################################################################
117 117
118############################################################################## 118##############################################################################
@@ -124,8 +124,8 @@ XCFLAGS=
124# 124#
125# Use the system provided memory allocator (realloc) instead of the 125# Use the system provided memory allocator (realloc) instead of the
126# bundled memory allocator. This is slower, but sometimes helpful for 126# bundled memory allocator. This is slower, but sometimes helpful for
127# debugging. This option cannot be enabled on x64, since realloc usually 127# debugging. This option cannot be enabled on x64 without GC64, since
128# doesn't return addresses in the right address range. 128# realloc usually doesn't return addresses in the right address range.
129# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and 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. 130# the only way to get useful results from it for all other architectures.
131#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC 131#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
@@ -186,7 +186,8 @@ endif
186# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows 186# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
187# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- 187# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
188 188
189CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) 189ASOPTIONS= $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
190CCOPTIONS= $(CCDEBUG) $(ASOPTIONS)
190LDOPTIONS= $(CCDEBUG) $(LDFLAGS) 191LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
191 192
192HOST_CC= $(CC) 193HOST_CC= $(CC)
@@ -225,6 +226,7 @@ TARGET_XLDFLAGS=
225TARGET_XLIBS= -lm 226TARGET_XLIBS= -lm
226TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) 227TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
227TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) 228TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
229TARGET_ASFLAGS= $(ASOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
228TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) 230TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
229TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) 231TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
230TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS) 232TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
@@ -239,17 +241,29 @@ else
239ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) 241ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
240 TARGET_LJARCH= arm 242 TARGET_LJARCH= arm
241else 243else
244ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
245 ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
246 TARGET_ARCH= -D__AARCH64EB__=1
247 endif
248 TARGET_LJARCH= arm64
249else
242ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) 250ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
251 ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
252 TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE
253 else
254 TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE
255 endif
243 TARGET_LJARCH= ppc 256 TARGET_LJARCH= ppc
244else 257else
245ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
246 TARGET_LJARCH= ppcspe
247else
248ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) 258ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
249 ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) 259 ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
250 TARGET_ARCH= -D__MIPSEL__=1 260 TARGET_ARCH= -D__MIPSEL__=1
251 endif 261 endif
252 TARGET_LJARCH= mips 262 ifneq (,$(findstring LJ_TARGET_MIPS64 ,$(TARGET_TESTARCH)))
263 TARGET_LJARCH= mips64
264 else
265 TARGET_LJARCH= mips
266 endif
253else 267else
254 $(error Unsupported target architecture) 268 $(error Unsupported target architecture)
255endif 269endif
@@ -263,6 +277,7 @@ ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
263 TARGET_SYS= PS3 277 TARGET_SYS= PS3
264 TARGET_ARCH+= -D__CELLOS_LV2__ 278 TARGET_ARCH+= -D__CELLOS_LV2__
265 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC 279 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
280 TARGET_XLIBS+= -lpthread
266endif 281endif
267 282
268TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) 283TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
@@ -314,6 +329,9 @@ ifeq (iOS,$(TARGET_SYS))
314 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC 329 TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
315 TARGET_DYNXLDOPTS= 330 TARGET_DYNXLDOPTS=
316 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) 331 TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
332 ifeq (arm64,$(TARGET_LJARCH))
333 TARGET_XCFLAGS+= -fno-omit-frame-pointer
334 endif
317else 335else
318 ifneq (SunOS,$(TARGET_SYS)) 336 ifneq (SunOS,$(TARGET_SYS))
319 ifneq (PS3,$(TARGET_SYS)) 337 ifneq (PS3,$(TARGET_SYS))
@@ -374,6 +392,11 @@ DASM_XFLAGS=
374DASM_AFLAGS= 392DASM_AFLAGS=
375DASM_ARCH= $(TARGET_LJARCH) 393DASM_ARCH= $(TARGET_LJARCH)
376 394
395ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
396 DASM_AFLAGS+= -D ENDIAN_LE
397else
398 DASM_AFLAGS+= -D ENDIAN_BE
399endif
377ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) 400ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
378 DASM_AFLAGS+= -D P64 401 DASM_AFLAGS+= -D P64
379endif 402endif
@@ -406,13 +429,10 @@ DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subs
406ifeq (Windows,$(TARGET_SYS)) 429ifeq (Windows,$(TARGET_SYS))
407 DASM_AFLAGS+= -D WIN 430 DASM_AFLAGS+= -D WIN
408endif 431endif
409ifeq (x86,$(TARGET_LJARCH))
410 ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH)))
411 DASM_AFLAGS+= -D SSE
412 endif
413else
414ifeq (x64,$(TARGET_LJARCH)) 432ifeq (x64,$(TARGET_LJARCH))
415 DASM_ARCH= x86 433 ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH)))
434 DASM_ARCH= x86
435 endif
416else 436else
417ifeq (arm,$(TARGET_LJARCH)) 437ifeq (arm,$(TARGET_LJARCH))
418 ifeq (iOS,$(TARGET_SYS)) 438 ifeq (iOS,$(TARGET_SYS))
@@ -426,13 +446,15 @@ ifeq (ppc,$(TARGET_LJARCH))
426 ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) 446 ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
427 DASM_AFLAGS+= -D ROUND 447 DASM_AFLAGS+= -D ROUND
428 endif 448 endif
429 ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH))) 449 ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH)))
430 DASM_AFLAGS+= -D GPR64 450 DASM_AFLAGS+= -D GPR64
431 endif 451 endif
432 ifeq (PS3,$(TARGET_SYS)) 452 ifeq (PS3,$(TARGET_SYS))
433 DASM_AFLAGS+= -D PPE -D TOC 453 DASM_AFLAGS+= -D PPE -D TOC
434 endif 454 endif
435endif 455 ifneq (,$(findstring LJ_ARCH_PPC64 ,$(TARGET_TESTARCH)))
456 DASM_ARCH= ppc64
457 endif
436endif 458endif
437endif 459endif
438endif 460endif
@@ -448,7 +470,7 @@ BUILDVM_X= $(BUILDVM_T)
448HOST_O= $(MINILUA_O) $(BUILDVM_O) 470HOST_O= $(MINILUA_O) $(BUILDVM_O)
449HOST_T= $(MINILUA_T) $(BUILDVM_T) 471HOST_T= $(MINILUA_T) $(BUILDVM_T)
450 472
451LJVM_S= lj_vm.s 473LJVM_S= lj_vm.S
452LJVM_O= lj_vm.o 474LJVM_O= lj_vm.o
453LJVM_BOUT= $(LJVM_S) 475LJVM_BOUT= $(LJVM_S)
454LJVM_MODE= elfasm 476LJVM_MODE= elfasm
@@ -457,10 +479,11 @@ LJLIB_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 479 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
458LJLIB_C= $(LJLIB_O:.o=.c) 480LJLIB_C= $(LJLIB_O:.o=.c)
459 481
460LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \ 482LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
461 lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ 483 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 \ 484 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 \ 485 lj_strfmt.o lj_strfmt_num.o lj_api.o lj_profile.o \
486 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 \ 487 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 \ 488 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 \ 489 lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
@@ -580,6 +603,10 @@ amalg:
580clean: 603clean:
581 $(HOST_RM) $(ALL_RM) 604 $(HOST_RM) $(ALL_RM)
582 605
606libbc:
607 ./$(LUAJIT_T) host/genlibbc.lua -o host/buildvm_libbc.h $(LJLIB_C)
608 $(MAKE) all
609
583depend: 610depend:
584 @for file in $(ALL_HDRGEN); do \ 611 @for file in $(ALL_HDRGEN); do \
585 test -f $$file || touch $$file; \ 612 test -f $$file || touch $$file; \
@@ -594,7 +621,7 @@ depend:
594 test -s $$file || $(HOST_RM) $$file; \ 621 test -s $$file || $(HOST_RM) $$file; \
595 done 622 done
596 623
597.PHONY: default all amalg clean depend 624.PHONY: default all amalg clean libbc depend
598 625
599############################################################################## 626##############################################################################
600# Rules for generated files. 627# Rules for generated files.
@@ -604,7 +631,7 @@ $(MINILUA_T): $(MINILUA_O)
604 $(E) "HOSTLINK $@" 631 $(E) "HOSTLINK $@"
605 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) 632 $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
606 633
607host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) 634host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(DASM_DIR)/*.lua
608 $(E) "DYNASM $@" 635 $(E) "DYNASM $@"
609 $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) 636 $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
610 637
@@ -651,10 +678,10 @@ lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
651 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< 678 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
652 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< 679 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
653 680
654%.o: %.s 681%.o: %.S
655 $(E) "ASM $@" 682 $(E) "ASM $@"
656 $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< 683 $(Q)$(TARGET_DYNCC) $(TARGET_ASFLAGS) -c -o $(@:.o=_dyn.o) $<
657 $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< 684 $(Q)$(TARGET_CC) $(TARGET_ASFLAGS) -c -o $@ $<
658 685
659$(LUAJIT_O): 686$(LUAJIT_O):
660 $(E) "CC $@" 687 $(E) "CC $@"