2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>.
11 rem * This software is licensed as described in the file COPYING, which
12 rem * you should have received as part of this distribution. The terms
13 rem * are also available at http://curl.haxx.se/docs/copyright.html.
15 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 rem * copies of the Software, and permit persons to whom the Software is
17 rem * furnished to do so, under the terms of the COPYING file.
19 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 rem * KIND, either express or implied.
22 rem ***************************************************************************
25 rem Check we are running on a Windows NT derived OS
26 if not "%OS%" == "Windows_NT" goto nodos
30 if /i "%~1" == "-?" goto syntax
31 if /i "%~1" == "-h" goto syntax
32 if /i "%~1" == "-help" goto syntax
35 if "%~1" == "" goto all
37 if /i "%~1" == "vc6" (
39 ) else if /i "%~1" == "vc7" (
41 ) else if /i "%~1" == "vc7.1" (
43 ) else if /i "%~1" == "vc8" (
45 ) else if /i "%~1" == "vc9" (
47 ) else if /i "%~1" == "vc10" (
49 ) else if /i "%~1" == "vc11" (
51 ) else if /i "%~1" == "vc12" (
62 echo Generating VC6 project files
63 call :generate dsp Windows\VC6\src\curlsrc.tmpl Windows\VC6\src\curlsrc.dsp
64 call :generate dsp Windows\VC6\lib\libcurl.tmpl Windows\VC6\lib\libcurl.dsp
65 if not "%ALL%" == "true" goto success
69 echo Generating VC7 project files
70 call :generate vcproj1 Windows\VC7\src\curlsrc.tmpl Windows\VC7\src\curlsrc.vcproj
71 call :generate vcproj1 Windows\VC7\lib\libcurl.tmpl Windows\VC7\lib\libcurl.vcproj
72 if not "%ALL%" == "true" goto success
76 echo Generating VC7.1 project files
77 call :generate vcproj1 Windows\VC7.1\src\curlsrc.tmpl Windows\VC7.1\src\curlsrc.vcproj
78 call :generate vcproj1 Windows\VC7.1\lib\libcurl.tmpl Windows\VC7.1\lib\libcurl.vcproj
79 if not "%ALL%" == "true" goto success
83 echo Generating VC8 project files
84 call :generate vcproj2 Windows\VC8\src\curlsrc.tmpl Windows\VC8\src\curlsrc.vcproj
85 call :generate vcproj2 Windows\VC8\lib\libcurl.tmpl Windows\VC8\lib\libcurl.vcproj
86 if not "%ALL%" == "true" goto success
90 echo Generating VC9 project files
91 call :generate vcproj2 Windows\VC9\src\curlsrc.tmpl Windows\VC9\src\curlsrc.vcproj
92 call :generate vcproj2 Windows\VC9\lib\libcurl.tmpl Windows\VC9\lib\libcurl.vcproj
93 if not "%ALL%" == "true" goto success
97 echo Generating VC10 project files
98 call :generate vcxproj Windows\VC10\src\curlsrc.tmpl Windows\VC10\src\curlsrc.vcxproj
99 call :generate vcxproj Windows\VC10\lib\libcurl.tmpl Windows\VC10\lib\libcurl.vcxproj
100 if not "%ALL%" == "true" goto success
104 echo Generating VC11 project files
105 call :generate vcxproj Windows\VC11\src\curlsrc.tmpl Windows\VC11\src\curlsrc.vcxproj
106 call :generate vcxproj Windows\VC11\lib\libcurl.tmpl Windows\VC11\lib\libcurl.vcxproj
107 if not "%ALL%" == "true" goto success
111 echo Generating VC12 project files
112 call :generate vcxproj Windows\VC12\src\curlsrc.tmpl Windows\VC12\src\curlsrc.vcxproj
113 call :generate vcxproj Windows\VC12\lib\libcurl.tmpl Windows\VC12\lib\libcurl.vcxproj
117 rem Main generate function.
119 rem %1 - Project Type (dsp for VC6, vcproj1 for VC7 and VC7.1, vcproj2 for VC8 and VC9
120 rem or vcxproj for VC10, VC11 and VC12)
121 rem %2 - Input template file
122 rem %3 - Output project file
127 echo Error: Cannot open %CD%\%2
136 for /f "usebackq delims=" %%i in (`"findstr /n ^^ %2"`) do (
138 setlocal enabledelayedexpansion
141 if "!var!" == "CURL_SRC_C_FILES" (
142 for /f "delims=" %%c in ('dir /b ..\src\*.c') do call :element %1 src "%%c" %3
143 ) else if "!var!" == "CURL_SRC_H_FILES" (
144 for /f "delims=" %%h in ('dir /b ..\src\*.h') do call :element %1 src "%%h" %3
145 ) else if "!var!" == "CURL_SRC_RC_FILES" (
146 for /f "delims=" %%r in ('dir /b ..\src\*.rc') do call :element %1 src "%%r" %3
147 ) else if "!var!" == "CURL_SRC_X_C_FILES" (
148 call :element %1 lib "strtoofft.c" %3
149 call :element %1 lib "rawstr.c" %3
150 call :element %1 lib "nonblock.c" %3
151 call :element %1 lib "warnless.c" %3
152 ) else if "!var!" == "CURL_SRC_X_H_FILES" (
153 call :element %1 lib "config-win32.h" %3
154 call :element %1 lib "curl_setup.h" %3
155 call :element %1 lib "strtoofft.h" %3
156 call :element %1 lib "rawstr.h" %3
157 call :element %1 lib "nonblock.h" %3
158 call :element %1 lib "warnless.h" %3
159 ) else if "!var!" == "CURL_LIB_C_FILES" (
160 for /f "delims=" %%c in ('dir /b ..\lib\*.c') do call :element %1 lib "%%c" %3
161 ) else if "!var!" == "CURL_LIB_H_FILES" (
162 for /f "delims=" %%h in ('dir /b ..\lib\*.h') do call :element %1 lib "%%h" %3
163 ) else if "!var!" == "CURL_LIB_RC_FILES" (
164 for /f "delims=" %%r in ('dir /b ..\lib\*.rc') do call :element %1 lib "%%r" %3
165 ) else if "!var!" == "CURL_LIB_VTLS_C_FILES" (
166 for /f "delims=" %%c in ('dir /b ..\lib\vtls\*.c') do call :element %1 lib\vtls "%%c" %3
167 ) else if "!var!" == "CURL_LIB_VTLS_H_FILES" (
168 for /f "delims=" %%h in ('dir /b ..\lib\vtls\*.h') do call :element %1 lib\vtls "%%h" %3
177 rem Generates a single file xml element.
179 rem %1 - Project Type (dsp for VC6, vcproj1 for VC7 and VC7.1, vcproj2 for VC8 and VC9
180 rem or vcxproj for VC10, VC11 and VC12)
181 rem %2 - Directory (src, lib or lib\vtls)
182 rem %3 - Source filename
183 rem %4 - Output project file
187 if "%2" == "lib\vtls" (
193 call :extension %3 ext
196 echo # Begin Source File>> %4
198 echo SOURCE=..\..\..\..\%2\%~3>> %4
199 echo # End Source File>> %4
200 ) else if "%1" == "vcproj1" (
201 echo %TABS%^<File>> %4
202 echo %TABS% RelativePath="..\..\..\..\%2\%~3"^>>> %4
203 echo %TABS%^</File^>>> %4
204 ) else if "%1" == "vcproj2" (
205 echo %TABS%^<File>> %4
206 echo %TABS% RelativePath="..\..\..\..\%2\%~3">> %4
208 echo %TABS%^</File^>>> %4
209 ) else if "%1" == "vcxproj" (
211 echo %SPACES%^<ClCompile Include=^"..\..\..\..\%2\%~3^" /^>>> %4
212 ) else if "%ext%" == "h" (
213 echo %SPACES%^<ClInclude Include=^"..\..\..\..\%2\%~3^" /^>>> %4
214 ) else if "%ext%" == "rc" (
215 echo %SPACES%^<ResourceCompile Include=^"..\..\..\..\%2\%~3^" /^>>> %4
221 rem Returns the extension for a given filename.
223 rem %1 - The filename
224 rem %2 - The return value
235 if not "%fname:~-1%"=="." (
236 set ename=%fname:~-1%%ename%
237 set fname=%fname:~0,-1%
247 echo Usage: generate [compiler]
251 echo vc6 - Use Visual Studio 6
252 echo vc7 - Use Visual Studio .NET
253 echo vc7.1 - Use Visual Studio .NET 2003
254 echo vc8 - Use Visual Studio 2005
255 echo vc9 - Use Visual Studio 2008
256 echo vc10 - Use Visual Studio 2010
257 echo vc11 - Use Visual Studio 2012
258 echo vc12 - Use Visual Studio 2013
263 echo Error: Unknown argument '%1'
268 echo Error: Only a Windows NT based Operating System is supported