buildconf.bat 7.5 KB

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