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