… | |
… | |
2 | |
2 | |
3 | ############################################################################# |
3 | ############################################################################# |
4 | # configuration to fill in |
4 | # configuration to fill in |
5 | |
5 | |
6 | STATICPERL=~/.staticperl |
6 | STATICPERL=~/.staticperl |
7 | CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
8 | EMAIL="read the documentation <rtfm@example.org>" |
8 | EMAIL="read the documentation <rtfm@example.org>" |
9 | |
9 | |
10 | MKBUNDLE="$STATICPERL/mkbundle" |
|
|
11 | |
|
|
12 | # perl build variables |
10 | # perl build variables |
13 | PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed |
|
|
14 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
11 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
15 | PERL_CONFIGURE="" # additional Configure arguments |
12 | PERL_CONFIGURE="" # additional Configure arguments |
16 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
13 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
17 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
14 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
18 | |
15 | |
… | |
… | |
29 | ;; |
26 | ;; |
30 | esac |
27 | esac |
31 | |
28 | |
32 | # -Wl,--gc-sections makes it impossible to check for undefined references |
29 | # -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 :/ |
30 | # 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 |
31 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
35 | PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" |
32 | PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
36 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
33 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | |
34 | |
38 | # some configuration options for modules |
35 | # some configuration options for modules |
39 | export PERL_MM_USE_DEFAULT=1 |
36 | export PERL_MM_USE_DEFAULT=1 |
40 | #export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
37 | #export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
… | |
… | |
52 | postconfigure() { : ; } |
49 | postconfigure() { : ; } |
53 | postbuild() { : ; } |
50 | postbuild() { : ; } |
54 | postinstall() { : ; } |
51 | postinstall() { : ; } |
55 | |
52 | |
56 | # now source user config, if any |
53 | # now source user config, if any |
|
|
54 | if [ "$STATICPERLRC" ]; then |
|
|
55 | . "$STATICPERLRC" |
|
|
56 | else |
57 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
57 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
58 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
58 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
59 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
59 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
|
|
60 | fi |
60 | |
61 | |
61 | ############################################################################# |
62 | ############################################################################# |
62 | # support |
63 | # support |
|
|
64 | |
|
|
65 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
|
|
66 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
|
|
67 | |
|
|
68 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
69 | export LC_ALL=C # just to be on the safe side |
63 | |
70 | |
64 | # set version in a way that Makefile.PL can extract |
71 | # set version in a way that Makefile.PL can extract |
65 | VERSION=VERSION; eval \ |
72 | VERSION=VERSION; eval \ |
66 | $VERSION=0.9 |
73 | $VERSION=0.911 |
67 | |
74 | |
68 | BZ2=bz2 |
75 | BZ2=bz2 |
69 | BZIP2=bzip2 |
76 | BZIP2=bzip2 |
70 | |
77 | |
71 | fatal() { |
78 | fatal() { |
… | |
… | |
104 | ############################################################################# |
111 | ############################################################################# |
105 | # clean |
112 | # clean |
106 | |
113 | |
107 | distclean() { |
114 | distclean() { |
108 | verblock <<EOF |
115 | verblock <<EOF |
109 | deleting everything installed by this script |
116 | deleting everything installed by this script (rm -rf $STATICPERL) |
110 | EOF |
117 | EOF |
111 | |
118 | |
112 | rm -rf "$STATICPERL" |
119 | rm -rf "$STATICPERL" |
113 | } |
120 | } |
114 | |
121 | |
… | |
… | |
147 | verblock <<EOF |
154 | verblock <<EOF |
148 | unpacking perl |
155 | unpacking perl |
149 | EOF |
156 | EOF |
150 | |
157 | |
151 | mkdir -p unpack |
158 | mkdir -p unpack |
152 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ |
159 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
153 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
160 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
154 | chmod -R u+w unpack/perl-$PERL_VERSION |
161 | chmod -R u+w unpack/perl-$PERL_VERSION |
155 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
162 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
156 | rmdir -p unpack |
163 | rmdir -p unpack |
157 | fi |
164 | fi |
… | |
… | |
254 | verblock <<EOF |
261 | verblock <<EOF |
255 | installing $STATICPERL/src/perl-$PERL_VERSION |
262 | installing $STATICPERL/src/perl-$PERL_VERSION |
256 | to $PERL_PREFIX |
263 | to $PERL_PREFIX |
257 | EOF |
264 | EOF |
258 | |
265 | |
259 | rm -rf "$PERL_PREFIX" |
266 | ln -sf "perl/bin/" "$STATICPERL/bin" |
260 | |
267 | ln -sf "perl/lib/" "$STATICPERL/lib" |
|
|
268 | |
|
|
269 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
|
|
270 | rm -rf "$PERL_PREFIX" # by this rm -rf |
|
|
271 | |
261 | make install || fatal "make install: error while installing" |
272 | make install || fatal "make install: error while installing" |
262 | |
273 | |
263 | rcd "$PERL_PREFIX" |
274 | rcd "$PERL_PREFIX" |
264 | |
275 | |
265 | # create a "make install" replacement for CPAN |
276 | # create a "make install" replacement for CPAN |
… | |
… | |
361 | ############################################################################# |
372 | ############################################################################# |
362 | # main |
373 | # main |
363 | |
374 | |
364 | podusage() { |
375 | podusage() { |
365 | echo |
376 | echo |
|
|
377 | |
366 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
378 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
367 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
379 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
368 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
380 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
369 | 2>/dev/null && exit |
381 | 2>/dev/null && exit |
370 | fi |
382 | fi |
|
|
383 | |
371 | # try whatever perl we can find |
384 | # try whatever perl we can find |
372 | perl -MPod::Usage -e \ |
385 | perl -MPod::Usage -e \ |
373 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
386 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
374 | 2>/dev/null && exit |
387 | 2>/dev/null && exit |
375 | |
388 | |
376 | fatal "displaying documentation requires a working perl - try '$0 install' first" |
389 | fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
377 | } |
390 | } |
378 | |
391 | |
379 | usage() { |
392 | usage() { |
380 | podusage 0 |
393 | podusage 0 |
381 | } |
394 | } |
… | |
… | |
391 | } |
404 | } |
392 | |
405 | |
393 | bundle() { |
406 | bundle() { |
394 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
407 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
395 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
408 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
|
|
409 | CACHE="$STATICPERL/cache" |
|
|
410 | mkdir -p "$CACHE" |
396 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" |
411 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
397 | } |
412 | } |
398 | |
413 | |
399 | if [ $# -gt 0 ]; then |
414 | if [ $# -gt 0 ]; then |
400 | while [ $# -gt 0 ]; do |
415 | while [ $# -gt 0 ]; do |
401 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
416 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
402 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
417 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
403 | |
418 | |
404 | command="${1#--}"; shift |
419 | command="${1#--}"; shift |
405 | case "$command" in |
420 | case "$command" in |
|
|
421 | version ) |
|
|
422 | echo "staticperl version $VERSION" |
|
|
423 | ;; |
406 | fetch | configure | build | install | clean | distclean) |
424 | fetch | configure | build | install | clean | distclean) |
407 | verblock <<EOF |
|
|
408 | $command |
|
|
409 | EOF |
|
|
410 | ( "$command" ) |
425 | ( "$command" ) |
411 | ;; |
426 | ;; |
412 | instsrc ) |
427 | instsrc ) |
413 | ( instsrc "$@" ) |
428 | ( instsrc "$@" ) |
414 | exit |
429 | exit |