source: main/trunk/greenstone2/makegs2.bat

Last change on this file was 35703, checked in by davidb, 3 years ago

Introduction/Splicing in of VISUAL_STUDIO_MAJORVERSION to keep GS2 code base in line with recent changes in GS3. Principally related to which source code version of iconv.zip is unzipped by the compilation process, as < VS14 needs different version to >=VS14

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