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

Last change on this file since 28097 was 28097, checked in by ak19, 11 years ago

Fixing use of env variable MODE. The silent mode of makegs2.bat was only working so far when used by diffcol because the automatic defaults were correct anyway. Now the MODE var does the correct thing.

File size: 13.6 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
23
[20765]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
[17900]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"
[20745]29set VCVARS=
[17900]30
[20183]31:: Path to Microsoft Platform SDK's SetEnv.cmd -- You can set this variable manually if needed
[20745]32::e.g. set SDK_ENV="C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd"
33set SDK_ENV=
[17900]34
35rem Checking for Winbin and Unzip utility
[27221]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
[17900]45IF NOT EXIST .\bin\windows\*.* GOTO ENDNOWINBIN
[26615]46IF NOT EXIST .\bin\windows\choice32.exe GOTO ENDNOWINBIN
[17900]47
48echo.
49echo.
50echo #### # ###
51echo ## # #
52echo # ### ## ## ### ### ### ## ### ## #
53echo # # # #### #### # # ## # # # # # #### ##
54echo ## # # # # # # # # # # # # # ##
55echo #### # ### ### # # ### ## ## # # ### ####
[18090]56echo (C) 2008, New Zealand Digital Library Project
[17900]57echo.
58echo.
59echo.
60
61
62rem Checking for existance of the packages extracted / zipped
[20183]63IF NOT EXIST .\common-src\packages\windows\crypt\crypt\nul IF NOT EXIST .\common-src\packages\windows\crypt\crypt.zip GOTO ENDNOWINPACK
[17900]64
[22766]65IF NOT EXIST .\common-src\packages\expat\expat* IF NOT EXIST .\common-src\packages\expat\expat*.tar.gz GOTO ENDNOWINPACK
[17900]66
[20183]67:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\nul IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm.zip GOTO ENDNOWINPACK
[17900]68
[20183]69IF NOT EXIST .\common-src\packages\windows\stlport\stlport\nul IF NOT EXIST .\common-src\packages\windows\stlport\stlport.zip GOTO ENDNOWINPACK
[17900]70
[20183]71IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\nul IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv.zip GOTO ENDNOICONV
[17900]72
[18090]73IF NOT EXIST .\common-src\packages\sqlite\sqlite* IF NOT EXIST .\common-src\packages\sqlite\sqlite*.tar.gz GOTO ENDNOSQLITE
74
[27622]75
[28097]76if "%MODE%"=="auto" GOTO UNZIP
[27622]77
[17900]78rem Ask the user to extract now or to directly compile
[18090]79echo Do you want to extract the required packages (Recommended)? This will be the default action in 10 seconds.
[26615]80if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]81 IF errorlevel 2 GOTO COMPILE
82 IF errorlevel 1 GOTO UNZIP
83 IF errorlevel 0 GOTO END
[26615]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)
[17900]89
90:UNZIP
91IF NOT EXIST .\bin\windows\unzip.exe GOTO ENDNOUNZIP
[18090]92IF NOT EXIST .\bin\windows\gunzip.exe GOTO ENDNOUNZIP
93IF NOT EXIST .\bin\windows\tar.exe GOTO ENDNOUNZIP
[17900]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
[22766]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
[17900]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\
[18090]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
[20183]107
108
[17900]109echo.
110echo.
111:COMPILE
112
[27622]113rem Last check if all the packages have been extracted prior to compilation
[17900]114IF NOT EXIST .\common-src\packages\windows\crypt\crypt\*.* GOTO NEEDUNZIP
[22766]115IF NOT EXIST .\common-src\packages\expat\expat* GOTO NEEDUNZIP
[18829]116:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\*.* GOTO NEEDUNZIP
[17900]117IF NOT EXIST .\common-src\packages\windows\stlport\stlport\*.* GOTO NEEDUNZIP
118IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\*.* GOTO NEEDUNZIP
[18090]119IF NOT EXIST .\common-src\packages\sqlite\sqlite* GOTO NEEDUNZIP
[17900]120
[20765]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
[17900]124rem Check some known paths to VCVARS32.BAT
125:: if the user has set VCVARS32 don't look in the default places at all
[20431]126IF NOT %VCVARS%=="" echo ******* VCVARS set, checking for MS Platform SDK...& GOTO SET_SDK
[17900]127
[18034]128:: Visual Studio 2005 Pro --- NOT READY YET
[20183]129IF EXIST "%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" set VCVARS="%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
[18012]130
[17901]131:: Visual Studio 2003 \ VS7
[20183]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"
[17900]133
[17901]134:: Visual Studio 6 \ VS6
[20183]135IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" set VCVARS="%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
[17900]136
137IF %VCVARS%=="" GOTO ENDNOVCVARS32
[20183]138:: Now VCVARS has been set so it can be used when we need it
[17900]139
[20431]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
[20183]144
[20431]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
[20183]158:PROMPT
[28097]159if "%MODE%"=="auto" GOTO WITHALL
[17900]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
[24461]166echo 3. Apache local library (needs Microsoft Platform SDK)
[25525]167echo 4. All
168echo 5. All (with Debugging ON)
169echo 6. Clean (when re-compiling all, do this before step 5)
170echo 7. Quit
[17900]171echo.
172echo Please choose a number from the menu. Otherwise both libraries will be compiled in 15 seconds.
[26615]173if "%1"=="amd64" (.\bin\windows\choice64.exe /N /D 3 /T 15 /C 1234567
[25525]174 IF errorlevel 7 GOTO END
175 IF errorlevel 6 GOTO DOCLEAN
176 IF errorlevel 5 GOTO WITHALLDEBUG
[24461]177 IF errorlevel 4 GOTO WITHALL
178 IF errorlevel 3 GOTO WITHAPACHE
[17900]179 IF errorlevel 2 GOTO WITHOUTLOCALLIB
180 IF errorlevel 1 GOTO WITHLOCALLIB
181 IF errorlevel 0 GOTO END
[26615]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)
[17900]192
[24461]193:DOCLEAN
194echo.
195echo.
196nmake /f win32.mak CLEAN
197GOTO ENDOK
198
[20183]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
203IF 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
204
205nmake /f win32.mak APACHE_HTTPD=1
206GOTO ENDOK
207
208
[17900]209:WITHOUTLOCALLIB
[20183]210echo.
211echo.
[17900]212nmake /f win32.mak
213GOTO ENDOK
214
215:WITHLOCALLIB
[20183]216echo.
217echo.
[17900]218nmake /f win32.mak LOCAL_LIBRARY=1
219GOTO ENDOK
220
[24461]221:WITHALL
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
[20183]225echo.
226echo.
[25525]227nmake /f win32.mak
228nmake /f win32.mak LOCAL_LIBRARY=1
229nmake /f win32.mak APACHE_HTTPD=1
230GOTO ENDOK
231
232:WITHALLDEBUG
233:: Now unpack the custom GS2 apache web server tar.gz file, if not already unpacked
234IF 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
235
236echo.
237echo.
[24461]238nmake /f win32.mak DEBUG=1
239nmake /f win32.mak LOCAL_LIBRARY=1 DEBUG=1
240nmake /f win32.mak APACHE_HTTPD=1 DEBUG=1
[17900]241GOTO ENDOK
242
243:NEEDUNZIP
[28097]244if "%MODE%"=="auto" GOTO ENDNOUNZIP
[17900]245echo.
246echo /!\ Error /!\ - Some or all the packages are not properly extracted.
247echo.
248echo If you wish to compile Greenstone 2 you need to unzip the required packages now.
249echo.
250rem Ask to Unzip the packages now otherwise quit
251echo Do you want to unzip these required packages now? This will be the default action in 10 seconds.
[26615]252if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]253 IF errorlevel 2 GOTO END
254 IF errorlevel 1 GOTO UNZIP
255 IF errorlevel 0 GOTO END
[26615]256) else (.\bin\windows\choice32.exe /T:Y,10 /c:YN
257 IF errorlevel 2 GOTO END
258 IF errorlevel 1 GOTO UNZIP
259 IF errorlevel 0 GOTO END
260)
[17900]261
262:ENDNOWINBIN
263echo.
264echo /!\ Error /!\ - Winbin has not been found.
[27221]265echo (FAILED trying to get it from http://svn.greenstone.org/main/trunk/binaries/windows/bin.)
266echo Winbin is required to get the conversion tools used for importing different types of files.
[27622]267echo For more info please visit this page:
[17900]268echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
269GOTO END
270
271:ENDNOUNZIP
272echo.
[18090]273echo /!\ Error /!\ - Extacting tools are missing.
274echo They are required to extract all packages needed for compilation.
275echo These tools are contained in the Winbin folder, more info on this web page:
[17900]276echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
277GOTO END
278
279:ENDNOWINPACK
280echo.
281echo /!\ Error /!\ - Windows packages are missing.
282echo Some required packages are missing in .\common-src\packages\windows\
283echo Please go to this page for more information on how to get everything:
284echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
285GOTO END
286
[18090]287:ENDNOSQLITE
288echo.
289echo /!\ Error /!\ - SQLite is missing.
290echo Some required packages are missing in .\common-src\packages\sqlite\
291echo Please go to this page for more information on how to get everything:
292echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
293GOTO END
294
[17900]295:ENDNOICONV
296echo.
297echo /!\ Error /!\ - Indexers are missing.
298echo Some required packages are missing in .\common-src\indexers\packages\windows\
299echo Please go to this page for more information on how to get everything:
300echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows
301GOTO END
302
303:ENDNOVCVARS32
304echo.
305echo /!\ Error /!\ - Not able to find 'vcvars32.bat'.
306echo You need Visual Studio to compile the source code but we were
307echo unable to find the file vcvars32.bat in your system.
308echo.
309echo Please edit this bat file and manually set the full path to
310echo vcvars32.bat then run this script again.
311GOTO END
312
[20183]313:ENDNOSDKENV
314echo.
315echo /!\ Error /!\ - Not able to find 'SetEnv.cmd'.
[20431]316echo We were unable to find the SDK file SetEnv.cmd on your system.
317echo You need Microsoft Platform SDK (which is available for free) to compile
318echo up the Apache web server. You also need it if you're working with
319echo Microsoft Visual Studio 8 or higher.
[20183]320echo.
[20431]321echo If you already have it installed, please edit the makegs2.bat file and
322echo manually set the full path to SetEnv.cmd, then run this script again.
323echo If you have an older version of Visual Studio, then you do not need the
324echo Platform SDK and can compile the Web and/or Local libraries up from the
325echo DOS command prompt using:
326echo nmake /f win32.mak
327echo and/or
328echo nmake /f win32.mak LOCAL_LIBRARY=1
[20183]329GOTO END
330
[17900]331:ENDOK
332echo.
333echo Done!
334echo.
335echo This program is free software; you can redistribute it and/or
336echo modify it under the terms of the GNU General Public License
337echo as published by the Free Software Foundation; either version 2
338echo of the License, or (at your option) any later version.
339echo.
340echo This program is distributed in the hope that it will be useful,
341echo but WITHOUT ANY WARRANTY; without even the implied warranty of
342echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
343echo GNU General Public License for more details.
344echo.
345GOTO END
346
[17966]347:END
[24832]348echo.
349echo **** Note that this command prompt has been left in Short-Filename mode.
[26975]350echo **** This can make command line building go weird, so please use a fresh
351echo **** terminal for that.
[24832]352echo.
353popd
Note: See TracBrowser for help on using the repository browser.