Disable a debug option
[platform/upstream/curl.git] / buildconf.bat
1 @echo off\r
2 rem ***************************************************************************\r
3 rem *                                  _   _ ____  _\r
4 rem *  Project                     ___| | | |  _ \| |\r
5 rem *                             / __| | | | |_) | |\r
6 rem *                            | (__| |_| |  _ <| |___\r
7 rem *                             \___|\___/|_| \_\_____|\r
8 rem *\r
9 rem * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.\r
10 rem *\r
11 rem * This software is licensed as described in the file COPYING, which\r
12 rem * you should have received as part of this distribution. The terms\r
13 rem * are also available at https://curl.se/docs/copyright.html.\r
14 rem *\r
15 rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
16 rem * copies of the Software, and permit persons to whom the Software is\r
17 rem * furnished to do so, under the terms of the COPYING file.\r
18 rem *\r
19 rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY\r
20 rem * KIND, either express or implied.\r
21 rem *\r
22 rem * SPDX-License-Identifier: curl\r
23 rem *\r
24 rem ***************************************************************************\r
25 \r
26 rem NOTES\r
27 rem\r
28 rem This batch file must be used to set up a git tree to build on systems where\r
29 rem there is no autotools support (i.e. DOS and Windows).\r
30 rem\r
31 \r
32 :begin\r
33   rem Set our variables\r
34   if "%OS%" == "Windows_NT" setlocal\r
35   set MODE=GENERATE\r
36 \r
37   rem Switch to this batch file's directory\r
38   cd /d "%~0\.." 1>NUL 2>&1\r
39 \r
40   rem Check we are running from a curl git repository\r
41   if not exist GIT-INFO goto norepo\r
42 \r
43   rem Detect programs. HAVE_<PROGNAME>\r
44   rem When not found the variable is set undefined. The undefined pattern\r
45   rem allows for statements like "if not defined HAVE_PERL (command)"\r
46   groff --version <NUL 1>NUL 2>&1\r
47   if errorlevel 1 (set HAVE_GROFF=) else (set HAVE_GROFF=Y)\r
48   nroff --version <NUL 1>NUL 2>&1\r
49   if errorlevel 1 (set HAVE_NROFF=) else (set HAVE_NROFF=Y)\r
50   perl --version <NUL 1>NUL 2>&1\r
51   if errorlevel 1 (set HAVE_PERL=) else (set HAVE_PERL=Y)\r
52   gzip --version <NUL 1>NUL 2>&1\r
53   if errorlevel 1 (set HAVE_GZIP=) else (set HAVE_GZIP=Y)\r
54 \r
55 :parseArgs\r
56   if "%~1" == "" goto start\r
57 \r
58   if /i "%~1" == "-clean" (\r
59     set MODE=CLEAN\r
60   ) else if /i "%~1" == "-?" (\r
61     goto syntax\r
62   ) else if /i "%~1" == "-h" (\r
63     goto syntax\r
64   ) else if /i "%~1" == "-help" (\r
65     goto syntax\r
66   ) else (\r
67     goto unknown\r
68   )\r
69 \r
70   shift & goto parseArgs\r
71 \r
72 :start\r
73   if "%MODE%" == "GENERATE" (\r
74     echo.\r
75     echo Generating prerequisite files\r
76 \r
77     call :generate\r
78     if errorlevel 3 goto nogenhugehelp\r
79     if errorlevel 2 goto nogenmakefile\r
80     if errorlevel 1 goto warning\r
81 \r
82   ) else (\r
83     echo.\r
84     echo Removing prerequisite files\r
85 \r
86     call :clean\r
87     if errorlevel 2 goto nocleanhugehelp\r
88     if errorlevel 1 goto nocleanmakefile\r
89   )\r
90 \r
91   goto success\r
92 \r
93 rem Main generate function.\r
94 rem\r
95 rem Returns:\r
96 rem\r
97 rem 0 - success\r
98 rem 1 - success with simplified tool_hugehelp.c\r
99 rem 2 - failed to generate Makefile\r
100 rem 3 - failed to generate tool_hugehelp.c\r
101 rem\r
102 :generate\r
103   if "%OS%" == "Windows_NT" setlocal\r
104   set BASIC_HUGEHELP=0\r
105 \r
106   rem Create Makefile\r
107   echo * %CD%\Makefile\r
108   if exist Makefile.dist (\r
109     copy /Y Makefile.dist Makefile 1>NUL 2>&1\r
110     if errorlevel 1 (\r
111       if "%OS%" == "Windows_NT" endlocal\r
112       exit /B 2\r
113     )\r
114   )\r
115 \r
116   rem Create tool_hugehelp.c\r
117   echo * %CD%\src\tool_hugehelp.c\r
118   call :genHugeHelp\r
119   if errorlevel 2 (\r
120     if "%OS%" == "Windows_NT" endlocal\r
121     exit /B 3\r
122   )\r
123   if errorlevel 1 (\r
124     set BASIC_HUGEHELP=1\r
125   )\r
126   cmd /c exit 0\r
127 \r
128   rem Setup c-ares git tree\r
129   if exist ares\buildconf.bat (\r
130     echo.\r
131     echo Configuring c-ares build environment\r
132     cd ares\r
133     call buildconf.bat\r
134     cd ..\r
135   )\r
136 \r
137   if "%BASIC_HUGEHELP%" == "1" (\r
138     if "%OS%" == "Windows_NT" endlocal\r
139     exit /B 1\r
140   )\r
141 \r
142   if "%OS%" == "Windows_NT" endlocal\r
143   exit /B 0\r
144 \r
145 rem Main clean function.\r
146 rem\r
147 rem Returns:\r
148 rem\r
149 rem 0 - success\r
150 rem 1 - failed to clean Makefile\r
151 rem 2 - failed to clean tool_hugehelp.c\r
152 rem\r
153 :clean\r
154   rem Remove Makefile\r
155   echo * %CD%\Makefile\r
156   if exist Makefile (\r
157     del Makefile 2>NUL\r
158     if exist Makefile (\r
159       exit /B 1\r
160     )\r
161   )\r
162 \r
163   rem Remove tool_hugehelp.c\r
164   echo * %CD%\src\tool_hugehelp.c\r
165   if exist src\tool_hugehelp.c (\r
166     del src\tool_hugehelp.c 2>NUL\r
167     if exist src\tool_hugehelp.c (\r
168       exit /B 2\r
169     )\r
170   )\r
171 \r
172   exit /B\r
173 \r
174 rem Function to generate src\tool_hugehelp.c\r
175 rem\r
176 rem Returns:\r
177 rem\r
178 rem 0 - full tool_hugehelp.c generated\r
179 rem 1 - simplified tool_hugehelp.c\r
180 rem 2 - failure\r
181 rem\r
182 :genHugeHelp\r
183   if "%OS%" == "Windows_NT" setlocal\r
184   set LC_ALL=C\r
185   set ROFFCMD=\r
186   set BASIC=1\r
187 \r
188   if defined HAVE_PERL (\r
189     if defined HAVE_GROFF (\r
190       set ROFFCMD=groff -mtty-char -Tascii -P-c -man\r
191     ) else if defined HAVE_NROFF (\r
192       set ROFFCMD=nroff -c -Tascii -man\r
193     )\r
194   )\r
195 \r
196   if defined ROFFCMD (\r
197     echo #include "tool_setup.h"> src\tool_hugehelp.c\r
198     echo #include "tool_hugehelp.h">> src\tool_hugehelp.c\r
199 \r
200     if defined HAVE_GZIP (\r
201       echo #ifndef HAVE_LIBZ>> src\tool_hugehelp.c\r
202     )\r
203 \r
204     %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl docs\MANUAL >> src\tool_hugehelp.c\r
205     if defined HAVE_GZIP (\r
206       echo #else>> src\tool_hugehelp.c\r
207       %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl -c docs\MANUAL >> src\tool_hugehelp.c\r
208       echo #endif /^* HAVE_LIBZ ^*/>> src\tool_hugehelp.c\r
209     )\r
210 \r
211     set BASIC=0\r
212   ) else (\r
213     if exist src\tool_hugehelp.c.cvs (\r
214       copy /Y src\tool_hugehelp.c.cvs src\tool_hugehelp.c 1>NUL 2>&1\r
215     ) else (\r
216       echo #include "tool_setup.h"> src\tool_hugehelp.c\r
217       echo #include "tool_hugehelp.h">> src\tool_hugehelp.c\r
218       echo.>> src\tool_hugehelp.c\r
219       echo void hugehelp(void^)>> src\tool_hugehelp.c\r
220       echo {>> src\tool_hugehelp.c\r
221       echo #ifdef USE_MANUAL>> src\tool_hugehelp.c\r
222       echo   fputs("Built-in manual not included\n", stdout^);>> src\tool_hugehelp.c\r
223       echo #endif>> src\tool_hugehelp.c\r
224       echo }>> src\tool_hugehelp.c\r
225     )\r
226   )\r
227 \r
228   findstr "/C:void hugehelp(void)" src\tool_hugehelp.c 1>NUL 2>&1\r
229   if errorlevel 1 (\r
230     if "%OS%" == "Windows_NT" endlocal\r
231     exit /B 2\r
232   )\r
233 \r
234   if "%BASIC%" == "1" (\r
235     if "%OS%" == "Windows_NT" endlocal\r
236     exit /B 1\r
237   )\r
238 \r
239   if "%OS%" == "Windows_NT" endlocal\r
240   exit /B 0\r
241 \r
242 rem Function to clean-up local variables under DOS, Windows 3.x and\r
243 rem Windows 9x as setlocal isn't available until Windows NT\r
244 rem\r
245 :dosCleanup\r
246   set MODE=\r
247   set HAVE_GROFF=\r
248   set HAVE_NROFF=\r
249   set HAVE_PERL=\r
250   set HAVE_GZIP=\r
251   set BASIC_HUGEHELP=\r
252   set LC_ALL\r
253   set ROFFCMD=\r
254   set BASIC=\r
255 \r
256   exit /B\r
257 \r
258 :syntax\r
259   rem Display the help\r
260   echo.\r
261   echo Usage: buildconf [-clean]\r
262   echo.\r
263   echo -clean    - Removes the files\r
264   goto error\r
265 \r
266 :unknown\r
267   echo.\r
268   echo Error: Unknown argument '%1'\r
269   goto error\r
270 \r
271 :norepo\r
272   echo.\r
273   echo Error: This batch file should only be used with a curl git repository\r
274   goto error\r
275 \r
276 :nogenmakefile\r
277   echo.\r
278   echo Error: Unable to generate Makefile\r
279   goto error\r
280 \r
281 :nogenhugehelp\r
282   echo.\r
283   echo Error: Unable to generate src\tool_hugehelp.c\r
284   goto error\r
285 \r
286 :nocleanmakefile\r
287   echo.\r
288   echo Error: Unable to clean Makefile\r
289   goto error\r
290 \r
291 :nocleanhugehelp\r
292   echo.\r
293   echo Error: Unable to clean src\tool_hugehelp.c\r
294   goto error\r
295 \r
296 :warning\r
297   echo.\r
298   echo Warning: The curl manual could not be integrated in the source. This means when\r
299   echo you build curl the manual will not be available (curl --man^). Integration of\r
300   echo the manual is not required and a summary of the options will still be available\r
301   echo (curl --help^). To integrate the manual your PATH is required to have\r
302   echo groff/nroff, perl and optionally gzip for compression.\r
303   goto success\r
304 \r
305 :error\r
306   if "%OS%" == "Windows_NT" (\r
307     endlocal\r
308   ) else (\r
309     call :dosCleanup\r
310   )\r
311   exit /B 1\r
312 \r
313 :success\r
314   if "%OS%" == "Windows_NT" (\r
315     endlocal\r
316   ) else (\r
317     call :dosCleanup\r
318   )\r
319   exit /B 0\r