buildconf.bat 7.5 KB

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