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

Last change on this file since 36373 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
RevLine 
[17900]1@echo off
[24820]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.
[26615]7if "%1"=="amd64" (
8 cmd /c rem
9) else (
10 command /c rem
11)
[24820]12
[27622]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
[17966]20pushd "%CD%"
21CD /D "%~dp0"
[17900]22
[31422]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
[17900]25
[20765]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
[17900]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"
[20745]31set VCVARS=
[17900]32
[20183]33:: Path to Microsoft Platform SDK's SetEnv.cmd -- You can set this variable manually if needed
[20745]34::e.g. set SDK_ENV="C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd"
35set SDK_ENV=
[17900]36
[35535]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
[17900]41rem Checking for Winbin and Unzip utility
[27221]42
43:: try getting it from svn
44IF NOT EXIST .\bin\windows\*.* (
[35535]45 echo Getting winbin FROM https://svn.greenstone.org/main/trunk/binaries/windows/bin INTO bin/windows
[27221]46 cd bin
[35535]47 svn co https://svn.greenstone.org/main/trunk/binaries/windows/bin windows
[27221]48 cd ..
49)
50
[17900]51IF NOT EXIST .\bin\windows\*.* GOTO ENDNOWINBIN
[26615]52IF NOT EXIST .\bin\windows\choice32.exe GOTO ENDNOWINBIN
[17900]53
54echo.
55echo.
56echo #### # ###
57echo ## # #
58echo # ### ## ## ### ### ### ## ### ## #
59echo # # # #### #### # # ## # # # # # #### ##
60echo ## # # # # # # # # # # # # # ##
61echo #### # ### ### # # ### ## ## # # ### ####
[18090]62echo (C) 2008, New Zealand Digital Library Project
[17900]63echo.
64echo.
65echo.
66
67
68rem Checking for existance of the packages extracted / zipped
[20183]69IF NOT EXIST .\common-src\packages\windows\crypt\crypt\nul IF NOT EXIST .\common-src\packages\windows\crypt\crypt.zip GOTO ENDNOWINPACK
[17900]70
[22766]71IF NOT EXIST .\common-src\packages\expat\expat* IF NOT EXIST .\common-src\packages\expat\expat*.tar.gz GOTO ENDNOWINPACK
[17900]72
[20183]73:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\nul IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm.zip GOTO ENDNOWINPACK
[17900]74
[20183]75IF NOT EXIST .\common-src\packages\windows\stlport\stlport\nul IF NOT EXIST .\common-src\packages\windows\stlport\stlport.zip GOTO ENDNOWINPACK
[17900]76
77
[35703]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
[18090]88IF NOT EXIST .\common-src\packages\sqlite\sqlite* IF NOT EXIST .\common-src\packages\sqlite\sqlite*.tar.gz GOTO ENDNOSQLITE
89
[27622]90
[28097]91if "%MODE%"=="auto" GOTO UNZIP
[27622]92
[17900]93rem Ask the user to extract now or to directly compile
[18090]94echo Do you want to extract the required packages (Recommended)? This will be the default action in 10 seconds.
[26615]95if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]96 IF errorlevel 2 GOTO COMPILE
97 IF errorlevel 1 GOTO UNZIP
98 IF errorlevel 0 GOTO END
[26615]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)
[17900]104
105:UNZIP
106IF NOT EXIST .\bin\windows\unzip.exe GOTO ENDNOUNZIP
[18090]107IF NOT EXIST .\bin\windows\gunzip.exe GOTO ENDNOUNZIP
108IF NOT EXIST .\bin\windows\tar.exe GOTO ENDNOUNZIP
[17900]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
[22766]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
[17900]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
[35703]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\
[18090]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
[20183]122
123
[17900]124echo.
125echo.
126:COMPILE
127
[27622]128rem Last check if all the packages have been extracted prior to compilation
[17900]129IF NOT EXIST .\common-src\packages\windows\crypt\crypt\*.* GOTO NEEDUNZIP
[22766]130IF NOT EXIST .\common-src\packages\expat\expat* GOTO NEEDUNZIP
[18829]131:: IF NOT EXIST .\common-src\packages\windows\gdbm\gdbm\*.* GOTO NEEDUNZIP
[17900]132IF NOT EXIST .\common-src\packages\windows\stlport\stlport\*.* GOTO NEEDUNZIP
133IF NOT EXIST .\common-src\indexers\packages\windows\iconv\iconv\*.* GOTO NEEDUNZIP
[18090]134IF NOT EXIST .\common-src\packages\sqlite\sqlite* GOTO NEEDUNZIP
[17900]135
[20765]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
[17900]139rem Check some known paths to VCVARS32.BAT
140:: if the user has set VCVARS32 don't look in the default places at all
[20431]141IF NOT %VCVARS%=="" echo ******* VCVARS set, checking for MS Platform SDK...& GOTO SET_SDK
[17900]142
[18034]143:: Visual Studio 2005 Pro --- NOT READY YET
[20183]144IF EXIST "%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" set VCVARS="%programfiles%\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
[18012]145
[17901]146:: Visual Studio 2003 \ VS7
[20183]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"
[17900]148
[17901]149:: Visual Studio 6 \ VS6
[20183]150IF %VCVARS%=="" IF EXIST "%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT" set VCVARS="%programfiles%\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
[17900]151
152IF %VCVARS%=="" GOTO ENDNOVCVARS32
[20183]153:: Now VCVARS has been set so it can be used when we need it
[17900]154
[20431]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
[20183]159
[20431]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
[20183]173:PROMPT
[28097]174if "%MODE%"=="auto" GOTO WITHALL
[17900]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
[24461]181echo 3. Apache local library (needs Microsoft Platform SDK)
[25525]182echo 4. All
183echo 5. All (with Debugging ON)
184echo 6. Clean (when re-compiling all, do this before step 5)
185echo 7. Quit
[17900]186echo.
187echo Please choose a number from the menu. Otherwise both libraries will be compiled in 15 seconds.
[26615]188if "%1"=="amd64" (.\bin\windows\choice64.exe /N /D 3 /T 15 /C 1234567
[25525]189 IF errorlevel 7 GOTO END
190 IF errorlevel 6 GOTO DOCLEAN
191 IF errorlevel 5 GOTO WITHALLDEBUG
[24461]192 IF errorlevel 4 GOTO WITHALL
193 IF errorlevel 3 GOTO WITHAPACHE
[17900]194 IF errorlevel 2 GOTO WITHOUTLOCALLIB
195 IF errorlevel 1 GOTO WITHLOCALLIB
196 IF errorlevel 0 GOTO END
[26615]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)
[17900]207
[24461]208:DOCLEAN
209echo.
210echo.
211nmake /f win32.mak CLEAN
212GOTO ENDOK
213
[20183]214:WITHAPACHE
215:: Only compile up the Apache web server if we're asked to
[31422]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.
[20183]219
220:: Now unpack the custom GS2 apache web server tar.gz file
[31422]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%
[31421]224)
[20183]225nmake /f win32.mak APACHE_HTTPD=1
226GOTO ENDOK
227
228
[17900]229:WITHOUTLOCALLIB
[20183]230echo.
231echo.
[17900]232nmake /f win32.mak
233GOTO ENDOK
234
235:WITHLOCALLIB
[20183]236echo.
237echo.
[17900]238nmake /f win32.mak LOCAL_LIBRARY=1
239GOTO ENDOK
240
[24461]241:WITHALL
242:: Now unpack the custom GS2 apache web server tar.gz file, if not already unpacked
[31422]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)
[24461]247
[20183]248echo.
249echo.
[25525]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
[31422]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)
[25525]261
262echo.
263echo.
[24461]264nmake /f win32.mak DEBUG=1
265nmake /f win32.mak LOCAL_LIBRARY=1 DEBUG=1
266nmake /f win32.mak APACHE_HTTPD=1 DEBUG=1
[17900]267GOTO ENDOK
268
269:NEEDUNZIP
[28097]270if "%MODE%"=="auto" GOTO ENDNOUNZIP
[17900]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.
[26615]278if "%1"=="amd64" (.\bin\windows\choice64.exe /D Y /T 10 /C YN
[17900]279 IF errorlevel 2 GOTO END
280 IF errorlevel 1 GOTO UNZIP
281 IF errorlevel 0 GOTO END
[26615]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)
[17900]287
288:ENDNOWINBIN
289echo.
290echo /!\ Error /!\ - Winbin has not been found.
[27221]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.
[27622]293echo For more info please visit this page:
[17900]294echo http://wiki.greenstone.org/wiki/index.php/Installing_Greenstone_2_from_SVN_source_on_Windows#Getting_winbin
295GOTO END
296
297:ENDNOUNZIP
298echo.
[18090]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:
[17900]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
[18090]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
[17900]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
[20183]339:ENDNOSDKENV
340echo.
341echo /!\ Error /!\ - Not able to find 'SetEnv.cmd'.
[20431]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.
[20183]346echo.
[20431]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
[20183]355GOTO END
356
[17900]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
[17966]373:END
[24832]374echo.
375echo **** Note that this command prompt has been left in Short-Filename mode.
[26975]376echo **** This can make command line building go weird, so please use a fresh
377echo **** terminal for that.
[24832]378echo.
379popd
Note: See TracBrowser for help on using the repository browser.