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

Revision 20765, 10.5 KB (checked in by ak19, 10 years ago)

Added a variable that can be set to true if the makegs2 script should itself call the scripts SDK's setenv.cmd and Vis Studio's vcvars32.bat. By default the variable is not set and so the environment has to be set up by the user before trying to use makegs2.bat compile. This change was made because the Windows SDK works different from older versions of Platform SDK.

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