-
Notifications
You must be signed in to change notification settings - Fork 23
/
msvcmake.bat
75 lines (57 loc) · 1.66 KB
/
msvcmake.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@ECHO OFF
SETLOCAL
REM Please make sure that Microsoft Visual Studio compiler and linker are
REM reachable from your %Path% environment variable.
SET RCOMPILER=rc.exe
SET CCOMPILER=cl.exe
SET LINKER=link.exe
SET STRIPCMD=strip.exe
SET CFLAGS=/c /O2
SET DLLOUTPUT=libconfini.dll
SET DEFFILE=src\libconfini.def
SET RCFILE=src\winres.rc
REM The following variable may contain a space-delimited list of files
SET SRCFILES=src\confini.c
WHERE %CCOMPILER% >nul 2>nul
IF %ERRORLEVEL% NEQ 0 (
@ECHO Program %CCOMPILER% has not been found. Abort.
EXIT /B 1
)
WHERE %RCOMPILER% >nul 2>nul
SET /A __RCERR__=%ERRORLEVEL%
SET __TMP_RSO__=winres.res
IF %__RCERR__% NEQ 0 (
@ECHO Program %RCOMPILER% has not been found. Proceeding without resource file.
GOTO COMPILE_DLL
)
@ECHO Loading resource file...
%RCOMPILER% /fo %__TMP_RSO__% %RCFILE%
SET /A __RCERR__=%ERRORLEVEL%
IF %__RCERR__% NEQ 0 (
@ECHO An error occured. Proceeding without resource file.
)
:COMPILE_DLL
SET __TMP_OBJ__=confini.obj
@ECHO Compiling %SRCFILES%...
%CCOMPILER% /Fo%__TMP_OBJ__% %CFLAGS% %SRCFILES%
SET /A __CCERR__=%ERRORLEVEL%
IF %__CCERR__% NEQ 0 (
@ECHO An error occured while compiling the library. Abort.
EXIT /B %__CCERR__%
)
@ECHO Creating %DLLOUTPUT%...
IF %__RCERR__% EQU 0 (
%LINKER% /DLL /DEF:%DEFFILE% /OUT:%DLLOUTPUT% %__TMP_RSO__% %__TMP_OBJ__%
) ELSE (
%LINKER% /DLL /DEF:%DEFFILE% /OUT:%DLLOUTPUT% %__TMP_OBJ__%
)
SET /A __LINKERR__=%ERRORLEVEL%
IF %__LINKERR__% EQU 0 (
IF %__RCERR__% EQU 0 DEL %__TMP_RSO__%
DEL %__TMP_OBJ__%
@ECHO Done.
) ELSE (
@ECHO Could not create the DLL.
)
EXIT /B %__CCERR__%
ENDLOCAL