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

Revision 26975, 12.7 KB (checked in by kjdon, 7 years ago)

added a comment about short filename mode. Building the demo colleciton in a terminal after running makegs2.bat went really weird. All the images were processed as individual images instead of being blocked by HTMLPlugin

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