Blame build.bat

Packit f574b8
@echo off
Packit f574b8
@rem $LynxId: build.bat,v 1.1 2018/02/19 14:54:26 tom Exp $
Packit f574b8
	setlocal
Packit f574b8
	set SSL_DIR=C:\OpenSSL-%TARGET_ARCH%
Packit f574b8

Packit f574b8
if not exist lynx.man     goto :not_lynx
Packit f574b8
if not exist lynx.cfg     goto :not_lynx
Packit f574b8
if not exist makefile.msc goto :not_lynx
Packit f574b8
if not exist make-msc.bat goto :not_lynx
Packit f574b8

Packit f574b8
if "x"=="x%PARTITION%" goto :no_build
Packit f574b8

Packit f574b8
rem The locally-built libraries are in a directory tree which has subfolders
Packit f574b8
rem for each version of Visual Studio.  The OpenSSL directories are in
Packit f574b8
rem a separate location.  Simplify building Lynx by copying the link-libraries
Packit f574b8
rem and DLLs to the build-tree.
Packit f574b8

Packit f574b8
	call :copybin \project\all\%PARTITION%
Packit f574b8
	call :copylib \project\all\%PARTITION%
Packit f574b8

Packit f574b8
	xcopy /f/q lynx.cfg bin
Packit f574b8
	xcopy /f/q samples\lynx.lss bin
Packit f574b8

Packit f574b8
	call :clean
Packit f574b8
	call :build %1
Packit f574b8

Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:no_build
Packit f574b8
	echo The build-tools were not setup
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:not_lynx
Packit f574b8
	echo This is not the Lynx build-directory
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
rem Copy configuration and OpenSSL DLLs to bin-directory to simplify
Packit f574b8
rem ad hoc testing.  The "\com" has some GnuWin32 executables which can be
Packit f574b8
rem used for decompressing temporary files.  Copy those here as well to
Packit f574b8
rem simplify packaging.
Packit f574b8

Packit f574b8
:copybin
Packit f574b8
	setlocal
Packit f574b8
	echo ** Copying files to bin-directory
Packit f574b8
	if not exist bin mkdir bin
Packit f574b8
	cd bin
Packit f574b8
	del /f /q lynx*.*
Packit f574b8
	del /f /q *.dll
Packit f574b8
	del /f /q *.exe
Packit f574b8
	copy %1\dynamic\*.dll .
Packit f574b8
	copy c:\com\bzip2.exe .
Packit f574b8
	copy c:\com\gzip.exe .
Packit f574b8
	call :copy_ssl libeay
Packit f574b8
	call :copy_ssl ssleay
Packit f574b8
	call :copy_ssl libcrypto
Packit f574b8
	call :copy_ssl libssl
Packit f574b8
	call :copy_ssl msvcr
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:copy_ssl
Packit f574b8
	setlocal
Packit f574b8
	set DESTDIR=%CD%
Packit f574b8
	cd %SSL_DIR%
Packit f574b8
	for /f "usebackq" %%i in (`dir /b /s bin`) do xcopy /s /c /f /y %%i\%1*.dll %DESTDIR%
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
rem We could link with locally-built DLLs, but it would complicate
Packit f574b8
rem things unnecessarily, and in the case of the slang library, more
Packit f574b8
rem than double the size of an installer since its DLL is larger than all
Packit f574b8
rem of the other parts of Lynx combined.
Packit f574b8

Packit f574b8
:copylib
Packit f574b8
	setlocal
Packit f574b8
	echo ** Copying files to lib-directory
Packit f574b8
	if not exist lib mkdir lib
Packit f574b8
	cd lib
Packit f574b8
	del /f /q *.lib
Packit f574b8
	del /f /q bzip*.h
Packit f574b8
	del /f /q curs*.h
Packit f574b8
	del /f /q slang*.h
Packit f574b8
	del /f /q z*.h
Packit f574b8
	copy %1\include\* .
Packit f574b8
	copy %1\static\* .
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:clean
Packit f574b8
	setlocal
Packit f574b8
	call make-msc.bat clean
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:build
Packit f574b8
	setlocal
Packit f574b8
	if "x%1"=="x" call :do_default
Packit f574b8
	if not "x%1"=="x" call :do_%1
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:do_all
Packit f574b8
	call :do_default
Packit f574b8
	call :do_sock
Packit f574b8
	call :do_oldssl
Packit f574b8
	call :do_newssl
Packit f574b8
	call :do_cs
Packit f574b8
	call :do_slang
Packit f574b8
	call make-msc clean
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
@rem just for testing
Packit f574b8
:do_default
Packit f574b8
	call :doit bin\lynx-default.exe
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:do_sock
Packit f574b8
	call :doit bin\lynx-sock.exe "OPT_SOCK=yes"
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
rem The "with-openssl" batch-file simplifies some of the task of linking
Packit f574b8
rem with OpenSSL DLLs by setting SSL_LIBS for the appropriate old/new
Packit f574b8
rem filenames.
Packit f574b8

Packit f574b8
:do_oldssl
Packit f574b8
	setlocal
Packit f574b8
	call with-openssl 1.0.2n 0
Packit f574b8
	call :doit bin\lynx-oldssl.exe "OPT_SSL=yes" "OPT_SOCK=yes"
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:do_newssl
Packit f574b8
	setlocal
Packit f574b8
	call with-openssl 1.1.0g 1
Packit f574b8
	call :doit bin\lynx-newssl.exe "OPT_SSL=yes" "OPT_SOCK=yes"
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
@rem for packages
Packit f574b8
:do_cs
Packit f574b8
	call :doit bin\lynx-cs.exe "OPT_SOCK=yes" "OPT_CS=yes"
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:do_slang
Packit f574b8
	call :doit bin\lynx-slang.exe "OPT_SOCK=yes" "SCREEN=slang"
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:do_none
Packit f574b8
	goto :eof
Packit f574b8

Packit f574b8
:doit
Packit f574b8
	setlocal
Packit f574b8
	echo ** START BUILD: %*
Packit f574b8
	set progname=%1
Packit f574b8
	shift
Packit f574b8
	call make-msc clean
Packit f574b8
	echo on
Packit f574b8
	call make-msc "PROGNAME=%progname%" %1 %2 %3 %4 %5 %6 %7 %8 %9
Packit f574b8
	if errorlevel 1 goto :failed
Packit f574b8
	echo ** BUILD-SUCCESS %progname%
Packit f574b8
	echo.
Packit f574b8
	%progname% -version
Packit f574b8
	echo.
Packit f574b8
	endlocal
Packit f574b8
	goto :eof
Packit f574b8
:failed
Packit f574b8
	echo ?? BUILD-FAILURE %progname%
Packit f574b8
	endlocal
Packit f574b8
	goto :eof