2
0

buildconf.bat 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. @echo off
  2. rem ***************************************************************************
  3. rem * _ _ ____ _
  4. rem * Project ___| | | | _ \| |
  5. rem * / __| | | | |_) | |
  6. rem * | (__| |_| | _ <| |___
  7. rem * \___|\___/|_| \_\_____|
  8. rem *
  9. rem * Copyright (C) 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.md goto norepo
  38. :parseArgs
  39. if "%~1" == "" goto start
  40. if /i "%~1" == "-clean" (
  41. set MODE=CLEAN
  42. ) else if /i "%~1" == "-?" (
  43. goto syntax
  44. ) else if /i "%~1" == "-h" (
  45. goto syntax
  46. ) else if /i "%~1" == "-help" (
  47. goto syntax
  48. ) else (
  49. goto unknown
  50. )
  51. shift & goto parseArgs
  52. :start
  53. if "%MODE%" == "GENERATE" (
  54. echo.
  55. echo Generating prerequisite files
  56. call :generate
  57. if errorlevel 3 goto nogenhugehelp
  58. if errorlevel 2 goto nogenmakefile
  59. if errorlevel 1 goto warning
  60. ) else (
  61. echo.
  62. echo Removing prerequisite files
  63. call :clean
  64. if errorlevel 2 goto nocleanhugehelp
  65. if errorlevel 1 goto nocleanmakefile
  66. )
  67. goto success
  68. rem Main generate function.
  69. rem
  70. rem Returns:
  71. rem
  72. rem 0 - success
  73. rem 1 - success with simplified tool_hugehelp.c
  74. rem 2 - failed to generate Makefile
  75. rem 3 - failed to generate tool_hugehelp.c
  76. rem
  77. :generate
  78. if "%OS%" == "Windows_NT" setlocal
  79. set BASIC_HUGEHELP=0
  80. rem Create Makefile
  81. echo * %CD%\Makefile
  82. if exist Makefile.dist (
  83. copy /Y Makefile.dist Makefile 1>NUL 2>&1
  84. if errorlevel 1 (
  85. if "%OS%" == "Windows_NT" endlocal
  86. exit /B 2
  87. )
  88. )
  89. rem Create tool_hugehelp.c
  90. echo * %CD%\src\tool_hugehelp.c
  91. call :genHugeHelp
  92. if errorlevel 2 (
  93. if "%OS%" == "Windows_NT" endlocal
  94. exit /B 3
  95. )
  96. if errorlevel 1 (
  97. set BASIC_HUGEHELP=1
  98. )
  99. cmd /c exit 0
  100. if "%BASIC_HUGEHELP%" == "1" (
  101. if "%OS%" == "Windows_NT" endlocal
  102. exit /B 1
  103. )
  104. if "%OS%" == "Windows_NT" endlocal
  105. exit /B 0
  106. rem Main clean function.
  107. rem
  108. rem Returns:
  109. rem
  110. rem 0 - success
  111. rem 1 - failed to clean Makefile
  112. rem 2 - failed to clean tool_hugehelp.c
  113. rem
  114. :clean
  115. rem Remove Makefile
  116. echo * %CD%\Makefile
  117. if exist Makefile (
  118. del Makefile 2>NUL
  119. if exist Makefile (
  120. exit /B 1
  121. )
  122. )
  123. rem Remove tool_hugehelp.c
  124. echo * %CD%\src\tool_hugehelp.c
  125. if exist src\tool_hugehelp.c (
  126. del src\tool_hugehelp.c 2>NUL
  127. if exist src\tool_hugehelp.c (
  128. exit /B 2
  129. )
  130. )
  131. exit /B
  132. rem Function to generate src\tool_hugehelp.c
  133. rem
  134. rem Returns:
  135. rem
  136. rem 0 - full tool_hugehelp.c generated
  137. rem 1 - simplified tool_hugehelp.c
  138. rem 2 - failure
  139. rem
  140. :genHugeHelp
  141. if "%OS%" == "Windows_NT" setlocal
  142. set LC_ALL=C
  143. set BASIC=1
  144. if exist src\tool_hugehelp.c.cvs (
  145. copy /Y src\tool_hugehelp.c.cvs src\tool_hugehelp.c 1>NUL 2>&1
  146. ) else (
  147. echo #include "tool_setup.h"> src\tool_hugehelp.c
  148. echo #include "tool_hugehelp.h">> src\tool_hugehelp.c
  149. echo.>> src\tool_hugehelp.c
  150. echo void hugehelp(void^)>> src\tool_hugehelp.c
  151. echo {>> src\tool_hugehelp.c
  152. echo #ifdef USE_MANUAL>> src\tool_hugehelp.c
  153. echo fputs("Built-in manual not included\n", stdout^);>> src\tool_hugehelp.c
  154. echo #endif>> src\tool_hugehelp.c
  155. echo }>> src\tool_hugehelp.c
  156. )
  157. findstr "/C:void hugehelp(void)" src\tool_hugehelp.c 1>NUL 2>&1
  158. if errorlevel 1 (
  159. if "%OS%" == "Windows_NT" endlocal
  160. exit /B 2
  161. )
  162. if "%BASIC%" == "1" (
  163. if "%OS%" == "Windows_NT" endlocal
  164. exit /B 1
  165. )
  166. if "%OS%" == "Windows_NT" endlocal
  167. exit /B 0
  168. rem Function to clean-up local variables under DOS, Windows 3.x and
  169. rem Windows 9x as setlocal isn't available until Windows NT
  170. rem
  171. :dosCleanup
  172. set MODE=
  173. set BASIC_HUGEHELP=
  174. set LC_ALL
  175. set BASIC=
  176. exit /B
  177. :syntax
  178. rem Display the help
  179. echo.
  180. echo Usage: buildconf [-clean]
  181. echo.
  182. echo -clean - Removes the files
  183. goto error
  184. :unknown
  185. echo.
  186. echo Error: Unknown argument '%1'
  187. goto error
  188. :norepo
  189. echo.
  190. echo Error: This batch file should only be used with a curl git repository
  191. goto error
  192. :nogenmakefile
  193. echo.
  194. echo Error: Unable to generate Makefile
  195. goto error
  196. :nogenhugehelp
  197. echo.
  198. echo Error: Unable to generate src\tool_hugehelp.c
  199. goto error
  200. :nocleanmakefile
  201. echo.
  202. echo Error: Unable to clean Makefile
  203. goto error
  204. :nocleanhugehelp
  205. echo.
  206. echo Error: Unable to clean src\tool_hugehelp.c
  207. goto error
  208. :warning
  209. echo.
  210. echo Warning: The curl manual could not be integrated in the source. This means when
  211. echo you build curl the manual will not be available (curl --manual^). Integration of
  212. echo the manual is not required and a summary of the options will still be available
  213. echo (curl --help^). To integrate the manual build with configure or cmake.
  214. goto success
  215. :error
  216. if "%OS%" == "Windows_NT" (
  217. endlocal
  218. ) else (
  219. call :dosCleanup
  220. )
  221. exit /B 1
  222. :success
  223. if "%OS%" == "Windows_NT" (
  224. endlocal
  225. ) else (
  226. call :dosCleanup
  227. )
  228. exit /B 0