Reorganize build process.

Drop pre-translated buildvm_*.h.
Rename buildvm_*.dasc to vm_*.dasc.
Move buildvm* to host directory.
Build minilua, unless HOST_LUA is set.
Use HOST_LUA to run DynASM.
Translate only vm_*.dasc for target architecture.
This commit is contained in:
Mike Pall 2012-06-09 15:04:03 +02:00
parent 0a6c8338d2
commit 9a9509c66a
24 changed files with 114 additions and 41376 deletions

View File

@ -155,9 +155,6 @@ clean:
cleaner: cleaner:
$(MAKE) -C src cleaner $(MAKE) -C src cleaner
distclean: .PHONY: all install amalg clean cleaner
$(MAKE) -C src distclean
.PHONY: all install amalg clean cleaner distclean
############################################################################## ##############################################################################

1
src/.gitignore vendored
View File

@ -1,5 +1,4 @@
luajit luajit
buildvm
lj_bcdef.h lj_bcdef.h
lj_ffdef.h lj_ffdef.h
lj_libdef.h lj_libdef.h

View File

@ -49,12 +49,12 @@ CCOPT= -O2 -fomit-frame-pointer
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute # 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 # the binaries to a different machine you could also use: -march=native
# #
CCOPT_X86= -march=i686 CCOPT_x86= -march=i686
CCOPT_X64= CCOPT_x64=
CCOPT_ARM= CCOPT_arm=
CCOPT_PPC= CCOPT_ppc=
CCOPT_PPCSPE= CCOPT_ppcspe=
CCOPT_MIPS= CCOPT_mips=
# #
CCDEBUG= CCDEBUG=
# Uncomment the next line to generate debug information: # Uncomment the next line to generate debug information:
@ -182,13 +182,11 @@ LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
HOST_CC= $(CC) HOST_CC= $(CC)
HOST_RM= rm -f HOST_RM= rm -f
# NOTE: The LuaJIT distribution comes with pre-generated buildvm_*.h files. # If left blank, minilua is built and used. You can supply an installed
# You DO NOT NEED an installed copy of (plain) Lua 5.1 to run DynASM unless # copy of (plain) Lua 5.1 or 5.2, e.g. with: HOST_LUA=lua
# you want to MODIFY the corresponding *.dasc file. You can also use LuaJIT HOST_LUA=
# itself (bootstrapped from a pre-generated file) to run DynASM of course.
HOST_LUA= lua
HOST_XCFLAGS= HOST_XCFLAGS= -I.
HOST_XLDFLAGS= HOST_XLDFLAGS=
HOST_XLIBS= HOST_XLIBS=
HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS) HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
@ -223,31 +221,25 @@ TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
TARGET_CCARCH= x64 TARGET_LJARCH= x64
TARGET_XCFLAGS+= $(CCOPT_X64)
else else
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
TARGET_CCARCH= x86 TARGET_LJARCH= x86
TARGET_XCFLAGS+= $(CCOPT_X86)
else else
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
TARGET_CCARCH= arm TARGET_LJARCH= arm
TARGET_XCFLAGS+= $(CCOPT_ARM)
else else
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
TARGET_CCARCH= ppc TARGET_LJARCH= ppc
TARGET_XCFLAGS+= $(CCOPT_PPC)
else else
ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
TARGET_CCARCH= ppcspe TARGET_LJARCH= ppcspe
TARGET_XCFLAGS+= $(CCOPT_PPCSPE)
else else
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
TARGET_ARCH= -D__MIPSEL__=1 TARGET_ARCH= -D__MIPSEL__=1
endif endif
TARGET_CCARCH= mips TARGET_LJARCH= mips
TARGET_XCFLAGS+= $(CCOPT_MIPS)
else else
$(error Unsupported target architecture) $(error Unsupported target architecture)
endif endif
@ -257,7 +249,8 @@ endif
endif endif
endif endif
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_CCARCH)) TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
ifneq (,$(PREFIX)) ifneq (,$(PREFIX))
ifneq (/usr/local,$(PREFIX)) ifneq (/usr/local,$(PREFIX))
@ -300,7 +293,7 @@ ifeq (Darwin,$(TARGET_SYS))
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
ifeq (x64,$(TARGET_CCARCH)) ifeq (x64,$(TARGET_LJARCH))
TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
endif endif
@ -357,24 +350,41 @@ endif
# Files and pathnames. # Files and pathnames.
############################################################################## ##############################################################################
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
DASM_DIR= ../dynasm DASM_DIR= ../dynasm
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
DASM_FLAGS= DASM_XFLAGS=
DASM_DISTFLAGS= -LN DASM_AFLAGS=
DASM_FLAGS_X86= DASM_ARCH= $(TARGET_LJARCH)
DASM_FLAGS_X64= -D X64
DASM_FLAGS_X64WIN= -D X64 -D X64WIN
DASM_FLAGS_ARM=
DASM_FLAGS_PPC=
DASM_FLAGS_PPCSPE=
DASM_FLAGS_MIPS=
BUILDVM_O= buildvm.o buildvm_asm.o buildvm_peobj.o buildvm_lib.o buildvm_fold.o ifeq (x64,$(TARGET_LJARCH))
BUILDVM_T= buildvm DASM_ARCH= x86
BUILDVM_X= ./$(BUILDVM_T) ifeq (Windows,$(TARGET_SYS))
DASM_AFLAGS+= -D X64 -D X64WIN
else
DASM_AFLAGS+= -D X64
endif
endif
HOST_O= $(BUILDVM_O) DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
HOST_T= $(BUILDVM_T) 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)
LJVM_S= lj_vm.s LJVM_S= lj_vm.s
LJVM_O= lj_vm.o LJVM_O= lj_vm.o
@ -409,13 +419,12 @@ LUAJIT_A= libluajit.a
LUAJIT_SO= libluajit.so LUAJIT_SO= libluajit.so
LUAJIT_T= luajit LUAJIT_T= luajit
ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(BUILDVM_T) 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 ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
host/buildvm_arch.h
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
ALL_DYNGEN= buildvm_x86.h buildvm_x64.h buildvm_x64win.h buildvm_arm.h \
buildvm_ppc.h buildvm_ppcspe.h buildvm_mips.h
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
ALL_RM= $(ALL_T) $(ALL_GEN) *.o $(WIN_RM) ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
############################################################################## ##############################################################################
# Build mode handling. # Build mode handling.
@ -427,8 +436,11 @@ TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
ifeq (Windows,$(HOST_SYS)) ifeq (Windows,$(HOST_SYS))
BUILDVM_T= buildvm.exe MINILUA_T= host/minilua.exe
LIB_VMDEFP= $(subst /,\\,$(LIB_VMDEF)) MINILUA_X= host\minilua
BUILDVM_T= host/buildvm.exe
BUILDVM_X= host\buildvm
ALL_RM:= $(subst /,\,$(ALL_RM))
endif endif
ifeq (Windows,$(TARGET_SYS)) ifeq (Windows,$(TARGET_SYS))
TARGET_DYNCC= $(STATIC_CC) TARGET_DYNCC= $(STATIC_CC)
@ -495,68 +507,39 @@ amalg:
clean: clean:
$(HOST_RM) $(ALL_RM) $(HOST_RM) $(ALL_RM)
cleaner: # Temporary rule for migration from old file layout.
$(HOST_RM) $(ALL_RM) $(ALL_DYNGEN) cleaner: clean
$(HOST_RM) buildvm*
distclean: clean
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X86) -o buildvm_x86.h buildvm_x86.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64) -o buildvm_x64.h buildvm_x86.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64WIN) -o buildvm_x64win.h buildvm_x86.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_ARM) -o buildvm_arm.h buildvm_arm.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPC) -o buildvm_ppc.h buildvm_ppc.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPCSPE) -o buildvm_ppcspe.h buildvm_ppcspe.dasc
$(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_MIPS) -o buildvm_mips.h buildvm_mips.dasc
depend: depend:
@for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \ @for file in $(ALL_HDRGEN); do \
test -f $$file || touch $$file; \ test -f $$file || touch $$file; \
done done
@$(HOST_CC) $(HOST_ACFLAGS) -MM *.c | \ @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \
sed -e "s| [^ ]*/dasm_\S*\.h||g" \ sed -e "s| [^ ]*/dasm_\S*\.h||g" \
-e "s| buildvm_\S*\.h||g" \ -e "s|^\([^l ]\)|host/\1|" \
-e "s| lj_target_\S*\.h| lj_target_*.h|g" \ -e "s| lj_target_\S*\.h| lj_target_*.h|g" \
-e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
-e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
@for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \ @for file in $(ALL_HDRGEN); do \
test -s $$file || $(HOST_RM) $$file; \ test -s $$file || $(HOST_RM) $$file; \
done done
.PHONY: default all amalg clean cleaner distclean depend .PHONY: default all amalg clean cleaner depend
############################################################################## ##############################################################################
# Rules for generated files. # Rules for generated files.
############################################################################## ##############################################################################
buildvm_x86.h: buildvm_x86.dasc $(MINILUA_T): $(MINILUA_O)
$(E) "DYNASM $@" $(E) "HOSTLINK $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X86) -o $@ buildvm_x86.dasc $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
buildvm_x64.h: buildvm_x86.dasc host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
$(E) "DYNASM $@" $(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64) -o $@ buildvm_x86.dasc $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
buildvm_x64win.h: buildvm_x86.dasc host/buildvm.o: $(DASM_DIR)/dasm_*.h
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64WIN) -o $@ buildvm_x86.dasc
buildvm_arm.h: buildvm_arm.dasc
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_ARM) -o $@ buildvm_arm.dasc
buildvm_ppc.h: buildvm_ppc.dasc
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPC) -o $@ buildvm_ppc.dasc
buildvm_ppcspe.h: buildvm_ppcspe.dasc
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPCSPE) -o $@ buildvm_ppcspe.dasc
buildvm_mips.h: buildvm_mips.dasc
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_MIPS) -o $@ buildvm_mips.dasc
buildvm.o: $(ALL_DYNGEN) $(DASM_DIR)/dasm_*.h
$(BUILDVM_T): $(BUILDVM_O) $(BUILDVM_T): $(BUILDVM_O)
$(E) "HOSTLINK $@" $(E) "HOSTLINK $@"

View File

@ -1,15 +1,3 @@
buildvm.o: buildvm.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \
lj_obj.h lj_gc.h lj_bc.h lj_ir.h lj_ircall.h lj_jit.h lj_frame.h \
lj_dispatch.h lj_ctype.h lj_ccall.h luajit.h \
lj_traceerr.h
buildvm_asm.o: buildvm_asm.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \
lj_bc.h
buildvm_fold.o: buildvm_fold.c buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_obj.h lj_ir.h
buildvm_lib.o: buildvm_lib.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \
lj_obj.h lj_lib.h
buildvm_peobj.o: buildvm_peobj.c buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_bc.h
lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_lib.h lj_alloc.h lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_lib.h lj_alloc.h
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
@ -207,3 +195,17 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c lib_os.c \ lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c lib_os.c \
lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c lib_init.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c lib_init.c
luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h
host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \
lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \
lj_gc.h lj_ccall.h lj_ctype.h luajit.h \
host/buildvm_arch.h lj_traceerr.h
host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_bc.h lj_def.h lj_arch.h
host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \
luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h
host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h
host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \
luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h
host/minilua.o: host/minilua.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3
src/host/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
minilua
buildvm
buildvm_arch.h

View File

@ -54,33 +54,24 @@ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type);
/* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */ /* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */
#define DASM_ALIGNED_WRITES 1 #define DASM_ALIGNED_WRITES 1
/* Embed architecture-specific DynASM encoder and backend. */ /* Embed architecture-specific DynASM encoder. */
#if LJ_TARGET_X86 #if LJ_TARGET_X86ORX64
#include "../dynasm/dasm_x86.h" #include "../dynasm/dasm_x86.h"
#include "buildvm_x86.h"
#elif LJ_TARGET_X64
#include "../dynasm/dasm_x86.h"
#if LJ_ABI_WIN
#include "buildvm_x64win.h"
#else
#include "buildvm_x64.h"
#endif
#elif LJ_TARGET_ARM #elif LJ_TARGET_ARM
#include "../dynasm/dasm_arm.h" #include "../dynasm/dasm_arm.h"
#include "buildvm_arm.h"
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
#include "../dynasm/dasm_ppc.h" #include "../dynasm/dasm_ppc.h"
#include "buildvm_ppc.h"
#elif LJ_TARGET_PPCSPE #elif LJ_TARGET_PPCSPE
#include "../dynasm/dasm_ppc.h" #include "../dynasm/dasm_ppc.h"
#include "buildvm_ppcspe.h"
#elif LJ_TARGET_MIPS #elif LJ_TARGET_MIPS
#include "../dynasm/dasm_mips.h" #include "../dynasm/dasm_mips.h"
#include "buildvm_mips.h"
#else #else
#error "No support for this architecture (yet)" #error "No support for this architecture (yet)"
#endif #endif
/* Embed generated architecture-specific backend. */
#include "buildvm_arch.h"
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void owrite(BuildCtx *ctx, const void *ptr, size_t sz) void owrite(BuildCtx *ctx, const void *ptr, size_t sz)

View File

@ -19,17 +19,28 @@
@set LJMT=mt /nologo @set LJMT=mt /nologo
@set LJLIB=lib /nologo @set LJLIB=lib /nologo
@set DASMDIR=..\dynasm @set DASMDIR=..\dynasm
@set DASM=lua %DASMDIR%\dynasm.lua @set DASM=%DASMDIR%\dynasm.lua
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
if not exist buildvm_x86.h^ %LJCOMPILE% host\minilua.c
%DASM% -LN -o buildvm_x86.h buildvm_x86.dasc
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
if not exist buildvm_x64win.h^ %LJLINK% /out:minilua.exe minilua.obj
%DASM% -LN -D X64 -D X64WIN -o buildvm_x64win.h buildvm_x86.dasc @if errorlevel 1 goto :BAD
if exist minilua.exe.manifest^
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
@set DASMFLAGS=-D X64 -D X64WIN
@if defined CPU goto :XCPU
@set CPU=%PROCESSOR_ARCHITECTURE%
:XCPU
@if "%CPU%"=="AMD64" goto :X64
@if "%CPU%"=="X64" goto :X64
@set DASMFLAGS=
:X64
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJCOMPILE% /I "." /I %DASMDIR% buildvm*.c %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj %LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD @if errorlevel 1 goto :BAD
@ -85,7 +96,7 @@ if exist lua51.dll.manifest^
if exist luajit.exe.manifest^ if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
@del *.obj *.manifest buildvm.exe @del *.obj *.manifest minilua.exe buildvm.exe
@echo. @echo.
@echo === Successfully built LuaJIT === @echo === Successfully built LuaJIT ===