summaryrefslogtreecommitdiff
path: root/build.bat
blob: 2a1038c8185ca63bfb5eb7835db79a47a12a292e (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
@echo OFF
rem $Id: build.bat 14098 2005-10-03 18:54:13Z jpf@u.washington.edu $
rem ========================================================================
rem Copyright 2006-2007 University of Washington
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem ========================================================================

rem These are the default values, which we might override below
rem by setting them to older versions

rem Default flags. These are in effect when openssl and libressl are disabled.
set MESSAGE=Not including OPENSSL or LIBRESSL support
set sslflags=
set ssllibes=
set sslextralibes="crypt32.lib"

if "%1"=="" goto blank
if "%1"=="wnt" goto wnt
if "%1"=="wxp" goto wxp
if "%1"=="w2k" goto w2k
if "%1"=="clean" goto clean
echo Unknown build command: %1 %2 %3 %4
goto usage
:blank
echo Must specify build command!
:usage
echo usage: BUILD cmd
echo   where "cmd" is one of either:
echo         wnt        -- Windows
echo         wxp        -- Windows XP
echo         w2k        -- Windows with Win2k Kerb
echo         clean      -- to remove obj, lib, and exe files from source
goto fini

:wxp
if not defined ALPINE_LIBRESSL set ALPINE_LIBRESSL=%cd%\libressl
if NOT exist "%ALPINE_LIBRESSL%" goto wntbuild
set MESSAGE=including LIBRESSL support
set CRYPTO_VERSION=41
set SSL_VERSION=43
set TLS_VERSION=15
set windows32build=-DWXPBUILD -D__MINGW_USE_VC2005_COMPAT
set sslflags=-I\"%ALPINE_LIBRESSL%\"\include -I\"%ALPINE_LIBRESSL%\"\include\openssl -DENABLE_WINDOWS_UNIXSSL
set ssllibes=\"%ALPINE_LIBRESSL%\"\x86\libcrypto-%CRYPTO_VERSION%.lib \"%ALPINE_LIBRESSL%\"\x86\libssl-%SSL_VERSION%.lib \"%ALPINE_LIBRESSL%\"\x86\libtls-%TLS_VERSION%.lib
set sslextralibes=
goto wntbuild

:wnt
if not defined ALPINE_OPENSSL set ALPINE_OPENSSL=%cd%\openssl
if NOT exist "%ALPINE_OPENSSL%" goto wntbuild
set MESSAGE=including OPENSSL support
set windows32build=
set sslflags=-I\"%ALPINE_OPENSSL%\"\include\ -I\"%ALPINE_OPENSSL%\"\include\openssl -DENABLE_WINDOWS_UNIXSSL -DOPENSSL_1_1_0
set ssllibes=\"%ALPINE_OPENSSL%\"\lib\libcrypto.lib \"%ALPINE_OPENSSL%\"\lib\libssl.lib 
set sslextralibes=
goto wntbuild

:wntbuild
echo PC-Alpine for Windows/Winsock (Win32) build sequence
set cclntmake=makefile.nt
set alpinemake=makefile.wnt
echo %MESSAGE%
goto ldapincludewnt
:ldapincludewnt
if not defined ALPINE_LDAP set ALPINE_LDAP=%cd%\ldap
if exist "%ALPINE_LDAP%" goto yesldapwnt
echo NOT including LDAP functionality
set ldapinclude=
set ldaplibes=
goto noldapwnt
:yesldapwnt
echo including LDAP functionality
set ldapflags=-I\"%ALPINE_LDAP%\"\inckit -DENABLE_LDAP
set ldaplibes=\"%ALPINE_LDAP%\"\binaries\release\ldap32.lib
:noldapwnt
set extracflagsnq=/DWINVER=0x0501 /Zi -Od %ldapflags% %sslflags% %windows32build% -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DSPCL_REMARKS=\"\\\"\\\"\"
set extralibes="%sslextralibes%"
set extralibesalpine="%ldaplibes% %ssllibes%"
set extrarcflags="/D_PCP_WNT"
set extramakecommand=
goto buildsetup

:w2k
echo Krb5ized PC-Alpine for Windows/Winsock (Win32) build sequence
set cclntmake=makefile.w2k
set alpinemake=makefile.wnt
set sslflags=
set ssllibes=
set sslextralibes="crypt32.lib"
goto ldapincludew2k
:ldapincludew2k
if not defined ALPINE_LDAP set ALPINE_LDAP=%cd%\ldap
if exist "%ALPINE_LDAP%" goto yesldapw2k
echo NOT including LDAP functionality
set ldapinclude=
set ldaplibes=
goto noldapw2k
:yesldapw2k
echo including LDAP functionality
set ldapflags=-I\"%ALPINE_LDAP%\"\inckit -DENABLE_LDAP
set ldaplibes=\"%ALPINE_LDAP%\"\binaries\release\ldap32.lib
:noldapw2k
set extracflagsnq=/DWINVER=0x0501 /Zi -Od %ldapflags% %sslflags% -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DSPCFC_WINVER=\"\\\" 2000\\\"\" -DSPCL_REMARKS=\"\\\" with krb5\\\"\"
set extralibes="secur32.lib %sslextralibes%"
set extralibesalpine="secur32.lib crypt32.lib %ldaplibes% %ssllibes%"
set extrarcflags="/D_PCP_W2K"
set extramakecommand=
goto buildsetup

:clean
echo Sure you want to delete object, library and executable files?!?!
echo If NOT, type Ctrl-C to terminate build script NOW.  Type ENTER if you do.
pause
echo Cleaning alpine, pico, mailutil, mapi, and c-client directories
echo del *.pdb
del /Q alpine\*.pdb
del /Q c-client\*.pdb
del /Q c-client-dll\*.pdb
rem del /Q mailutil\*.pdb
rem del /Q mapi\*.pdb
del /Q pico\*.pdb
del /Q pith\*.pdb
del /Q regex\*.pdb
del /Q alpine\osdep\*.pdb
del /Q pico\osdep\*.pdb
del /Q pith\charconv\*.pdb
del /Q pith\osdep\*.pdb
echo del *.ilk
del /Q alpine\*.ilk
rem del /Q mapi\*.ilk
del /Q pico\*.ilk
del /Q pith\*.ilk
set alpinemake=makefile.wnt
set extramakecommand=clean
if NOT exist c-client goto nocclient
del /Q c-client\*
rmdir c-client
:nocclient
if NOT exist c-client-dll goto nocclientdll
del /Q c-client-dll\*
rmdir c-client-dll
:nocclientdll
set cclntmake=makefile.w2k
goto buildmailutil

:buildsetup
if not exist c-client mkdir c-client
if not defined ALPINE_IMAP set ALPINE_IMAP=imap
echo Copying imap files to c-client directory
copy /Y "%ALPINE_IMAP%"\src\c-client\* c-client\ > garbageout.txt
copy /Y "%ALPINE_IMAP%"\src\charset\* c-client\ > garbageout.txt
copy /Y "%ALPINE_IMAP%"\src\osdep\nt\* c-client\ > garbageout.txt
del garbageout.txt
rem if not exist c-client-dll mkdir c-client-dll
rem copy /Y "%ALPINE_IMAP%"\src\c-client\* c-client-dll\ > garbageout.txt
rem copy /Y "%ALPINE_IMAP%"\src\charset\* c-client-dll\ > garbageout.txt
rem copy /Y "%ALPINE_IMAP%"\src\osdep\nt\* c-client-dll\ > garbageout.txt
rem del garbageout.txt
if not exist mailutil mkdir mailutil
copy /Y "%ALPINE_IMAP%"\src\mailutil\* mailutil\ > garbageout.txt
if defined ALPINE_LIBRESSL del /Q libressl\x86\lib*.lib
if defined ALPINE_LIBRESSL del /Q alpine\lib*.dll
if defined ALPINE_LIBRESSL copy /Y libressl\x86\"%1%"\* libressl\x86\ > garbageout.txt
if defined ALPINE_LIBRESSL copy /Y alpine\DLL\"%1%\"\* alpine\ > garbageout.txt
if defined ALPINE_OPENSSL copy /Y alpine\DLL\openssl\* alpine\ > garbageout.txt
del garbageout.txt
goto build

:build
set extraldflags="/DEBUG /DEBUGTYPE:CV"
set extracflags="%extracflagsnq%"
set extradllcflags="%extracflagsnq% /D_DLL"
goto buildcclnt

:buildcclnt
echo Building c-client...
cd c-client
nmake -nologo -f %cclntmake% EXTRACFLAGS=%extracflags% EXTRALIBES=%extralibes% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto buildmailutil

:buildmailutil
if exist mailutil goto yesbuildmailutil
goto nobuildmailutil
:yesbuildmailutil
echo Building mailutil
cd mailutil
nmake -nologo -f %cclntmake% EXTRACFLAGS=%extracflags% LIBRESSLLIBS="%ssllibes%" %extramakecommand%
if errorlevel 1 goto bogus
cd ..
:nobuildmailutil
goto buildpithosd

:buildpithosd
echo Building pith-osdep...
cd pith\osdep
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% EXTRALIBES=%extralibes% %extramakecommand%
if errorlevel 1 goto bogus
cd ..\..
goto buildpithcc

:buildpithcc
echo Building pith-charconv...
cd pith\charconv
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% EXTRALIBES=%extralibes% %extramakecommand%
if errorlevel 1 goto bogus
cd ..\..
goto buildpith

:buildpith
echo Building pith...
cd pith
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% EXTRALIBES=%extralibes% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto buildregex

:buildregex
echo Building regex...
cd regex
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto buildpicoosd

:buildpicoosd
echo Building pico-osdep...
cd pico\osdep
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..\..
goto buildpico

:buildpico
echo Building pico...
cd pico
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto buildalpineosd

:buildalpineosd
echo Building alpine-osdep...
cd alpine\osdep
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% EXTRARCFLAGS=%extrarcflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..\..
goto buildalpine

:buildalpine
echo Building alpine...
cd alpine
nmake -nologo -f %alpinemake% wnt=1 EXTRACFLAGS=%extracflags% EXTRALIBES=%extralibesalpine% LDAPLIBS=%ldaplibes% EXTRALDFLAGS=%extraldflags% EXTRARCFLAGS=%extrarcflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto nobuildmapi

:buildcclntdll
if NOT exist c-client-dll goto buildmapi
echo Building c-client-dll
cd c-client-dll
nmake -nologo -f %cclntmake% EXTRACFLAGS=%extradllcflags% %extramakecommand%
if errorlevel 1 goto bogus
cd ..
goto buildmapi

:buildmapi
echo Building mapi
cd mapi
nmake -nologo -f makefile EXTRACFLAGS=%extracflags% EXTRALDFLAGS=%extraldflags% LDAPLIBS=%ldaplibes% %extramakecommand%
if errorlevel 1 goto bogus
cd ..

:nobuildmapi
echo Alpine build complete.
goto fini

:bogus
echo Problems building Alpine!

:fini