--- App-Staticperl/staticperl.sh 2010/12/10 20:29:17 1.14 +++ App-Staticperl/staticperl.sh 2011/01/10 14:12:03 1.26 @@ -7,11 +7,12 @@ CPAN=http://mirror.netcologne.de/cpan # which mirror to use EMAIL="read the documentation " - # perl build variables +MAKE=make PERL_VERSION=5.12.2 # 5.8.9 is also a good choice +PERL_CC=cc PERL_CONFIGURE="" # additional Configure arguments -PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" +PERL_CCFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG" PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" ARCH="$(uname -m)" @@ -29,14 +30,15 @@ # -Wl,--gc-sections makes it impossible to check for undefined references # for some reason so we need to patch away the "-no" after Configure and before make :/ -# -z muldefs is to work around uclibc's pthread static linking bug -PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" +# --allow-multiple-definition exists to work around uclibc's pthread static linking bug +PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself # some configuration options for modules -export PERL_MM_USE_DEFAULT=1 -#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow -export EV_EXTRA_DEFS='-DEV_FEATURES=4+8+16+64 -DEV_USE_SELECT=0 -DEV_USE_POLL=1 -DEV_USE_EPOLL=1 -DEV_NO_LOOPS -DEV_COMPAT3=0' +PERL_MM_USE_DEFAULT=1 +#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow +EV_EXTRA_DEFS='-DEV_FEATURES=4+8+16+64 -DEV_USE_SELECT=0 -DEV_USE_POLL=1 -DEV_USE_EPOLL=1 -DEV_NO_LOOPS -DEV_COMPAT3=0' +export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS # which extra modules to install by default from CPAN that are # required by mkbundle @@ -67,11 +69,11 @@ PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG -export LC_ALL=C # just to be on the safe side +LC_ALL=C; export LC_ALL # just to be on the safe side # set version in a way that Makefile.PL can extract VERSION=VERSION; eval \ -$VERSION=0.9 +$VERSION=0.92 BZ2=bz2 BZIP2=bzip2 @@ -127,6 +129,12 @@ rm -rf "$STATICPERL/src/perl-$PERL_VERSION" } +realclean() { + rm -f "$PERL_PREFIX/staticstamp.postinstall" + rm -f "$PERL_PREFIX/staticstamp.install" + rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" +} + fetch() { rcd "$STATICPERL" @@ -146,9 +154,10 @@ EOF rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side - wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ - || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ + curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ + || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ || fatal "$URL: unable to download" + rm -f perl-$PERL_VERSION.tar.$BZ2 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 fi @@ -157,6 +166,7 @@ EOF mkdir -p unpack + rm -rf unpack/perl-$PERL_VERSION $BZIP2 -d "$2~" || fatal "error while running sed" + rm -f "$2" mv "$2~" "$2" } +configure_failure() { + cat </dev/null 2>&1 + "$MAKE" distclean >/dev/null 2>&1 + + sedreplace '/^#define SITELIB/d' config_h.SH - # I hate them + # I hate them for this grep -q -- -fstack-protector Configure && \ sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure @@ -200,11 +239,11 @@ -Uusethreads \ -Uuseithreads \ -Uusemultiplicity \ - -Duseperlio \ -Uusesfio \ -Uuseshrplib \ - -Dcppflags="$PERL_CPPFLAGS" \ - -Dccflags="-g2 -fno-strict-aliasing" \ + -Uinstallusrbinperl \ + -A ccflags=" $PERL_CCFLAGS" \ + -Dcc="$PERL_CC" \ -Doptimize="$PERL_OPTIMIZE" \ -Dldflags="$PERL_LDFLAGS" \ -Dlibs="$PERL_LIBS" \ @@ -215,7 +254,6 @@ -Uusevendorprefix \ -Dsitelib="$PERL_PREFIX/lib" \ -Dsitearch="$PERL_PREFIX/lib" \ - -Usitelibexp \ -Uman1dir \ -Uman3dir \ -Usiteman1dir \ @@ -225,7 +263,8 @@ -Dcf_email="$EMAIL" \ -Dcf_by="$EMAIL" \ $PERL_CONFIGURE \ - -dE || fatal "Configure failed" + -Duseperlio \ + -dE || configure_failure sedreplace ' s/-Wl,--no-gc-sections/-Wl,--gc-sections/g @@ -250,7 +289,7 @@ rm -f "$PERL_PREFIX/staticstamp.install" - make || fatal "make: error while building perl" + "$MAKE" || fatal "make: error while building perl" postbuild || fatal "postbuild hook failed" } @@ -270,26 +309,28 @@ ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten rm -rf "$PERL_PREFIX" # by this rm -rf - make install || fatal "make install: error while installing" + "$MAKE" install || fatal "make install: error while installing" rcd "$PERL_PREFIX" # create a "make install" replacement for CPAN cat >"$PERL_PREFIX"/bin/cpan-make-install </dev/null 2>&1 - make distclean >/dev/null 2>&1 + "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 + "$MAKE" distclean >/dev/null 2>&1 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" - make || fatal "$mod: error building module" + "$MAKE" || fatal "$mod: error building module" "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" - make distclean >/dev/null 2>&1 + "$MAKE" distclean >/dev/null 2>&1 exit 0 ) || exit $? done @@ -375,17 +416,19 @@ podusage() { echo + if [ -e "$PERL_PREFIX/bin/perl" ]; then "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 2>/dev/null && exit fi + # try whatever perl we can find perl -MPod::Usage -e \ 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 2>/dev/null && exit - fatal "displaying documentation requires a working perl - try '$0 install' first" + fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" } usage() { @@ -420,34 +463,34 @@ version ) echo "staticperl version $VERSION" ;; - fetch | configure | build | install | clean | distclean) - ( "$command" ) + fetch | configure | build | install | clean | realclean | distclean) + ( "$command" ) || exit ;; instsrc ) - ( instsrc "$@" ) + ( instsrc "$@" ) || exit exit ;; instcpan ) - ( instcpan "$@" ) + ( instcpan "$@" ) || exit exit ;; cpan ) - ( install ) + ( install ) || exit "$PERL_PREFIX/bin/cpan" "$@" exit ;; mkbundle ) - ( install ) + ( install ) || exit bundle "$@" exit ;; mkperl ) - ( install ) + ( install ) || exit bundle --perl "$@" exit ;; mkapp ) - ( install ) + ( install ) || exit bundle --app "$@" exit ;;