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

Revision 24832, 11.5 KB (checked in by ak19, 8 years ago)

1. util.pm's envvar_prepend and append subroutines now escape backslashes for internal regex operations not only for windows but throughout, and the filename_to_regex subroutine also escapes backslashes for all OS now. 2. makegs2.bat prints a warning at the very end to tell the user that the command prompt has been left in shortfilename mode.

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