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.9 by root, Tue Dec 7 20:03:15 2010 UTC vs.
Revision 1.19 by root, Mon Dec 13 17:25:17 2010 UTC

2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in
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
10MKBUNDLE="$STATICPERL/mkbundle"
11
12# perl build variables 10# perl build variables
13PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed
14PERL_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
15PERL_CONFIGURE="" # additional Configure arguments 13PERL_CONFIGURE="" # additional Configure arguments
16PERL_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"
17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 16
19ARCH="$(uname -m)" 17ARCH="$(uname -m)"
20 18
21case "$ARCH" in 19case "$ARCH" in
22 i*86 | x86_64 | amd64 ) 20 i*86 | x86_64 | amd64 )
23 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
24 case "$ARCH" in 23 case "$ARCH" in
25 i*86 ) 24 i*86 )
26 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
27 ;; 26 ;;
28 esac 27 esac
29 ;; 28 ;;
30esac 29esac
31 30
32# -Wl,--gc-sections makes it impossible to check for undefined references 31# -Wl,--gc-sections makes it impossible to check for undefined references
33# 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 :/
34# -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
35PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 34PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 35PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
37 36
38# some configuration options for modules 37# some configuration options for modules
39export PERL_MM_USE_DEFAULT=1 38export PERL_MM_USE_DEFAULT=1
40#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
52postconfigure() { : ; } 51postconfigure() { : ; }
53postbuild() { : ; } 52postbuild() { : ; }
54postinstall() { : ; } 53postinstall() { : ; }
55 54
56# now source user config, if any 55# now source user config, if any
56if [ "$STATICPERLRC" ]; then
57 . "$STATICPERLRC"
58else
57[ -r /etc/staticperlrc ] && . /etc/staticperlrc 59 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
58[ -r ~/.staticperlrc ] && . ~/.staticperlrc 60 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
59[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 61 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
62fi
60 63
61############################################################################# 64#############################################################################
62# support 65# support
66
67MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
68PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
69
70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
71export LC_ALL=C # just to be on the safe side
63 72
64# set version in a way that Makefile.PL can extract 73# set version in a way that Makefile.PL can extract
65VERSION=VERSION; eval \ 74VERSION=VERSION; eval \
66$VERSION=0.1 75$VERSION=0.911
67 76
68BZ2=bz2 77BZ2=bz2
69BZIP2=bzip2 78BZIP2=bzip2
70 79
71fatal() { 80fatal() {
104############################################################################# 113#############################################################################
105# clean 114# clean
106 115
107distclean() { 116distclean() {
108 verblock <<EOF 117 verblock <<EOF
109deleting everything installed by this script 118 deleting everything installed by this script (rm -rf $STATICPERL)
110EOF 119EOF
111 120
112 rm -rf "$STATICPERL" 121 rm -rf "$STATICPERL"
113} 122}
114 123
147 verblock <<EOF 156 verblock <<EOF
148unpacking perl 157unpacking perl
149EOF 158EOF
150 159
151 mkdir -p unpack 160 mkdir -p unpack
152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ 161 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \
153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 162 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION 163 chmod -R u+w unpack/perl-$PERL_VERSION
155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 164 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
156 rmdir -p unpack 165 rmdir -p unpack
157 fi 166 fi
190 -Dusemymalloc=n \ 199 -Dusemymalloc=n \
191 -Uusedl \ 200 -Uusedl \
192 -Uusethreads \ 201 -Uusethreads \
193 -Uuseithreads \ 202 -Uuseithreads \
194 -Uusemultiplicity \ 203 -Uusemultiplicity \
195 -Duseperlio \
196 -Uusesfio \ 204 -Uusesfio \
197 -Uuseshrplib \ 205 -Uuseshrplib \
206 -Dcc="$PERL_CC" \
198 -Dcppflags="$PERL_CPPFLAGS" \ 207 -Dcppflags="$PERL_CPPFLAGS" \
199 -Dccflags="-g2 -fno-strict-aliasing" \ 208 -Dccflags="-g2 -fno-strict-aliasing" \
200 -Doptimize="$PERL_OPTIMIZE" \ 209 -Doptimize="$PERL_OPTIMIZE" \
201 -Dldflags="$PERL_LDFLAGS" \ 210 -Dldflags="$PERL_LDFLAGS" \
202 -Dlibs="$PERL_LIBS" \ 211 -Dlibs="$PERL_LIBS" \
215 -Dpager=/usr/bin/less \ 224 -Dpager=/usr/bin/less \
216 -Demail="$EMAIL" \ 225 -Demail="$EMAIL" \
217 -Dcf_email="$EMAIL" \ 226 -Dcf_email="$EMAIL" \
218 -Dcf_by="$EMAIL" \ 227 -Dcf_by="$EMAIL" \
219 $PERL_CONFIGURE \ 228 $PERL_CONFIGURE \
229 -Duseperlio \
220 -dE || fatal "Configure failed" 230 -dE || fatal "Configure failed"
221 231
222 sedreplace ' 232 sedreplace '
223 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 233 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
224 s/ *-fno-stack-protector */ /g 234 s/ *-fno-stack-protector */ /g
254 verblock <<EOF 264 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 265installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 266to $PERL_PREFIX
257EOF 267EOF
258 268
259 rm -rf "$PERL_PREFIX" 269 ln -sf "perl/bin/" "$STATICPERL/bin"
260 270 ln -sf "perl/lib/" "$STATICPERL/lib"
271
272 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
273 rm -rf "$PERL_PREFIX" # by this rm -rf
274
261 make install || fatal "make install: error while installing" 275 make install || fatal "make install: error while installing"
262 276
263 rcd "$PERL_PREFIX" 277 rcd "$PERL_PREFIX"
264 278
265 # create a "make install" replacement for CPAN 279 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 280 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
267make install UNINST=1 281make || exit
282
268if find blib/arch/auto -type f | grep -q -v .exists; then 283if find blib/arch/auto -type f | grep -q -v .exists; then
269 echo Probably an XS module, rebuilding perl 284 echo Probably an XS module, rebuilding perl
270 make perl 285 if make perl; then
271 rm -f "$PERL_PREFIX"/bin/perl 286 mv perl "$PERL_PREFIX"/bin/perl
272 make -f Makefile.aperl inst_perl
273 make -f Makefile.aperl map_clean 287 make -f Makefile.aperl map_clean
288 else
289 make -f Makefile.aperl map_clean
290 exit 1
291 fi
274fi 292fi
293
294make install UNINST=1
275EOF 295EOF
276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 296 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
277 297
278 # trick CPAN into avoiding ~/.cpan completely 298 # trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 299 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
294 ' || fatal "error while initialising CPAN" 314 ' || fatal "error while initialising CPAN"
295 315
296 touch "$PERL_PREFIX/staticstamp.install" 316 touch "$PERL_PREFIX/staticstamp.install"
297 fi 317 fi
298 318
299 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then 319 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
300 NOCHECK_INSTALL=+ 320 NOCHECK_INSTALL=+
301 instcpan $STATICPERL_MODULES 321 instcpan $STATICPERL_MODULES
302 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 322 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
303 323
304 postinstall || fatal "postinstall hook failed" 324 postinstall || fatal "postinstall hook failed"
355############################################################################# 375#############################################################################
356# main 376# main
357 377
358podusage() { 378podusage() {
359 echo 379 echo
380
360 if [ -e "$PERL_PREFIX/bin/perl" ]; then 381 if [ -e "$PERL_PREFIX/bin/perl" ]; then
361 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 382 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
362 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 383 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
363 2>/dev/null && exit 384 2>/dev/null && exit
364 fi 385 fi
386
365 # try whatever perl we can find 387 # try whatever perl we can find
366 perl -MPod::Usage -e \ 388 perl -MPod::Usage -e \
367 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 389 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
368 2>/dev/null && exit 390 2>/dev/null && exit
369 391
370 fatal "displaying documentation requires a working perl - try '$0 install' first" 392 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
371} 393}
372 394
373usage() { 395usage() {
374 podusage 0 396 podusage 0
375} 397}
385} 407}
386 408
387bundle() { 409bundle() {
388 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 410 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
389 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 411 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
412 CACHE="$STATICPERL/cache"
413 mkdir -p "$CACHE"
390 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 414 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
391} 415}
392 416
393if [ $# -gt 0 ]; then 417if [ $# -gt 0 ]; then
394 while [ $# -gt 0 ]; do 418 while [ $# -gt 0 ]; do
395 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 419 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
396 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 420 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
397 421
398 command="${1#--}"; shift 422 command="${1#--}"; shift
399 case "$command" in 423 case "$command" in
424 version )
425 echo "staticperl version $VERSION"
426 ;;
400 fetch | configure | build | install | clean | distclean) 427 fetch | configure | build | install | clean | distclean)
401 verblock <<EOF
402$command
403EOF
404 ( "$command" ) 428 ( "$command" )
405 ;; 429 ;;
406 instsrc ) 430 instsrc )
407 ( instsrc "$@" ) 431 ( instsrc "$@" )
408 exit 432 exit
422 exit 446 exit
423 ;; 447 ;;
424 mkperl ) 448 mkperl )
425 ( install ) 449 ( install )
426 bundle --perl "$@" 450 bundle --perl "$@"
451 exit
452 ;;
453 mkapp )
454 ( install )
455 bundle --app "$@"
427 exit 456 exit
428 ;; 457 ;;
429 help ) 458 help )
430 podusage 2 459 podusage 2
431 ;; 460 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines