… | |
… | |
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.1 |
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 |
266 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
277 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
267 | make install UNINST=1 |
278 | make || exit |
|
|
279 | |
268 | if find blib/arch/auto -type f | grep -q -v .exists; then |
280 | if find blib/arch/auto -type f | grep -q -v .exists; then |
269 | echo Probably an XS module, rebuilding perl |
281 | echo Probably an XS module, rebuilding perl |
270 | make perl |
282 | if make perl; then |
271 | rm -f "$PERL_PREFIX"/bin/perl |
283 | mv perl "$PERL_PREFIX"/bin/perl |
272 | make -f Makefile.aperl inst_perl |
|
|
273 | make -f Makefile.aperl map_clean |
284 | make -f Makefile.aperl map_clean |
|
|
285 | else |
|
|
286 | make -f Makefile.aperl map_clean |
|
|
287 | exit 1 |
|
|
288 | fi |
274 | fi |
289 | fi |
|
|
290 | |
|
|
291 | make install UNINST=1 |
275 | EOF |
292 | EOF |
276 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
293 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
277 | |
294 | |
278 | # trick CPAN into avoiding ~/.cpan completely |
295 | # trick CPAN into avoiding ~/.cpan completely |
279 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
296 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
… | |
… | |
294 | ' || fatal "error while initialising CPAN" |
311 | ' || fatal "error while initialising CPAN" |
295 | |
312 | |
296 | touch "$PERL_PREFIX/staticstamp.install" |
313 | touch "$PERL_PREFIX/staticstamp.install" |
297 | fi |
314 | fi |
298 | |
315 | |
299 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then |
316 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
300 | NOCHECK_INSTALL=+ |
317 | NOCHECK_INSTALL=+ |
301 | instcpan $STATICPERL_MODULES |
318 | instcpan $STATICPERL_MODULES |
302 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
319 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
303 | |
320 | |
304 | postinstall || fatal "postinstall hook failed" |
321 | postinstall || fatal "postinstall hook failed" |
… | |
… | |
385 | } |
402 | } |
386 | |
403 | |
387 | bundle() { |
404 | bundle() { |
388 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
405 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
389 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
406 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
|
|
407 | CACHE="$STATICPERL/cache" |
|
|
408 | mkdir -p "$CACHE" |
390 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" |
409 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
391 | } |
410 | } |
392 | |
411 | |
393 | if [ $# -gt 0 ]; then |
412 | if [ $# -gt 0 ]; then |
394 | while [ $# -gt 0 ]; do |
413 | while [ $# -gt 0 ]; do |
395 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
414 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
396 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
415 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
397 | |
416 | |
398 | command="${1#--}"; shift |
417 | command="${1#--}"; shift |
399 | case "$command" in |
418 | case "$command" in |
|
|
419 | version ) |
|
|
420 | echo "staticperl version $VERSION" |
|
|
421 | ;; |
400 | fetch | configure | build | install | clean | distclean) |
422 | fetch | configure | build | install | clean | distclean) |
401 | verblock <<EOF |
|
|
402 | $command |
|
|
403 | EOF |
|
|
404 | ( "$command" ) |
423 | ( "$command" ) |
405 | ;; |
424 | ;; |
406 | instsrc ) |
425 | instsrc ) |
407 | ( instsrc "$@" ) |
426 | ( instsrc "$@" ) |
408 | exit |
427 | exit |
… | |
… | |
422 | exit |
441 | exit |
423 | ;; |
442 | ;; |
424 | mkperl ) |
443 | mkperl ) |
425 | ( install ) |
444 | ( install ) |
426 | bundle --perl "$@" |
445 | bundle --perl "$@" |
|
|
446 | exit |
|
|
447 | ;; |
|
|
448 | mkapp ) |
|
|
449 | ( install ) |
|
|
450 | bundle --app "$@" |
427 | exit |
451 | exit |
428 | ;; |
452 | ;; |
429 | help ) |
453 | help ) |
430 | podusage 2 |
454 | podusage 2 |
431 | ;; |
455 | ;; |