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