1 @rem Script to build LuaJIT with MSVC.
\r
2 @rem Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
\r
4 @rem Either open a "Visual Studio .NET Command Prompt"
\r
5 @rem (Note that the Express Edition does not contain an x64 compiler)
\r
7 @rem Open a "Windows SDK Command Shell" and set the compiler environment:
\r
8 @rem setenv /release /x86
\r
10 @rem setenv /release /x64
\r
12 @rem Then cd to this directory and run this script.
\r
14 @if not defined INCLUDE goto :FAIL
\r
17 @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
\r
18 @set LJLINK=link /nologo
\r
19 @set LJMT=mt /nologo
\r
20 @set LJLIB=lib /nologo
\r
21 @set DASMDIR=..\dynasm
\r
22 @set DASM=%DASMDIR%\dynasm.lua
\r
23 @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
\r
25 %LJCOMPILE% host\minilua.c
\r
26 @if errorlevel 1 goto :BAD
\r
27 %LJLINK% /out:minilua.exe minilua.obj
\r
28 @if errorlevel 1 goto :BAD
\r
29 if exist minilua.exe.manifest^
\r
30 %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
\r
32 @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
\r
35 @if errorlevel 8 goto :X64
\r
36 @set DASMFLAGS=-D WIN -D JIT -D FFI
\r
39 minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
\r
40 @if errorlevel 1 goto :BAD
\r
42 %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
\r
43 @if errorlevel 1 goto :BAD
\r
44 %LJLINK% /out:buildvm.exe buildvm*.obj
\r
45 @if errorlevel 1 goto :BAD
\r
46 if exist buildvm.exe.manifest^
\r
47 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
\r
49 buildvm -m peobj -o lj_vm.obj
\r
50 @if errorlevel 1 goto :BAD
\r
51 buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
\r
52 @if errorlevel 1 goto :BAD
\r
53 buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
\r
54 @if errorlevel 1 goto :BAD
\r
55 buildvm -m libdef -o lj_libdef.h %ALL_LIB%
\r
56 @if errorlevel 1 goto :BAD
\r
57 buildvm -m recdef -o lj_recdef.h %ALL_LIB%
\r
58 @if errorlevel 1 goto :BAD
\r
59 buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
\r
60 @if errorlevel 1 goto :BAD
\r
61 buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
\r
62 @if errorlevel 1 goto :BAD
\r
64 @if "%1" neq "debug" goto :NODEBUG
\r
66 @set LJCOMPILE=%LJCOMPILE% /Zi
\r
67 @set LJLINK=%LJLINK% /debug
\r
69 @if "%1"=="amalg" goto :AMALGDLL
\r
70 @if "%1"=="static" goto :STATIC
\r
71 %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
\r
72 @if errorlevel 1 goto :BAD
\r
73 %LJLINK% /DLL /out:lua51.dll lj_*.obj lib_*.obj
\r
74 @if errorlevel 1 goto :BAD
\r
77 %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
\r
78 @if errorlevel 1 goto :BAD
\r
79 %LJLIB% /OUT:lua51.lib lj_*.obj lib_*.obj
\r
80 @if errorlevel 1 goto :BAD
\r
83 %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
\r
84 @if errorlevel 1 goto :BAD
\r
85 %LJLINK% /DLL /out:lua51.dll ljamalg.obj lj_vm.obj
\r
86 @if errorlevel 1 goto :BAD
\r
88 if exist lua51.dll.manifest^
\r
89 %LJMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2
\r
91 %LJCOMPILE% luajit.c
\r
92 @if errorlevel 1 goto :BAD
\r
93 %LJLINK% /out:luajit.exe luajit.obj lua51.lib
\r
94 @if errorlevel 1 goto :BAD
\r
95 if exist luajit.exe.manifest^
\r
96 %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
\r
98 @del *.obj *.manifest minilua.exe buildvm.exe
\r
100 @echo === Successfully built LuaJIT for Windows/%LJARCH% ===
\r
105 @echo *******************************************************
\r
106 @echo *** Build FAILED -- Please check the error messages ***
\r
107 @echo *******************************************************
\a\r
110 @echo You must open a "Visual Studio .NET Command Prompt" to run this script
\r