You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

buildconf.bat 7.6KB

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