ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
(Generate patch)

Comparing App-Staticperl/staticperl.sh (file contents):
Revision 1.14 by root, Fri Dec 10 20:29:17 2010 UTC vs.
Revision 1.20 by root, Mon Dec 13 17:35:51 2010 UTC

5 5
6STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
7CPAN=http://mirror.netcologne.de/cpan # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9 9
10
11# perl build variables 10# perl build variables
12PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 11PERL_VERSION=5.12.2 # 5.8.9 is also a good choice
12PERL_CC=cc
13PERL_CONFIGURE="" # additional Configure arguments 13PERL_CONFIGURE="" # additional Configure arguments
14PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 14PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP"
15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
16 16
17ARCH="$(uname -m)" 17ARCH="$(uname -m)"
18 18
19case "$ARCH" in 19case "$ARCH" in
20 i*86 | x86_64 | amd64 ) 20 i*86 | x86_64 | amd64 )
21 PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 21 #PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64
22 PERL_OPTIMIZE="$PERL_OPTIMIZE" # x86/amd64
22 case "$ARCH" in 23 case "$ARCH" in
23 i*86 ) 24 i*86 )
24 PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only 25 PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only
25 ;; 26 ;;
26 esac 27 esac
27 ;; 28 ;;
28esac 29esac
29 30
30# -Wl,--gc-sections makes it impossible to check for undefined references 31# -Wl,--gc-sections makes it impossible to check for undefined references
31# for some reason so we need to patch away the "-no" after Configure and before make :/ 32# for some reason so we need to patch away the "-no" after Configure and before make :/
32# -z muldefs is to work around uclibc's pthread static linking bug 33# --allow-multiple-definition exists to work around uclibc's pthread static linking bug
33PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 34PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
34PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 35PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
35 36
36# some configuration options for modules 37# some configuration options for modules
37export PERL_MM_USE_DEFAULT=1 38export PERL_MM_USE_DEFAULT=1
38#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 39#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
69unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
70export LC_ALL=C # just to be on the safe side 71export LC_ALL=C # just to be on the safe side
71 72
72# set version in a way that Makefile.PL can extract 73# set version in a way that Makefile.PL can extract
73VERSION=VERSION; eval \ 74VERSION=VERSION; eval \
74$VERSION=0.9 75$VERSION=0.911
75 76
76BZ2=bz2 77BZ2=bz2
77BZIP2=bzip2 78BZIP2=bzip2
78 79
79fatal() { 80fatal() {
147 148
148 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 149 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side
149 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 150 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
150 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 151 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
151 || fatal "$URL: unable to download" 152 || fatal "$URL: unable to download"
153 rm -f perl-$PERL_VERSION.tar.$BZ2
152 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 154 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2
153 fi 155 fi
154 156
155 verblock <<EOF 157 verblock <<EOF
156unpacking perl 158unpacking perl
157EOF 159EOF
158 160
159 mkdir -p unpack 161 mkdir -p unpack
162 rm -rf unpack/perl-$PERL_VERSION
160 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ 163 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \
161 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 164 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
162 chmod -R u+w unpack/perl-$PERL_VERSION 165 chmod -R u+w unpack/perl-$PERL_VERSION
163 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 166 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
164 rmdir -p unpack 167 rmdir -p unpack
166} 169}
167 170
168# similar to GNU-sed -i or perl -pi 171# similar to GNU-sed -i or perl -pi
169sedreplace() { 172sedreplace() {
170 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 173 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
174 rm -f "$2"
171 mv "$2~" "$2" 175 mv "$2~" "$2"
172} 176}
173 177
174configure() { 178configure() {
175 fetch 179 fetch
198 -Dusemymalloc=n \ 202 -Dusemymalloc=n \
199 -Uusedl \ 203 -Uusedl \
200 -Uusethreads \ 204 -Uusethreads \
201 -Uuseithreads \ 205 -Uuseithreads \
202 -Uusemultiplicity \ 206 -Uusemultiplicity \
203 -Duseperlio \
204 -Uusesfio \ 207 -Uusesfio \
205 -Uuseshrplib \ 208 -Uuseshrplib \
209 -Dcc="$PERL_CC" \
206 -Dcppflags="$PERL_CPPFLAGS" \ 210 -Dcppflags="$PERL_CPPFLAGS" \
207 -Dccflags="-g2 -fno-strict-aliasing" \ 211 -Dccflags="-g2 -fno-strict-aliasing" \
208 -Doptimize="$PERL_OPTIMIZE" \ 212 -Doptimize="$PERL_OPTIMIZE" \
209 -Dldflags="$PERL_LDFLAGS" \ 213 -Dldflags="$PERL_LDFLAGS" \
210 -Dlibs="$PERL_LIBS" \ 214 -Dlibs="$PERL_LIBS" \
223 -Dpager=/usr/bin/less \ 227 -Dpager=/usr/bin/less \
224 -Demail="$EMAIL" \ 228 -Demail="$EMAIL" \
225 -Dcf_email="$EMAIL" \ 229 -Dcf_email="$EMAIL" \
226 -Dcf_by="$EMAIL" \ 230 -Dcf_by="$EMAIL" \
227 $PERL_CONFIGURE \ 231 $PERL_CONFIGURE \
232 -Duseperlio \
228 -dE || fatal "Configure failed" 233 -dE || fatal "Configure failed"
229 234
230 sedreplace ' 235 sedreplace '
231 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 236 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
232 s/ *-fno-stack-protector */ /g 237 s/ *-fno-stack-protector */ /g
279make || exit 284make || exit
280 285
281if find blib/arch/auto -type f | grep -q -v .exists; then 286if find blib/arch/auto -type f | grep -q -v .exists; then
282 echo Probably an XS module, rebuilding perl 287 echo Probably an XS module, rebuilding perl
283 if make perl; then 288 if make perl; then
284 mv perl "$PERL_PREFIX"/bin/perl 289 mv perl "$PERL_PREFIX"/bin/perl~ \
290 && rm -f "$PERL_PREFIX"/bin/perl \
291 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
285 make -f Makefile.aperl map_clean 292 make -f Makefile.aperl map_clean
286 else 293 else
287 make -f Makefile.aperl map_clean 294 make -f Makefile.aperl map_clean
288 exit 1 295 exit 1
289 fi 296 fi
373############################################################################# 380#############################################################################
374# main 381# main
375 382
376podusage() { 383podusage() {
377 echo 384 echo
385
378 if [ -e "$PERL_PREFIX/bin/perl" ]; then 386 if [ -e "$PERL_PREFIX/bin/perl" ]; then
379 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 387 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
380 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 388 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
381 2>/dev/null && exit 389 2>/dev/null && exit
382 fi 390 fi
391
383 # try whatever perl we can find 392 # try whatever perl we can find
384 perl -MPod::Usage -e \ 393 perl -MPod::Usage -e \
385 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 394 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
386 2>/dev/null && exit 395 2>/dev/null && exit
387 396
388 fatal "displaying documentation requires a working perl - try '$0 install' first" 397 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
389} 398}
390 399
391usage() { 400usage() {
392 podusage 0 401 podusage 0
393} 402}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines