Commit 0cc0b7e2 authored by Steve Holme's avatar Steve Holme
Browse files

buildconf.bat: Added full generation of src\tool_hugehelp.c

Added support for generating the full man page based on code from
generate.bat.
parent aa9ead36
Loading
Loading
Loading
Loading
+113 −14
Original line number Diff line number Diff line
@@ -75,9 +75,11 @@ rem snapshot archives.
    echo Generating prerequisite files

    call :generate
    if errorlevel 3 goto nogencurlbuild
    if errorlevel 2 goto nogenhugehelp
    if errorlevel 1 goto nogenmakefile
    if errorlevel 4 goto nogencurlbuild
    if errorlevel 3 goto nogenhugehelp
    if errorlevel 2 goto nogenmakefile
    if errorlevel 1 goto warning

  ) else (
    echo.
    echo Removing prerequisite files
@@ -95,35 +97,44 @@ rem
rem Returns:
rem
rem 0 - success
rem 1 - failure to generate Makefile
rem 2 - failure to generate tool_hugehelp.c
rem 3 - failure to generate curlbuild.h
rem 1 - success with simplified tool_hugehelp.c 
rem 2 - failure to generate Makefile
rem 3 - failure to generate tool_hugehelp.c
rem 4 - failure to generate curlbuild.h
rem
:generate
  if "%OS%" == "Windows_NT" setlocal
  set BASIC_HUGEHELP=0

  rem create Makefile
  if exist Makefile.dist (
    echo * %CD%\Makefile
    copy /Y Makefile.dist Makefile 1>NUL 2>&1
    if errorlevel 1 (
      exit /B 1
      if "%OS%" == "Windows_NT" endlocal
      exit /B 2
    )
  )

  rem create tool_hugehelp.c
  if exist src\tool_hugehelp.c.cvs (
  echo * %CD%\src\tool_hugehelp.c
    copy /Y src\tool_hugehelp.c.cvs src\tool_hugehelp.c 1>NUL 2>&1
    if errorlevel 1 (
      exit /B 2
  call :genHugeHelp
  if errorlevel 2 (
    if "%OS%" == "Windows_NT" endlocal
    exit /B 3
  )
  if errorlevel 1 (
    set BASIC_HUGEHELP=1
  )
  cmd /c exit 0

  rem create curlbuild.h
  if exist include\curl\curlbuild.h.dist (
    echo * %CD%\include\curl\curlbuild.h
    copy /Y include\curl\curlbuild.h.dist include\curl\curlbuild.h 1>NUL 2>&1
    if errorlevel 1 (
      exit /B 3
      if "%OS%" == "Windows_NT" endlocal
      exit /B 4
    )
  )

@@ -136,6 +147,12 @@ rem
    cd ..
  )

  if "%BASIC_HUGEHELP%" == "1" (
    if "%OS%" == "Windows_NT" endlocal
    exit /B 1
  )

  if "%OS%" == "Windows_NT" endlocal
  exit /B 0

rem Main clean function.
@@ -169,9 +186,77 @@ rem
    del include\curl\curlbuild.h 2>NUL
    if exist include\curl\curlbuild.h (
      exit /B 3
    /)
  )

  exit /B

rem Function to generate src\tool_hugehelp.c
rem
rem Returns:
rem
rem 0 - full tool_hugehelp.c generated
rem 1 - simplified tool_hugehelp.c
rem 2 - failure
rem
:genHugeHelp
  if "%OS%" == "Windows_NT" setlocal
  set LC_ALL=C
  set ROFFCMD=
  set BASIC=1

  if defined HAVE_PERL (
    if defined HAVE_GROFF (
      set ROFFCMD=groff -mtty-char -Tascii -P-c -man
    ) else if defined HAVE_NROFF (
      set ROFFCMD=nroff -c -Tascii -man
    )
  )

  if defined ROFFCMD (
    echo #include "tool_setup.h"> src\tool_hugehelp.c
    echo #include "tool_hugehelp.h">> src\tool_hugehelp.c 

    if defined HAVE_GZIP (
      echo #ifndef HAVE_LIBZ>> src\tool_hugehelp.c
    )

    %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl docs\MANUAL >> src\tool_hugehelp.c
    if defined HAVE_GZIP (
      echo #else>> src\tool_hugehelp.c
      %ROFFCMD% docs\curl.1 2>NUL | perl src\mkhelp.pl -c docs\MANUAL >> src\tool_hugehelp.c
      echo #endif /^* HAVE_LIBZ ^*/>> src\tool_hugehelp.c
    )

    set BASIC=0
  ) else (
    if exist src\tool_hugehelp.c.cvs (
      copy /Y src\tool_hugehelp.c.cvs src\tool_hugehelp.c 1>NUL 2>&1
    ) else (
      echo #include "tool_setup.h"> src\tool_hugehelp.c
      echo #include "tool_hugehelp.hd">> src\tool_hugehelp.c
      echo.>> src\tool_hugehelp.c
      echo void hugehelp(void^)>> src\tool_hugehelp.c
      echo {>> src\tool_hugehelp.c
      echo #ifdef USE_MANUAL>> src\tool_hugehelp.c
      echo   fputs("Built-in manual not included\n", stdout^);>> src\tool_hugehelp.c
      echo #endif>> src\tool_hugehelp.c
      echo }>> src\tool_hugehelp.c
    )
  )

  findstr "/C:void hugehelp(void)" src\tool_hugehelp.c 1>NUL 2>&1
  if errorlevel 1 (
    if "%OS%" == "Windows_NT" endlocal
    exit /B 2
  )

  if "%BASIC%" == "1" (
    if "%OS%" == "Windows_NT" endlocal
    exit /B 1
  )

  if "%OS%" == "Windows_NT" endlocal
  exit /B 0

rem Function to clean-up local variables under DOS, Windows 3.x and
@@ -183,6 +268,10 @@ rem
  set HAVE_NROFF=
  set HAVE_PERL=
  set HAVE_GZIP=
  set BASIC_HUGEHELP=
  set LC_ALL
  set ROFFCMD=
  set BASIC=

  exit /B

@@ -234,6 +323,16 @@ rem
  echo Error: Unable to clean include\curl\curlbuild.h
  goto error

:warning
  echo.
  echo Warning: The curl manual could not be integrated in the source. This means when
  echo you build curl the manual will not be available (curl --man^). Integration of
  echo the manual is not required and a summary of the options will still be available
  echo (curl --help^). To integrate the manual your PATH is required to have
  echo groff/nroff, perl and optionally gzip for compression.
  echo.
  goto success

:error
  if "%OS%" == "Windows_NT" (
    endlocal