source: main/trunk/greenstone2/makegs2.bat@ 27365

Last change on this file since 27365 was 27221, checked in by kjdon, 11 years ago

Automating svn checkout of winbin so we don't have to do that step manually.

File size: 13.1 KB
Line 
1@echo off
2
3:: http://ss64.com/nt/syntax-args.html
4:: Doing this will make the command prompt go into short filenames mode for this directory.
5:: This will be helpful during compiling if there are spaces (or brackets) in the filepath,
6:: since apache's own batch scripts do not allow for the possibility of spaces or brackets.
7if "%1"=="amd64" (
8 cmd /c rem
9) else (
10 command /c rem
11)
12
13pushd "%CD%"
14CD /D "%~dp0"
15
16
17:: Set this to "true" if this script can attempt to setup the environment for compilation for you (leave empty if you will do it)
18set SET_GS_ENV=
19
20:: Path to VCVARS32.bat -- You can set this variable manually if needed
21:: e.g. set VCVARS="C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
22set VCVARS=
23
24:: Path to Microsoft Platform SDK's SetEnv.cmd -- You can set this variable manually if needed
25::e.g. set SDK_ENV="C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd"
26set SDK_ENV=
27
28rem Checking for Winbin and Unzip utility
29
30:: try getting it from svn
31IF NOT EXIST .\bin\windows\*.* (
32 echo Getting winbin FROM http://svn.greenstone.org/main/trunk/binaries/windows/bin INTO bin/windows
33 cd bin
34 svn co http://svn.greenstone.org/main/trunk/binaries/windows/bin windows
35 cd ..
36)
37
38IF NOT EXIST .\bin\windows\*.* GOTO ENDNOWINBIN
39IF NOT EXIST .\bin\windows\choice32.exe GOTO ENDNOWINBIN
40
41echo.
42echo.
43echo #### # ###
44echo ## # #
45echo # ### ## ## ### ### ### ## ### ## #
46echo # # # #### #### # # ## # # # # # #### ##
47echo ## # # # # # # # # # # # # # ##
48echo #### # ### ### # # ### ## ## # # ### ####
49echo (C) 2008, New Zealand Digital Library Project
50echo.
51echo.
52echo.
53
54
55rem Checking for existance of the packages extracted / zipped
56IF NOT EXIST .\common-src\packages\windows\crypt\crypt\nul IF NOT EXIST .\common-src\packages\windows\crypt\crypt.zip GOTO ENDNOWINPACK
57
58IF NOT EXIST .\common-src\packages\expat\expat* IF NOT EXIST .\common-src\packages\expat\expat*.tar.gz GOTO ENDNOWINPACK
59
60:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\nul IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm.zip GOTO ENDNOWINPACK
61
62IF NOT EXIST .\common-src\packages\windows\stlport\stlport\nul IF NOT EXIST .\common-src\packages\windows\stlport\stlport.zip GOTO ENDNOWINPACK
63
64IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\nul IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv.zip GOTO ENDNOICONV
65
66IF NOT EXIST .\common-src\packages\sqlite\sqlite* IF NOT EXIST .\common-src\packages\sqlite\sqlite*.tar.gz GOTO ENDNOSQLITE
67
68rem Ask the user to extract now or to directly compile
69echo Do you want to extract the required packages (Recommended)? This will be the default action in 10 seconds.
70if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
71 IF errorlevel 2 GOTO COMPILE
72 IF errorlevel 1 GOTO UNZIP
73 IF errorlevel 0 GOTO END
74) else (.\bin\windows\choice32.exe /T:Y,10 /C:YN
75 IF errorlevel 2 GOTO COMPILE
76 IF errorlevel 1 GOTO UNZIP
77 IF errorlevel 0 GOTO END
78)
79
80:UNZIP
81IF NOT EXIST .\bin\windows\unzip.exe GOTO ENDNOUNZIP
82IF NOT EXIST .\bin\windows\gunzip.exe GOTO ENDNOUNZIP
83IF NOT EXIST .\bin\windows\tar.exe GOTO ENDNOUNZIP
84
85rem Extracting the packages
86IF EXIST .\common-src\packages\windows\crypt\crypt.zip .\bin\windows\unzip.exe -o .\common-src\packages\windows\crypt\crypt.zip -d .\common-src\packages\windows\crypt\
87
88IF EXIST .\common-src\packages\expat\expat*.tar.gz .\bin\windows\gunzip.exe -cd .\common-src\packages\expat\expat*.tar.gz | .\bin\windows\tar.exe xv --directory=./common-src/packages/expat
89
90IF EXIST .\common-src\packages\windows\gdbm\gdbm.zip .\bin\windows\unzip.exe -o .\common-src\packages\windows\gdbm\gdbm.zip -d .\common-src\packages\windows\gdbm\
91
92IF EXIST .\common-src\packages\windows\stlport\stlport.zip .\bin\windows\unzip.exe -o .\common-src\packages\windows\stlport\stlport.zip -d .\common-src\packages\windows\stlport\
93
94IF EXIST .\common-src\indexers\packages\windows\iconv\iconv.zip .\bin\windows\unzip.exe -o .\common-src\indexers\packages\windows\iconv\iconv.zip -d .\common-src\indexers\packages\windows\iconv\
95
96IF EXIST .\common-src\packages\sqlite\sqlite*.tar.gz .\bin\windows\gunzip.exe -cd .\common-src\packages\sqlite\sqlite*.tar.gz | .\bin\windows\tar.exe xv --directory=./common-src/packages/sqlite
97
98
99echo.
100echo.
101:COMPILE
102
103rem Last check if all the packages have been extracted prior compilation
104IF NOT EXIST .\common-src\packages\windows\crypt\crypt\*.* GOTO NEEDUNZIP
105IF NOT EXIST .\common-src\packages\expat\expat* GOTO NEEDUNZIP
106:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\*.* GOTO NEEDUNZIP
107IF NOT EXIST .\common-src\packages\windows\stlport\stlport\*.* GOTO NEEDUNZIP
108IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\*.* GOTO NEEDUNZIP
109IF NOT EXIST .\common-src\packages\sqlite\sqlite* GOTO NEEDUNZIP
110
111:: Do nothing if we are not to set the environment for compiling in this file (if it was set before)
112if not "SET_GS_ENV"=="true" goto :PROMPT
113
114rem Check some known paths to VCVARS32.BAT
115:: if the user has set VCVARS32 don't look in the default places at all
116IF NOT %VCVARS%=="" echo ******* VCVARS set, checking for MS Platform SDK...& GOTO SET_SDK
117
118:: Visual Studio 2005 Pro --- NOT READY YET
119IF EXIST "%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" set VCVARS="%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
120
121:: Visual Studio 2003 \ VS7
122IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat" set VCVARS="%programfiles%\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat"
123
124:: Visual Studio 6 \ VS6
125IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" set VCVARS="%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
126
127IF %VCVARS%=="" GOTO ENDNOVCVARS32
128:: Now VCVARS has been set so it can be used when we need it
129
130:SET_SDK
131rem Check known path(s) to SetEnv.cmd
132:: if the user has set SDK_ENV don't look in the default places at all
133IF NOT %SDK_ENV%=="" GOTO CALL_SDK
134
135IF EXIST "%programfiles%\Microsoft Platform SDK\SetEnv.cmd" set SDK_ENV="%programfiles%\Microsoft Platform SDK\SetEnv.cmd"
136
137IF %SDK_ENV%=="" GOTO ENDNOSDKENV
138
139:CALL_SDK
140call %SDK_ENV%
141echo.
142echo.
143
144call %VCVARS%
145echo.
146echo.
147
148:PROMPT
149echo.
150rem Ask the user what to compile
151echo What do you want to compile?
152echo.
153echo 1. Local library only
154echo 2. Web library only
155echo 3. Apache local library (needs Microsoft Platform SDK)
156echo 4. All
157echo 5. All (with Debugging ON)
158echo 6. Clean (when re-compiling all, do this before step 5)
159echo 7. Quit
160echo.
161echo Please choose a number from the menu. Otherwise both libraries will be compiled in 15 seconds.
162if "%1"=="amd64" (.\bin\windows\choice64.exe /N /D 3 /T 15 /C 1234567
163 IF errorlevel 7 GOTO END
164 IF errorlevel 6 GOTO DOCLEAN
165 IF errorlevel 5 GOTO WITHALLDEBUG
166 IF errorlevel 4 GOTO WITHALL
167 IF errorlevel 3 GOTO WITHAPACHE
168 IF errorlevel 2 GOTO WITHOUTLOCALLIB
169 IF errorlevel 1 GOTO WITHLOCALLIB
170 IF errorlevel 0 GOTO END
171) else (.\bin\windows\choice32.exe /N /T:3,15 /C:1234567
172 IF errorlevel 7 GOTO END
173 IF errorlevel 6 GOTO DOCLEAN
174 IF errorlevel 5 GOTO WITHALLDEBUG
175 IF errorlevel 4 GOTO WITHALL
176 IF errorlevel 3 GOTO WITHAPACHE
177 IF errorlevel 2 GOTO WITHOUTLOCALLIB
178 IF errorlevel 1 GOTO WITHLOCALLIB
179 IF errorlevel 0 GOTO END
180)
181
182:DOCLEAN
183echo.
184echo.
185nmake /f win32.mak CLEAN
186GOTO ENDOK
187
188:WITHAPACHE
189:: Only compile up the Apache web server if we're asked to
190
191:: Now unpack the custom GS2 apache web server tar.gz file
192IF NOT EXIST .\runtime-src\packages\apache-httpd\httpd-2.2.11\nul .\bin\windows\gunzip.exe -cd .\runtime-src\packages\apache-httpd\httpd-*.tar.gz | .\bin\windows\tar.exe xv --directory=./runtime-src/packages/apache-httpd
193
194nmake /f win32.mak APACHE_HTTPD=1
195GOTO ENDOK
196
197
198:WITHOUTLOCALLIB
199echo.
200echo.
201nmake /f win32.mak
202GOTO ENDOK
203
204:WITHLOCALLIB
205echo.
206echo.
207nmake /f win32.mak LOCAL_LIBRARY=1
208GOTO ENDOK
209
210:WITHALL
211:: Now unpack the custom GS2 apache web server tar.gz file, if not already unpacked
212IF NOT EXIST .\runtime-src\packages\apache-httpd\httpd-2.2.11\nul .\bin\windows\gunzip.exe -cd .\runtime-src\packages\apache-httpd\httpd-*.tar.gz | .\bin\windows\tar.exe xv --directory=./runtime-src/packages/apache-httpd
213
214echo.
215echo.
216nmake /f win32.mak
217nmake /f win32.mak LOCAL_LIBRARY=1
218nmake /f win32.mak APACHE_HTTPD=1
219GOTO ENDOK
220
221:WITHALLDEBUG
222:: Now unpack the custom GS2 apache web server tar.gz file, if not already unpacked
223IF NOT EXIST .\runtime-src\packages\apache-httpd\httpd-2.2.11\nul .\bin\windows\gunzip.exe -cd .\runtime-src\packages\apache-httpd\httpd-*.tar.gz | .\bin\windows\tar.exe xv --directory=./runtime-src/packages/apache-httpd
224
225echo.
226echo.
227nmake /f win32.mak DEBUG=1
228nmake /f win32.mak LOCAL_LIBRARY=1 DEBUG=1
229nmake /f win32.mak APACHE_HTTPD=1 DEBUG=1
230GOTO ENDOK
231
232:NEEDUNZIP
233echo.
234echo /!\ Error /!\ - Some or all the packages are not properly extracted.
235echo.
236echo If you wish to compile Greenstone 2 you need to unzip the required packages now.
237echo.
238rem Ask to Unzip the packages now otherwise quit
239echo Do you want to unzip these required packages now? This will be the default action in 10 seconds.
240if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
241 IF errorlevel 2 GOTO END
242 IF errorlevel 1 GOTO UNZIP
243 IF errorlevel 0 GOTO END
244) else (.\bin\windows\choice32.exe /T:Y,10 /c:YN
245 IF errorlevel 2 GOTO END
246 IF errorlevel 1 GOTO UNZIP
247 IF errorlevel 0 GOTO END
248)
249
250:ENDNOWINBIN
251echo.
252echo /!\ Error /!\ - Winbin has not been found.
253echo (FAILED trying to get it from http://svn.greenstone.org/main/trunk/binaries/windows/bin.)
254echo Winbin is required to get the conversion tools used for importing different types of files.
255echo For more info please visit this page
256echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
257GOTO END
258
259:ENDNOUNZIP
260echo.
261echo /!\ Error /!\ - Extacting tools are missing.
262echo They are required to extract all packages needed for compilation.
263echo These tools are contained in the Winbin folder, more info on this web page:
264echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
265GOTO END
266
267:ENDNOWINPACK
268echo.
269echo /!\ Error /!\ - Windows packages are missing.
270echo Some required packages are missing in .\common-src\packages\windows\
271echo Please go to this page for more information on how to get everything:
272echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
273GOTO END
274
275:ENDNOSQLITE
276echo.
277echo /!\ Error /!\ - SQLite is missing.
278echo Some required packages are missing in .\common-src\packages\sqlite\
279echo Please go to this page for more information on how to get everything:
280echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
281GOTO END
282
283:ENDNOICONV
284echo.
285echo /!\ Error /!\ - Indexers are missing.
286echo Some required packages are missing in .\common-src\indexers\packages\windows\
287echo Please go to this page for more information on how to get everything:
288echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
289GOTO END
290
291:ENDNOVCVARS32
292echo.
293echo /!\ Error /!\ - Not able to find 'vcvars32.bat'.
294echo You need Visual Studio to compile the source code but we were
295echo unable to find the file vcvars32.bat in your system.
296echo.
297echo Please edit this bat file and manually set the full path to
298echo vcvars32.bat then run this script again.
299GOTO END
300
301:ENDNOSDKENV
302echo.
303echo /!\ Error /!\ - Not able to find 'SetEnv.cmd'.
304echo We were unable to find the SDK file SetEnv.cmd on your system.
305echo You need Microsoft Platform SDK (which is available for free) to compile
306echo up the Apache web server. You also need it if you're working with
307echo Microsoft Visual Studio 8 or higher.
308echo.
309echo If you already have it installed, please edit the makegs2.bat file and
310echo manually set the full path to SetEnv.cmd, then run this script again.
311echo If you have an older version of Visual Studio, then you do not need the
312echo Platform SDK and can compile the Web and/or Local libraries up from the
313echo DOS command prompt using:
314echo nmake /f win32.mak
315echo and/or
316echo nmake /f win32.mak LOCAL_LIBRARY=1
317GOTO END
318
319:ENDOK
320echo.
321echo Done!
322echo.
323echo This program is free software; you can redistribute it and/or
324echo modify it under the terms of the GNU General Public License
325echo as published by the Free Software Foundation; either version 2
326echo of the License, or (at your option) any later version.
327echo.
328echo This program is distributed in the hope that it will be useful,
329echo but WITHOUT ANY WARRANTY; without even the implied warranty of
330echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
331echo GNU General Public License for more details.
332echo.
333GOTO END
334
335:END
336echo.
337echo **** Note that this command prompt has been left in Short-Filename mode.
338echo **** This can make command line building go weird, so please use a fresh
339echo **** terminal for that.
340echo.
341popd
Note: See TracBrowser for help on using the repository browser.