1 @rem Script to build LuaJIT with MSVC.
\r
2 @rem Copyright (C) 2005-2013 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 LJDLLNAME=lua51.dll
\r
24 @set LJLIBNAME=lua51.lib
\r
25 @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
27 %LJCOMPILE% host\minilua.c
\r
28 @if errorlevel 1 goto :BAD
\r
29 %LJLINK% /out:minilua.exe minilua.obj
\r
30 @if errorlevel 1 goto :BAD
\r
31 if exist minilua.exe.manifest^
\r
32 %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
\r
34 @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64
\r
37 @if errorlevel 8 goto :X64
\r
38 @set DASMFLAGS=-D WIN -D JIT -D FFI
\r
41 minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
\r
42 @if errorlevel 1 goto :BAD
\r
44 %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
\r
45 @if errorlevel 1 goto :BAD
\r
46 %LJLINK% /out:buildvm.exe buildvm*.obj
\r
47 @if errorlevel 1 goto :BAD
\r
48 if exist buildvm.exe.manifest^
\r
49 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
\r
51 buildvm -m peobj -o lj_vm.obj
\r
52 @if errorlevel 1 goto :BAD
\r
53 buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
\r
54 @if errorlevel 1 goto :BAD
\r
55 buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
\r
56 @if errorlevel 1 goto :BAD
\r
57 buildvm -m libdef -o lj_libdef.h %ALL_LIB%
\r
58 @if errorlevel 1 goto :BAD
\r
59 buildvm -m recdef -o lj_recdef.h %ALL_LIB%
\r
60 @if errorlevel 1 goto :BAD
\r
61 buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
\r
62 @if errorlevel 1 goto :BAD
\r
63 buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
\r
64 @if errorlevel 1 goto :BAD
\r
66 @if "%1" neq "debug" goto :NODEBUG
\r
68 @set LJCOMPILE=%LJCOMPILE% /Zi
\r
69 @set LJLINK=%LJLINK% /debug
\r
71 @if "%1"=="amalg" goto :AMALGDLL
\r
72 @if "%1"=="static" goto :STATIC
\r
73 %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
\r
74 @if errorlevel 1 goto :BAD
\r
75 %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
\r
76 @if errorlevel 1 goto :BAD
\r
79 %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
\r
80 @if errorlevel 1 goto :BAD
\r
81 %LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
\r
82 @if errorlevel 1 goto :BAD
\r
85 %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
\r
86 @if errorlevel 1 goto :BAD
\r
87 %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
\r
88 @if errorlevel 1 goto :BAD
\r
90 if exist %LJDLLNAME%.manifest^
\r
91 %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
\r
93 %LJCOMPILE% luajit.c
\r
94 @if errorlevel 1 goto :BAD
\r
95 %LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
\r
96 @if errorlevel 1 goto :BAD
\r
97 if exist luajit.exe.manifest^
\r
98 %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
\r
100 @del *.obj *.manifest minilua.exe buildvm.exe
\r
102 @echo === Successfully built LuaJIT for Windows/%LJARCH% ===
\r
107 @echo *******************************************************
\r
108 @echo *** Build FAILED -- Please check the error messages ***
\r
109 @echo *******************************************************
\a\r
112 @echo You must open a "Visual Studio .NET Command Prompt" to run this script
\r