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

Revision 28097, 13.6 KB (checked in by ak19, 6 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.

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
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
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"
29set 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"
33set SDK_ENV=
34
35rem Checking for Winbin and Unzip utility
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
45IF NOT EXIST .\bin\windows\*.* GOTO ENDNOWINBIN
46IF NOT EXIST .\bin\windows\choice32.exe GOTO ENDNOWINBIN
47
48echo.
49echo.
50echo  ####                        #                  ### 
51echo ##                           #                     #
52echo #     ###  ##   ##  ### ### ###  ##  ###  ##       #
53echo #   # #   #### #### # # ##   #  #  # # # ####    ## 
54echo ##  # #   #    #    # #   #  #  #  # # # #      ##   
55echo  #### #    ###  ### # # ###  ##  ##  # #  ###   ####
56echo   (C) 2008, New Zealand Digital Library Project
57echo.
58echo.
59echo.
60
61
62rem Checking for existance of the packages extracted / zipped
63IF NOT EXIST .\common-src\packages\windows\crypt\crypt\nul IF NOT EXIST .\common-src\packages\windows\crypt\crypt.zip GOTO ENDNOWINPACK
64
65IF 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
69IF NOT EXIST .\common-src\packages\windows\stlport\stlport\nul IF NOT EXIST .\common-src\packages\windows\stlport\stlport.zip GOTO ENDNOWINPACK
70
71IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\nul IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv.zip GOTO ENDNOICONV
72
73IF NOT EXIST .\common-src\packages\sqlite\sqlite* IF NOT EXIST .\common-src\packages\sqlite\sqlite*.tar.gz GOTO ENDNOSQLITE
74
75
76if "%MODE%"=="auto" GOTO UNZIP
77
78rem Ask the user to extract now or to directly compile
79echo Do you want to extract the required packages (Recommended)? This will be the default action in 10 seconds.
80if "%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
91IF NOT EXIST .\bin\windows\unzip.exe GOTO ENDNOUNZIP
92IF NOT EXIST .\bin\windows\gunzip.exe GOTO ENDNOUNZIP
93IF NOT EXIST .\bin\windows\tar.exe GOTO ENDNOUNZIP
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
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
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\
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
107
108
109echo.
110echo.
111:COMPILE
112
113rem Last check if all the packages have been extracted prior to compilation
114IF NOT EXIST .\common-src\packages\windows\crypt\crypt\*.* GOTO NEEDUNZIP
115IF NOT EXIST .\common-src\packages\expat\expat* GOTO NEEDUNZIP
116:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\*.* GOTO NEEDUNZIP
117IF NOT EXIST .\common-src\packages\windows\stlport\stlport\*.* GOTO NEEDUNZIP
118IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\*.* GOTO NEEDUNZIP
119IF 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)
122if not "SET_GS_ENV"=="true" goto :PROMPT
123
124rem Check some known paths to VCVARS32.BAT
125:: if the user has set VCVARS32 don't look in the default places at all
126IF NOT %VCVARS%=="" echo ******* VCVARS set, checking for MS Platform SDK...& GOTO SET_SDK
127
128:: Visual Studio 2005 Pro --- NOT READY YET
129IF 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
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"
133
134:: Visual Studio 6 \ VS6
135IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" set VCVARS="%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
136
137IF %VCVARS%=="" GOTO ENDNOVCVARS32
138:: Now VCVARS has been set so it can be used when we need it
139
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
144
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
158:PROMPT
159if "%MODE%"=="auto" GOTO WITHALL
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
166echo 3. Apache local library (needs Microsoft Platform SDK)
167echo 4. All
168echo 5. All (with Debugging ON)
169echo 6. Clean (when re-compiling all, do this before step 5)
170echo 7. Quit
171echo.
172echo Please choose a number from the menu. Otherwise both libraries will be compiled in 15 seconds.
173if "%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
194echo.
195echo.
196nmake /f win32.mak CLEAN
197GOTO 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
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
209:WITHOUTLOCALLIB
210echo.
211echo.
212nmake /f win32.mak
213GOTO ENDOK
214
215:WITHLOCALLIB
216echo.
217echo.
218nmake /f win32.mak LOCAL_LIBRARY=1
219GOTO ENDOK
220
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
225echo.
226echo.
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.
238nmake /f win32.mak DEBUG=1
239nmake /f win32.mak LOCAL_LIBRARY=1 DEBUG=1
240nmake /f win32.mak APACHE_HTTPD=1 DEBUG=1
241GOTO ENDOK
242
243:NEEDUNZIP
244if "%MODE%"=="auto" GOTO ENDNOUNZIP
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.
252if "%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
263echo.
264echo /!\ Error /!\ - Winbin has not been found.
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.
267echo For more info please visit this page:
268echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
269GOTO END
270
271:ENDNOUNZIP
272echo.
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:
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
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
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
313:ENDNOSDKENV
314echo.
315echo /!\ Error /!\ - Not able to find 'SetEnv.cmd'.
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.
320echo.
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
329GOTO END
330
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
347:END
348echo.
349echo **** Note that this command prompt has been left in Short-Filename mode.
350echo **** This can make command line building go weird, so please use a fresh
351echo **** terminal for that.
352echo.
353popd
Note: See TracBrowser for help on using the browser.