root/main/trunk/greenstone2/makegs2.bat @ 31998

Revision 31422, 14.2 KB (checked in by ak19, 3 years ago)

Corrections to previous commit: need to CALL the new adjust-winmak-fils.bat script else the current script does not continue from where it left out. Also need to add the calls to the script in 3 batch labels that deal with compiling apache httpd. Using a variable instead of hardcoding the version of apache httpd2.

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