forked from blackrosezy/build-libcurl-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
162 lines (130 loc) · 4.46 KB
/
build.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@echo off
setlocal EnableDelayedExpansion
set PROGFILES=%ProgramFiles%
if not "%ProgramFiles(x86)%" == "" set PROGFILES=%ProgramFiles(x86)%
REM Check if Visual Studio 2013 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio 12.0"
if exist %MSVCDIR% (
set COMPILER_VER="2013"
goto setup_env
)
REM Check if Visual Studio 2012 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio 11.0"
if exist %MSVCDIR% (
set COMPILER_VER="2012"
goto setup_env
)
REM Check if Visual Studio 2010 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio 10.0"
if exist %MSVCDIR% (
set COMPILER_VER="2010"
goto setup_env
)
REM Check if Visual Studio 2008 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio 9.0"
if exist %MSVCDIR% (
set COMPILER_VER="2008"
goto setup_env
)
REM Check if Visual Studio 2005 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio 8"
if exist %MSVCDIR% (
set COMPILER_VER="2005"
goto setup_env
)
REM Check if Visual Studio 6 is installed
set MSVCDIR="%PROGFILES%\Microsoft Visual Studio\VC98"
if exist %MSVCDIR% (
set COMPILER_VER="6"
goto setup_env
)
echo No compiler : Microsoft Visual Studio (6, 2005, 2008, 2010, 2012 or 2013) is not installed.
goto end
:setup_env
echo Setting up environment
if %COMPILER_VER% == "6" (
call %MSVCDIR%\Bin\VCVARS32.BAT
goto begin
)
call %MSVCDIR%\VC\vcvarsall.bat x86
:begin
REM Setup path to helper bin
set ROOT_DIR="%CD%"
set RM="%CD%\bin\unxutils\rm.exe"
set CP="%CD%\bin\unxutils\cp.exe"
set MKDIR="%CD%\bin\unxutils\mkdir.exe"
set SEVEN_ZIP="%CD%\bin\7-zip\7za.exe"
set WGET="%CD%\bin\unxutils\wget.exe"
set XIDEL="%CD%\bin\xidel\xidel.exe"
REM Housekeeping
%RM% -rf tmp_*
%RM% -rf third-party
%RM% -rf curl.zip
%RM% -rf build_*.txt
REM Get download url .Look under <blockquote><a type='application/zip' href='xxx'>
echo Get download url...
%XIDEL% http://curl.haxx.se/download.html -e "//a[@type='application/x-gzip' and ends-with(@href, '.zip')]/@href" > tmp_url
set /p url=<tmp_url
REM Download latest curl and rename to curl.zip
echo Downloading latest curl...
%WGET% "http://curl.haxx.se%url%" -O curl.zip
REM Extract downloaded zip file to tmp_libcurl
%SEVEN_ZIP% x curl.zip -y -otmp_libcurl | FIND /V "ing " | FIND /V "Igor Pavlov"
cd tmp_libcurl\curl-*\winbuild
if %COMPILER_VER% == "6" (
set VCVERSION = 6
goto buildnow
)
if %COMPILER_VER% == "2005" (
set VCVERSION = 8
goto buildnow
)
if %COMPILER_VER% == "2008" (
set VCVERSION = 9
goto buildnow
)
if %COMPILER_VER% == "2010" (
set VCVERSION = 10
goto buildnow
)
if %COMPILER_VER% == "2012" (
set VCVERSION = 11
goto buildnow
)
if %COMPILER_VER% == "2013" (
set VCVERSION = 12
goto buildnow
)
:buildnow
REM Build!
nmake /f Makefile.vc mode=dll VC=%VCVERSION% DEBUG=yes
nmake /f Makefile.vc mode=dll VC=%VCVERSION% DEBUG=no GEN_PDB=yes
nmake /f Makefile.vc mode=static VC=%VCVERSION% DEBUG=yes
nmake /f Makefile.vc mode=static VC=%VCVERSION% DEBUG=no
REM Copy compiled .*lib, *.pdb, *.dll files folder to third-party\lib\dll-debug folder
cd %ROOT_DIR%\tmp_libcurl\curl-*\builds\libcurl-vc-x86-debug-dll-ipv6-sspi-winssl
%MKDIR% -p %ROOT_DIR%\third-party\libcurl\lib\dll-debug
%CP% lib\*.pdb %ROOT_DIR%\third-party\libcurl\lib\dll-debug
%CP% lib\*.lib %ROOT_DIR%\third-party\libcurl\lib\dll-debug
%CP% bin\*.dll %ROOT_DIR%\third-party\libcurl\lib\dll-debug
REM Copy compiled .*lib, *.pdb, *.dll files to third-party\lib\dll-release folder
cd %ROOT_DIR%\tmp_libcurl\curl-*\builds\libcurl-vc-x86-release-dll-ipv6-sspi-winssl
%MKDIR% -p %ROOT_DIR%\third-party\libcurl\lib\dll-release
%CP% lib\*.pdb %ROOT_DIR%\third-party\libcurl\lib\dll-release
%CP% lib\*.lib %ROOT_DIR%\third-party\libcurl\lib\dll-release
%CP% bin\*.dll %ROOT_DIR%\third-party\libcurl\lib\dll-release
REM Copy compiled .*lib file in lib-release folder to third-party\lib\static-debug folder
cd %ROOT_DIR%\tmp_libcurl\curl-*\builds\libcurl-vc-x86-debug-static-ipv6-sspi-winssl
%MKDIR% -p %ROOT_DIR%\third-party\libcurl\lib\static-debug
%CP% lib\*.lib %ROOT_DIR%\third-party\libcurl\lib\static-debug
REM Copy compiled .*lib files in lib-release folder to third-party\lib\static-release folder
cd %ROOT_DIR%\tmp_libcurl\curl-*\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl
%MKDIR% -p %ROOT_DIR%\third-party\libcurl\lib\static-release
%CP% lib\*.lib %ROOT_DIR%\third-party\libcurl\lib\static-release
REM Copy include folder to third-party folder
%CP% -rf include %ROOT_DIR%\third-party\libcurl
REM Cleanup temporary file/folders
cd %ROOT_DIR%
%RM% -rf tmp_*
:end
exit /b