2 rem ***************************************************************************
4 rem * Project ___| | | | _ \| |
5 rem * / __| | | | |_) | |
6 rem * | (__| |_| | _ <| |___
7 rem * \___|\___/|_| \_\_____|
9 rem * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
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 https://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 ***************************************************************************
26 rem This batch file must be used to set up a git tree to build on systems where
27 rem there is no autotools support (i.e. DOS and Windows).
32 if "%OS%" == "Windows_NT" setlocal
35 rem Switch to this batch file's directory
36 cd /d "%~0\.." 1>NUL 2>&1
38 rem Check we are running from a curl git repository
39 if not exist GIT-INFO goto norepo
41 rem Detect programs. HAVE_<PROGNAME>
42 rem When not found the variable is set undefined. The undefined pattern
43 rem allows for statements like "if not defined HAVE_PERL (command)"
44 groff --version <NUL 1>NUL 2>&1
45 if errorlevel 1 (set HAVE_GROFF=) else (set HAVE_GROFF=Y)
46 nroff --version <NUL 1>NUL 2>&1
47 if errorlevel 1 (set HAVE_NROFF=) else (set HAVE_NROFF=Y)
48 perl --version <NUL 1>NUL 2>&1
49 if errorlevel 1 (set HAVE_PERL=) else (set HAVE_PERL=Y)
50 gzip --version <NUL 1>NUL 2>&1
51 if errorlevel 1 (set HAVE_GZIP=) else (set HAVE_GZIP=Y)
54 if "%~1" == "" goto start
56 if /i "%~1" == "-clean" (
58 ) else if /i "%~1" == "-?" (
60 ) else if /i "%~1" == "-h" (
62 ) else if /i "%~1" == "-help" (
68 shift & goto parseArgs
71 if "%MODE%" == "GENERATE" (
73 echo Generating prerequisite files
76 if errorlevel 4 goto nogencurlbuild
77 if errorlevel 3 goto nogenhugehelp
78 if errorlevel 2 goto nogenmakefile
79 if errorlevel 1 goto warning
83 echo Removing prerequisite files
86 if errorlevel 3 goto nocleancurlbuild
87 if errorlevel 2 goto nocleanhugehelp
88 if errorlevel 1 goto nocleanmakefile
93 rem Main generate function.
98 rem 1 - success with simplified tool_hugehelp.c
99 rem 2 - failed to generate Makefile
100 rem 3 - failed to generate tool_hugehelp.c
101 rem 4 - failed to generate curlbuild.h
104 if "%OS%" == "Windows_NT" setlocal
109 if exist Makefile.dist (
110 copy /Y Makefile.dist Makefile 1>NUL 2>&1
112 if "%OS%" == "Windows_NT" endlocal
117 rem Create tool_hugehelp.c
118 echo * %CD%\src\tool_hugehelp.c
121 if "%OS%" == "Windows_NT" endlocal
129 rem Create curlbuild.h
130 echo * %CD%\include\curl\curlbuild.h
131 if exist include\curl\curlbuild.h.dist (
132 copy /Y include\curl\curlbuild.h.dist include\curl\curlbuild.h 1>NUL 2>&1
134 if "%OS%" == "Windows_NT" endlocal
139 rem Setup c-ares git tree
140 if exist ares\buildconf.bat (
142 echo Configuring c-ares build environment
148 if "%BASIC_HUGEHELP%" == "1" (
149 if "%OS%" == "Windows_NT" endlocal
153 if "%OS%" == "Windows_NT" endlocal
156 rem Main clean function.
161 rem 1 - failed to clean Makefile
162 rem 2 - failed to clean tool_hugehelp.c
163 rem 3 - failed to clean curlbuild.h
175 rem Remove tool_hugehelp.c
176 echo * %CD%\src\tool_hugehelp.c
177 if exist src\tool_hugehelp.c (
178 del src\tool_hugehelp.c 2>NUL
179 if exist src\tool_hugehelp.c (
184 rem Remove curlbuild.h
185 echo * %CD%\include\curl\curlbuild.h
186 if exist include\curl\curlbuild.h (
187 del include\curl\curlbuild.h 2>NUL
188 if exist include\curl\curlbuild.h (
195 rem Function to generate src\tool_hugehelp.c
199 rem 0 - full tool_hugehelp.c generated
200 rem 1 - simplified tool_hugehelp.c
204 if "%OS%" == "Windows_NT" setlocal
209 if defined HAVE_PERL (
210 if defined HAVE_GROFF (
211 set ROFFCMD=groff -mtty-char -Tascii -P-c -man
212 ) else if defined HAVE_NROFF (
213 set ROFFCMD=nroff -c -Tascii -man
218 echo #include "tool_setup.h"> src\tool_hugehelp.c
219 echo #include "tool_hugehelp.h">> src\tool_hugehelp.c
221 if defined HAVE_GZIP (
222 echo #ifndef HAVE_LIBZ>> src\tool_hugehelp.c
225 %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl docs\MANUAL >> src\tool_hugehelp.c
226 if defined HAVE_GZIP (
227 echo #else>> src\tool_hugehelp.c
228 %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl -c docs\MANUAL >> src\tool_hugehelp.c
229 echo #endif /^* HAVE_LIBZ ^*/>> src\tool_hugehelp.c
234 if exist src\tool_hugehelp.c.cvs (
235 copy /Y src\tool_hugehelp.c.cvs src\tool_hugehelp.c 1>NUL 2>&1
237 echo #include "tool_setup.h"> src\tool_hugehelp.c
238 echo #include "tool_hugehelp.hd">> src\tool_hugehelp.c
239 echo.>> src\tool_hugehelp.c
240 echo void hugehelp(void^)>> src\tool_hugehelp.c
241 echo {>> src\tool_hugehelp.c
242 echo #ifdef USE_MANUAL>> src\tool_hugehelp.c
243 echo fputs("Built-in manual not included\n", stdout^);>> src\tool_hugehelp.c
244 echo #endif>> src\tool_hugehelp.c
245 echo }>> src\tool_hugehelp.c
249 findstr "/C:void hugehelp(void)" src\tool_hugehelp.c 1>NUL 2>&1
251 if "%OS%" == "Windows_NT" endlocal
255 if "%BASIC%" == "1" (
256 if "%OS%" == "Windows_NT" endlocal
260 if "%OS%" == "Windows_NT" endlocal
263 rem Function to clean-up local variables under DOS, Windows 3.x and
264 rem Windows 9x as setlocal isn't available until Windows NT
282 echo Usage: buildconf [-clean]
284 echo -clean - Removes the files
289 echo Error: Unknown argument '%1'
294 echo Error: This batch file should only be used with a curl git repository
299 echo Error: Unable to generate Makefile
304 echo Error: Unable to generate src\tool_hugehelp.c
309 echo Error: Unable to generate include\curl\curlbuild.h
314 echo Error: Unable to clean Makefile
319 echo Error: Unable to clean src\tool_hugehelp.c
324 echo Error: Unable to clean include\curl\curlbuild.h
329 echo Warning: The curl manual could not be integrated in the source. This means when
330 echo you build curl the manual will not be available (curl --man^). Integration of
331 echo the manual is not required and a summary of the options will still be available
332 echo (curl --help^). To integrate the manual your PATH is required to have
333 echo groff/nroff, perl and optionally gzip for compression.
337 if "%OS%" == "Windows_NT" (
345 if "%OS%" == "Windows_NT" (