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

Revision 31421, 13.9 KB (checked in by ak19, 3 years ago)

New batch file adjust-winmake-files.bat that adjusts the win mak files within an extracted apache httpd 2 in approximately the same way that the release kit does this (changeset 22490), to prevent the race condition that stops GS2 compilation. This script is called from makegs2.bat after extracting the apache httpd, since the makegs2.bat script is not called by the release-kit which does its own regex replacement within the win mak files using custom anttasks.

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