-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·430 lines (362 loc) · 11.6 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#!/bin/bash
#wre help
wrehelp() {
cat <<_WREHELP
\`build.sh' builds the WebGUI Runtime Environment.
Usage: $0 [OPTIONS] [PACKAGES]
Build switches cause only select applications to build.
They can be combined to build only certain apps.
Example: ./build.sh --perl # only perl will be built
./build.sh --perl --nginx # only perl and nginx will build
./build.sh --all # build all (except wdk)
Options:
--all builds all packages
--clean cleans all pre-req folders for a new build
--help displays this screen
Packages: (must be built in the order shown below)
--utilities compiles and installs shared utilities
--perl compiles and installs perl
--nginx compiles and installs nginx
--imagemagick compiles and installs image magick
--perlmodules installs perl modules from cpan
--wre installs WebGUI Runtime Environment scripts and API
_WREHELP
}
#Evaluate options passed by command line
for opt in "$@"
do
#get any argument passed with this option
arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case "$opt" in
--clean)
export WRE_CLEAN=1
;;
--all)
export WRE_BUILD_UTILS=1
export WRE_BUILD_PERL=1
export WRE_BUILD_NGINX=1
export WRE_BUILD_IMAGEMAGICK=1
export WRE_BUILD_AWSTATS=1
export WRE_BUILD_WRE=1
export WRE_BUILD_PM=1
;;
--utils | --utilities)
export WRE_BUILD_UTILS=1
;;
--perl)
export WRE_BUILD_PERL=1
;;
--nginx)
export WRE_BUILD_NGINX=1
;;
--imageMagick | --imagemagick)
export WRE_BUILD_IMAGEMAGICK=1
;;
--wre)
export WRE_BUILD_WRE=1
;;
--perlModules | --perlmodules | --pm)
export WRE_BUILD_PM=1
;;
--help | -help | -h | -? | ?)
wrehelp
exit 0
;;
-*)
echo "Error: I don't know this option: $opt"
echo
wrehelp
exit 1
;;
esac
done
#No arguments passed, display help
if [ $# -eq 0 ]; then
wrehelp
exit 0
fi
if [ -d /data ]; then
# configure environment
. wre/sbin/setenvironment.sh
export WRE_BUILDDIR=`pwd`
export WRE_ROOT=/data/wre
export PREFIX="$WRE_ROOT/prereqs"
export CC="gcc"
export CXX="g++"
export LD="ld"
export CPPFLAGS="-I$PREFIX/include"
export CFLAGS="$CFLAGS -O3 -I$PREFIX/include"
export CXXFLAGS="$CPPFLAGS -O3 -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -L$PREFIX/lib"
export LIBS="-L$PREFIX/lib"
export LD_LIBRARY_PATH="$PREFIX/include"
export PERLCFGOPTS="-Aldflags=\"-L$PREFIX/lib\""
# --cache-file speeds up configure a lot
rm /tmp/Configure.cache
export CFG_CACHE="" #"--cache-file=/tmp/Configure.cache"
# deal with operating system inconsistencies
export WRE_OSNAME=`uname -s`
case $WRE_OSNAME in
FreeBSD | OpenBSD)
export WRE_MAKE=gmake
;;
Linux)
export WRE_MAKE=make
if [ -f /etc/redhat-release ]; then
export WRE_OSTYPE="RedHat"
fi
if [ -f /etc/fedora-release ]; then
export WRE_OSTYPE="Fedora"
fi
if [ -f /etc/slackware-release ] || [ -f /etc/slackware-version ]; then
export WRE_OSTYPE="Slackware"
fi
if [ -f /etc/debian_release ] || [ -f /etc/debian_version ]; then
export WRE_OSTYPE="Debian"
fi
if [ -f /etc/mandrake-release ]; then
export WRE_OSTYPE="Mandrake"
fi
if [ -f /etc/yellowdog-release ]; then
export WRE_OSTYPE="YellowDog"
fi
if [ -f /etc/gentoo-release ]; then
export WRE_OSTYPE="Gentoo"
fi
if [ -f /etc/lsb-release ]; then
export WRE_OSTYPE="Ubuntu"
fi
;;
Darwin)
export WRE_MAKE=make
VERSION=`uname -r | cut -d. -f1`
if [ $VERSION == "10" ]; then
export WRE_OSTYPE="Snow Leopard"
export MACOSX_DEPLOYMENT_TARGET=10.6
export CFLAGS="-m32 -arch i386 -g -Os -pipe -no-cpp-precomp $CFLAGS"
export CCFLAGS="-m32 -arch i386 -g -Os -pipe -no-cpp-precomp $CCFLAGS"
export CXXFLAGS="-m32 -arch i386 -g -Os -pipe $CXXFLAGS"
export LDFLAGS="-m32 -arch i386 -bind_at_load $LDFLAGS"
export CFG_LIBGCRYPT="--disable-asm"
export PERLCFGOPTS="-Ald=\"-m32\" -Accflags=\"-m32\" -Aldflags=\"-m32\" -Acppflags=\"-m32\""
fi
if [ $VERSION == "9" ]; then
export WRE_OSTYPE="Leopard"
fi
if [ $VERSION == "8" ]; then
export WRE_OSTYPE="Tiger"
fi
;;
esac
### Program-specific options
# Perl ./Config options
export PERLCFGOPTS="$PERLCFGOPTS -Dprefix=$PREFIX -des"
# ImageMagick options
case "$WRE_OSNAME" in
FreeBSD | OpenBSD)
export IM_OPTION="--without-threads"
;;
esac
# made folders than don't exist
mkdir -p $PREFIX/man/man1
mkdir -p $PREFIX/conf
mkdir -p $PREFIX/lib
mkdir -p $PREFIX/libexec
mkdir -p $PREFIX/include
mkdir -p $PREFIX/var
mkdir -p $PREFIX/bin
else
echo "You must create a writable /data folder to begin."
exit 0
fi
# error
checkError(){
if [ $1 -ne 0 ];
then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "##############################################"
echo "WRE ERROR: "$2" did not complete successfully."
echo "##############################################"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit
fi
}
printHeader(){
echo "### ----------------------------------- ###"
echo "#### Building $1 "
}
# most programs build the same
# param 1: folder name
# param 2: configure params
# param 3: make install params
# param 4: compiler flags
buildProgram() {
cd $1
printHeader $1
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
echo "Configuring $1 with GNUMAKE=$WRE_MAKE $4 ./configure --prefix=$PREFIX $2"
./configure --prefix=$PREFIX $2; checkError $? "$1 configure"
$WRE_MAKE; checkError $? "$1 make"
$WRE_MAKE install $3; checkError $? "$1 make install"
cd ..
}
# utilities
buildUtils(){
printHeader "Utilities"
cd source
# catdoc
cd catdoc-0.94.2
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
CATDOCARGS="--disable-wordview --without-wish --with-input=utf-8 \
--with-output=utf-8 --disable-charset-check --disable-langinfo"
./configure $CFG_CACHE --prefix=$PREFIX $CATDOCARGS; checkError $? "catdoc Configure"
$WRE_MAKE; checkError $? "catdoc make"
cd src
$WRE_MAKE install; checkError $? "catdoc make install src"
cd ../docs
$WRE_MAKE install; checkError $? "catdoc make install docs"
cd ../charsets
$WRE_MAKE install; checkError $? "catdoc make install charsets"
cd ../..
# xpdf
buildProgram "xpdf-3.03" "$CFG_CACHE --without-x"
cd $WRE_BUILDDIR
}
# perl
buildPerl(){
printHeader "Perl"
cd source/perl-5.14.2
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
./Configure $PERLCFGOPTS; checkError $? "Perl Configure"
$WRE_MAKE; checkError $? "Perl make"
$WRE_MAKE install; checkError $? "Perl make install"
cd $WRE_BUILDDIR
}
# nginx
buildNginx(){
printHeader "nginx"
cd source
cd nginx-1.0.11
#./configure --prefix=$PREFIX --with-pcre=../pcre-8.20 --with-http_ssl_module --with-openssl=../openssl-1.0.0e; checkError $? "nginx Configure"
./configure --prefix=$PREFIX --with-pcre=../pcre-8.20 --with-http_ssl_module; checkError $? "nginx Configure"
$WRE_MAKE; checkError $? "nginx make"
$WRE_MAKE install; checkError $? "nginx make install"
cd $WRE_BUILDDIR
}
# Image Magick
buildImageMagick(){
printHeader "Image Magick"
cd source
# lib xml
buildProgram "libxml2-2.7.7" "$CFG_CACHE"
# lib jpeg
cd jpeg-8c
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
./configure $CFG_CACHE --enable-shared --prefix=$PREFIX; checkError $? "libjpeg Configure"
$WRE_MAKE; checkError $? "libjpeg make"
$WRE_MAKE install; checkError $? "libjpeg make install"
cd ..
# freetype
buildProgram "freetype-2.4.8" "-enable-shared $CFG_CACHE"
# lib ungif
buildProgram "giflib-4.1.6" "--enable-shared $CFG_CACHE"
# lib png
buildProgram "libpng-1.5.10" "--enable-shared $CFG_CACHE"
# graphviz
buildProgram "graphviz-2.24.0" "$CFG_CACHE --enable-static --with-libgd=no --with-mylibgd=no --disable-java --disable-swig --disable-perl --disable-python --disable-php --disable-ruby --disable-sharp --disable-python23 --disable-python24 --disable-python25 --disable-r --disable-tcl --disable-guile --disable-io --disable-lua --disable-ocaml"
ln -s $PREFIX/bin/dot_static $PREFIX/bin/dot
# image magick
cd ImageMagick-* # when you update this version number, update the one below as well
printHeader "Image Magick"
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
GNUMAKE=$WRE_MAKE ./configure LD=ld --enable-delegate-build LDFLAGS=-L$PREFIX/lib CPPFLAGS=-I$PREFIX/include --enable-shared --prefix=$PREFIX --with-jpeg --with-png --with-perl --without-x --with-xml
$WRE_MAKE; checkError $? "Image Magick make"
$WRE_MAKE install; checkError $? "Image Magick make install"
}
# most perl modules are installed the same way
# param1: module directory
# param2: parameters to pass to Makefile.PL
installPerlModule() {
cd $1
printHeader "PM $1 with $2"
if [ "$WRE_CLEAN" == 1 ]; then
$WRE_MAKE distclean
$WRE_MAKE clean
fi
perl Makefile.PL $2 CCFLAGS="$CFLAGS"; checkError $? "$1 Makefile.PL"
$WRE_MAKE; checkError $? "$1 make"
#$WRE_MAKE test; checkError $? "$1 make test"
$WRE_MAKE install; checkError $? "$1 make install"
cd ..
}
installPerlModules () {
printHeader "Perl Modules"
cd source/perlmodules
export PERL_MM_USE_DEFAULT=1 # makes it so perl modules don't ask questions
cpan App::cpanminus
cpanm Task::WebGUI
if [ "$WRE_OSTYPE" != "Leopard" ] && [ "$WRE_OSTYPE" != "Snow Leopard" ]; then
cpanm http://backpan.perl.org/authors/id/D/DU/DURIST/Proc-ProcessTable-0.44.tar.gz
fi
# detecting shared memory properly on 2.6 kernels
if [ "$WRE_OSNAME" == "Linux" ]; then
cpanm Linux::Smaps
fi
cd $WRE_BUILDDIR
}
#wre utils
installWreUtils(){
printHeader "WebGUI Runtime Environment Core and Utilities"
cp -Rf wre /data/
}
# make the WRE distro smaller by getting rid of non-essential stuff
makeItSmall(){
printHeader "Making WRE smaller"
rm -Rf $PREFIX/man
rm -Rf $PREFIX/manual
rm -Rf $PREFIX/README.TXT
rm -Rf $PREFIX/docs
rm -Rf $PREFIX/share/doc
rm -Rf $PREFIX/share/gtk-doc
rm -Rf $PREFIX/share/man
rm -Rf $PREFIX/share/ImageMagick*
rm -Rf $WRE_ROOT/etc/original
rm -Rf $WRE_ROOT/etc/extra
}
#
# build stuff
if [ "$WRE_BUILD_UTILS" == 1 ]; then
buildUtils
fi
if [ "$WRE_BUILD_PERL" == 1 ]; then
buildPerl
fi
if [ "$WRE_BUILD_NGINX" == 1 ]; then
buildNginx
fi
if [ "$WRE_BUILD_IMAGEMAGICK" == 1 ]; then
buildImageMagick
fi
if [ "$WRE_BUILD_PM" == 1 ]; then
installPerlModules
fi
if [ "$WRE_BUILD_WRE" == 1 ]; then
installWreUtils
fi
makeItSmall
printHeader "Complete And Successful"