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

Last change on this file since 31422 was 31422, checked in by ak19, 7 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.

File size: 14.2 KB
RevLine 
[17900]1@echo off
[24820]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.
[26615]7if "%1"=="amd64" (
8 cmd /c rem
9) else (
10 command /c rem
11)
[24820]12
[27622]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
[17966]20pushd "%CD%"
21CD /D "%~dp0"
[17900]22
[31422]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
[17900]25
[20765]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
[17900]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"
[20745]31set VCVARS=
[17900]32
[20183]33:: Path to Microsoft Platform SDK's SetEnv.cmd -- You can set this variable manually if needed
[20745]34::e.g. set SDK_ENV="C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd"
35set SDK_ENV=
[17900]36
37rem Checking for Winbin and Unzip utility
[27221]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
[17900]47IF NOT EXIST .\bin\windows\*.* GOTO ENDNOWINBIN
[26615]48IF NOT EXIST .\bin\windows\choice32.exe GOTO ENDNOWINBIN
[17900]49
50echo.
51echo.
52echo #### # ###
53echo ## # #
54echo # ### ## ## ### ### ### ## ### ## #
55echo # # # #### #### # # ## # # # # # #### ##
56echo ## # # # # # # # # # # # # # ##
57echo #### # ### ### # # ### ## ## # # ### ####
[18090]58echo (C) 2008, New Zealand Digital Library Project
[17900]59echo.
60echo.
61echo.
62
63
64rem Checking for existance of the packages extracted / zipped
[20183]65IF NOT EXIST .\common-src\packages\windows\crypt\crypt\nul IF NOT EXIST .\common-src\packages\windows\crypt\crypt.zip GOTO ENDNOWINPACK
[17900]66
[22766]67IF NOT EXIST .\common-src\packages\expat\expat* IF NOT EXIST .\common-src\packages\expat\expat*.tar.gz GOTO ENDNOWINPACK
[17900]68
[20183]69:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\nul IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm.zip GOTO ENDNOWINPACK
[17900]70
[20183]71IF NOT EXIST .\common-src\packages\windows\stlport\stlport\nul IF NOT EXIST .\common-src\packages\windows\stlport\stlport.zip GOTO ENDNOWINPACK
[17900]72
[20183]73IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\nul IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv.zip GOTO ENDNOICONV
[17900]74
[18090]75IF NOT EXIST .\common-src\packages\sqlite\sqlite* IF NOT EXIST .\common-src\packages\sqlite\sqlite*.tar.gz GOTO ENDNOSQLITE
76
[27622]77
[28097]78if "%MODE%"=="auto" GOTO UNZIP
[27622]79
[17900]80rem Ask the user to extract now or to directly compile
[18090]81echo Do you want to extract the required packages (Recommended)? This will be the default action in 10 seconds.
[26615]82if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]83 IF errorlevel 2 GOTO COMPILE
84 IF errorlevel 1 GOTO UNZIP
85 IF errorlevel 0 GOTO END
[26615]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)
[17900]91
92:UNZIP
93IF NOT EXIST .\bin\windows\unzip.exe GOTO ENDNOUNZIP
[18090]94IF NOT EXIST .\bin\windows\gunzip.exe GOTO ENDNOUNZIP
95IF NOT EXIST .\bin\windows\tar.exe GOTO ENDNOUNZIP
[17900]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
[22766]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
[17900]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\
[18090]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
[20183]109
110
[17900]111echo.
112echo.
113:COMPILE
114
[27622]115rem Last check if all the packages have been extracted prior to compilation
[17900]116IF NOT EXIST .\common-src\packages\windows\crypt\crypt\*.* GOTO NEEDUNZIP
[22766]117IF NOT EXIST .\common-src\packages\expat\expat* GOTO NEEDUNZIP
[18829]118:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\*.* GOTO NEEDUNZIP
[17900]119IF NOT EXIST .\common-src\packages\windows\stlport\stlport\*.* GOTO NEEDUNZIP
120IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\*.* GOTO NEEDUNZIP
[18090]121IF NOT EXIST .\common-src\packages\sqlite\sqlite* GOTO NEEDUNZIP
[17900]122
[20765]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
[17900]126rem Check some known paths to VCVARS32.BAT
127:: if the user has set VCVARS32 don't look in the default places at all
[20431]128IF NOT %VCVARS%=="" echo ******* VCVARS set, checking for MS Platform SDK...& GOTO SET_SDK
[17900]129
[18034]130:: Visual Studio 2005 Pro --- NOT READY YET
[20183]131IF EXIST "%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" set VCVARS="%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
[18012]132
[17901]133:: Visual Studio 2003 \ VS7
[20183]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"
[17900]135
[17901]136:: Visual Studio 6 \ VS6
[20183]137IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" set VCVARS="%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
[17900]138
139IF %VCVARS%=="" GOTO ENDNOVCVARS32
[20183]140:: Now VCVARS has been set so it can be used when we need it
[17900]141
[20431]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
[20183]146
[20431]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
[20183]160:PROMPT
[28097]161if "%MODE%"=="auto" GOTO WITHALL
[17900]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
[24461]168echo 3. Apache local library (needs Microsoft Platform SDK)
[25525]169echo 4. All
170echo 5. All (with Debugging ON)
171echo 6. Clean (when re-compiling all, do this before step 5)
172echo 7. Quit
[17900]173echo.
174echo Please choose a number from the menu. Otherwise both libraries will be compiled in 15 seconds.
[26615]175if "%1"=="amd64" (.\bin\windows\choice64.exe /N /D 3 /T 15 /C 1234567
[25525]176 IF errorlevel 7 GOTO END
177 IF errorlevel 6 GOTO DOCLEAN
178 IF errorlevel 5 GOTO WITHALLDEBUG
[24461]179 IF errorlevel 4 GOTO WITHALL
180 IF errorlevel 3 GOTO WITHAPACHE
[17900]181 IF errorlevel 2 GOTO WITHOUTLOCALLIB
182 IF errorlevel 1 GOTO WITHLOCALLIB
183 IF errorlevel 0 GOTO END
[26615]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)
[17900]194
[24461]195:DOCLEAN
196echo.
197echo.
198nmake /f win32.mak CLEAN
199GOTO ENDOK
200
[20183]201:WITHAPACHE
202:: Only compile up the Apache web server if we're asked to
[31422]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.
[20183]206
207:: Now unpack the custom GS2 apache web server tar.gz file
[31422]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%
[31421]211)
[20183]212nmake /f win32.mak APACHE_HTTPD=1
213GOTO ENDOK
214
215
[17900]216:WITHOUTLOCALLIB
[20183]217echo.
218echo.
[17900]219nmake /f win32.mak
220GOTO ENDOK
221
222:WITHLOCALLIB
[20183]223echo.
224echo.
[17900]225nmake /f win32.mak LOCAL_LIBRARY=1
226GOTO ENDOK
227
[24461]228:WITHALL
229:: Now unpack the custom GS2 apache web server tar.gz file, if not already unpacked
[31422]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)
[24461]234
[20183]235echo.
236echo.
[25525]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
[31422]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)
[25525]248
249echo.
250echo.
[24461]251nmake /f win32.mak DEBUG=1
252nmake /f win32.mak LOCAL_LIBRARY=1 DEBUG=1
253nmake /f win32.mak APACHE_HTTPD=1 DEBUG=1
[17900]254GOTO ENDOK
255
256:NEEDUNZIP
[28097]257if "%MODE%"=="auto" GOTO ENDNOUNZIP
[17900]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.
[26615]265if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]266 IF errorlevel 2 GOTO END
267 IF errorlevel 1 GOTO UNZIP
268 IF errorlevel 0 GOTO END
[26615]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)
[17900]274
275:ENDNOWINBIN
276echo.
277echo /!\ Error /!\ - Winbin has not been found.
[27221]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.
[27622]280echo For more info please visit this page:
[17900]281echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
282GOTO END
283
284:ENDNOUNZIP
285echo.
[18090]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:
[17900]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
[18090]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
[17900]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
[20183]326:ENDNOSDKENV
327echo.
328echo /!\ Error /!\ - Not able to find 'SetEnv.cmd'.
[20431]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.
[20183]333echo.
[20431]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
[20183]342GOTO END
343
[17900]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
[17966]360:END
[24832]361echo.
362echo **** Note that this command prompt has been left in Short-Filename mode.
[26975]363echo **** This can make command line building go weird, so please use a fresh
364echo **** terminal for that.
[24832]365echo.
366popd
Note: See TracBrowser for help on using the repository browser.