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

Last change on this file since 35535 was 35535, checked in by anupama, 3 years ago

Script makegs2.bat to compile GS2 on Windows, also needs to rename PDFv2Plugin.pm to PDFv2Plugin.tmp so GLI can launch without pluginfo.pl -describeall blowing up over the require statement on the pdfboxconverter extension (the extension is needed by v2 plugin). The rk2 release-kit already handled this in the installer, and earlier today makegs2.sh was updated for linux/mac (commit 35534)

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