summaryrefslogtreecommitdiffstats
path: root/build.bat
blob: cff8e6d13bdd804a0414d3bd93e97561197559e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
@echo off
@rem $LynxId: build.bat,v 1.1 2018/02/19 14:54:26 tom Exp $
	setlocal
	set SSL_DIR=C:\OpenSSL-%TARGET_ARCH%

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

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

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

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

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

	call :clean
	call :build %1

	goto :eof

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

:do_none
	goto :eof

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