… | |
… | |
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 | # perl build variables |
10 | # perl build variables |
11 | MAKE=make |
11 | MAKE=make |
12 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
12 | PERL_VERSION=5.12.3 # 5.8.9 is also a good choice |
13 | PERL_CC=cc |
13 | PERL_CC=cc |
14 | PERL_CONFIGURE="" # additional Configure arguments |
14 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CCFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG" |
15 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
16 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
16 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | |
17 | |
18 | ARCH="$(uname -m)" |
18 | ARCH="$(uname -m)" |
19 | |
19 | |
20 | case "$ARCH" in |
20 | case "$ARCH" in |
… | |
… | |
29 | esac |
29 | esac |
30 | |
30 | |
31 | # -Wl,--gc-sections makes it impossible to check for undefined references |
31 | # -Wl,--gc-sections makes it impossible to check for undefined references |
32 | # 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 :/ |
33 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
33 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
34 | PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
34 | #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
|
|
35 | PERL_LDFLAGS= |
35 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
36 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
36 | |
37 | |
37 | # some configuration options for modules |
38 | # some configuration options for modules |
38 | export PERL_MM_USE_DEFAULT=1 |
39 | PERL_MM_USE_DEFAULT=1 |
39 | #export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
40 | #CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
40 | 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' |
41 | 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' |
|
|
42 | export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS |
41 | |
43 | |
42 | # which extra modules to install by default from CPAN that are |
44 | # which extra modules to install by default from CPAN that are |
43 | # required by mkbundle |
45 | # required by mkbundle |
44 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
46 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
45 | |
47 | |
46 | # which extra modules you might want to install |
48 | # which extra modules you might want to install |
47 | EXTRA_MODULES="" |
49 | EXTRA_MODULES="" |
48 | |
50 | |
49 | # overridable functions |
51 | # overridable functions |
50 | preconfigure() { : ; } |
52 | preconfigure() { : ; } |
|
|
53 | patchconfig() { : ; } |
51 | postconfigure() { : ; } |
54 | postconfigure() { : ; } |
52 | postbuild() { : ; } |
55 | postbuild() { : ; } |
53 | postinstall() { : ; } |
56 | postinstall() { : ; } |
54 | |
57 | |
55 | # now source user config, if any |
58 | # now source user config, if any |
… | |
… | |
66 | |
69 | |
67 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
70 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
68 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
71 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
69 | |
72 | |
70 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
73 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
71 | export LC_ALL=C # just to be on the safe side |
74 | LC_ALL=C; export LC_ALL # just to be on the safe side |
72 | |
75 | |
73 | # set version in a way that Makefile.PL can extract |
76 | # set version in a way that Makefile.PL can extract |
74 | VERSION=VERSION; eval \ |
77 | VERSION=VERSION; eval \ |
75 | $VERSION=0.912 |
78 | $VERSION="1.21" |
76 | |
79 | |
77 | BZ2=bz2 |
80 | BZ2=bz2 |
78 | BZIP2=bzip2 |
81 | BZIP2=bzip2 |
79 | |
82 | |
80 | fatal() { |
83 | fatal() { |
… | |
… | |
151 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
154 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
152 | trying $URL |
155 | trying $URL |
153 | EOF |
156 | EOF |
154 | |
157 | |
155 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
158 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
|
|
159 | curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
156 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
160 | || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
157 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
|
|
158 | || fatal "$URL: unable to download" |
161 | || fatal "$URL: unable to download" |
159 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
162 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
160 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
163 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
161 | fi |
164 | fi |
162 | |
165 | |
… | |
… | |
164 | unpacking perl |
167 | unpacking perl |
165 | EOF |
168 | EOF |
166 | |
169 | |
167 | mkdir -p unpack |
170 | mkdir -p unpack |
168 | rm -rf unpack/perl-$PERL_VERSION |
171 | rm -rf unpack/perl-$PERL_VERSION |
169 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
172 | $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar xf - ) \ |
170 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
173 | || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" |
171 | chmod -R u+w unpack/perl-$PERL_VERSION |
174 | chmod -R u+w unpack/perl-$PERL_VERSION |
172 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
175 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
173 | rmdir -p unpack |
176 | rmdir -p unpack |
174 | fi |
177 | fi |
175 | } |
178 | } |
… | |
… | |
226 | |
229 | |
227 | # I hate them for this |
230 | # I hate them for this |
228 | grep -q -- -fstack-protector Configure && \ |
231 | grep -q -- -fstack-protector Configure && \ |
229 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
232 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
230 | |
233 | |
231 | preconfigure |
234 | # what did that bloke think |
|
|
235 | grep -q -- usedl=.define hints/darwin.sh && \ |
|
|
236 | sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
|
|
237 | |
|
|
238 | preconfigure || fatal "preconfigure hook failed" |
232 | |
239 | |
233 | # trace configure \ |
240 | # trace configure \ |
234 | sh Configure -Duselargefiles \ |
241 | sh Configure -Duselargefiles \ |
235 | -Uuse64bitint \ |
242 | -Uuse64bitint \ |
236 | -Dusemymalloc=n \ |
243 | -Dusemymalloc=n \ |
… | |
… | |
238 | -Uusethreads \ |
245 | -Uusethreads \ |
239 | -Uuseithreads \ |
246 | -Uuseithreads \ |
240 | -Uusemultiplicity \ |
247 | -Uusemultiplicity \ |
241 | -Uusesfio \ |
248 | -Uusesfio \ |
242 | -Uuseshrplib \ |
249 | -Uuseshrplib \ |
|
|
250 | -Uinstallusrbinperl \ |
243 | -A ccflags=" $PERL_CCFLAGS" \ |
251 | -A ccflags=" $PERL_CCFLAGS" \ |
244 | -Dcc="$PERL_CC" \ |
252 | -Dcc="$PERL_CC" \ |
245 | -Doptimize="$PERL_OPTIMIZE" \ |
253 | -Doptimize="$PERL_OPTIMIZE" \ |
246 | -Dldflags="$PERL_LDFLAGS" \ |
254 | -Dldflags="$PERL_LDFLAGS" \ |
247 | -Dlibs="$PERL_LIBS" \ |
255 | -Dlibs="$PERL_LIBS" \ |
… | |
… | |
267 | sedreplace ' |
275 | sedreplace ' |
268 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
276 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
269 | s/ *-fno-stack-protector */ /g |
277 | s/ *-fno-stack-protector */ /g |
270 | ' config.sh |
278 | ' config.sh |
271 | |
279 | |
|
|
280 | patchconfig || fatal "patchconfig hook failed" |
|
|
281 | |
272 | sh Configure -S || fatal "Configure -S failed" |
282 | sh Configure -S || fatal "Configure -S failed" |
273 | |
283 | |
274 | postconfigure || fatal "postconfigure hook failed" |
284 | postconfigure || fatal "postconfigure hook failed" |
275 | |
285 | |
276 | touch staticstamp.configure |
286 | touch staticstamp.configure |
… | |
… | |
312 | rcd "$PERL_PREFIX" |
322 | rcd "$PERL_PREFIX" |
313 | |
323 | |
314 | # create a "make install" replacement for CPAN |
324 | # create a "make install" replacement for CPAN |
315 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
325 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
316 | "$MAKE" || exit |
326 | "$MAKE" || exit |
|
|
327 | |
|
|
328 | # patch CPAN::HandleConfig.pm |
|
|
329 | HCPM="$PERL_PREFIX"/lib/CPAN/HandleConfig.pm |
|
|
330 | case "\$(head -n1 "\$HCPM")" in |
|
|
331 | *CPAN::MyConfig* ) |
|
|
332 | ;; |
|
|
333 | * ) |
|
|
334 | echo "patching \$HCPM for a safer tomorrow" |
|
|
335 | { |
|
|
336 | echo "use CPAN::MyConfig;" |
|
|
337 | cat "\$HCPM" |
|
|
338 | } >"\$HCPM~" |
|
|
339 | rm -f "\$HCPM" |
|
|
340 | mv "\$HCPM~" "\$HCPM" |
|
|
341 | ;; |
|
|
342 | esac |
317 | |
343 | |
318 | if find blib/arch/auto -type f | grep -q -v .exists; then |
344 | if find blib/arch/auto -type f | grep -q -v .exists; then |
319 | echo Probably an XS module, rebuilding perl |
345 | echo Probably an XS module, rebuilding perl |
320 | if "$MAKE" perl; then |
346 | if "$MAKE" perl; then |
321 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
347 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
… | |
… | |
333 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
359 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
334 | |
360 | |
335 | # trick CPAN into avoiding ~/.cpan completely |
361 | # trick CPAN into avoiding ~/.cpan completely |
336 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
362 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
337 | |
363 | |
|
|
364 | # we call cpan with -MCPAN::MyConfig in this script, but |
|
|
365 | # every make install will patch CPAN::HandleConfig.pm to |
|
|
366 | # protect the user. |
|
|
367 | |
338 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
368 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
339 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
369 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
340 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
370 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
341 | CPAN::Shell->o (conf => q<init>); |
371 | CPAN::Shell->o (conf => q<init>); |
342 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
372 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
343 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
373 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
… | |
… | |
345 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
375 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
346 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
376 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
347 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
377 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
348 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
378 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
349 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
379 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
|
|
380 | CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
350 | CPAN::Shell->o (conf => q<commit>); |
381 | CPAN::Shell->o (conf => q<commit>); |
351 | ' || fatal "error while initialising CPAN" |
382 | ' || fatal "error while initialising CPAN" |
352 | |
383 | |
353 | touch "$PERL_PREFIX/staticstamp.install" |
384 | touch "$PERL_PREFIX/staticstamp.install" |
354 | fi |
385 | fi |
… | |
… | |
374 | installing modules from CPAN |
405 | installing modules from CPAN |
375 | $@ |
406 | $@ |
376 | EOF |
407 | EOF |
377 | |
408 | |
378 | for mod in "$@"; do |
409 | for mod in "$@"; do |
379 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
410 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \ |
380 | || fatal "$mod: unable to install from CPAN" |
411 | || fatal "$mod: unable to install from CPAN" |
381 | done |
412 | done |
382 | rm -rf "$STATICPERL/build" |
413 | rm -rf "$STATICPERL/build" |
383 | } |
414 | } |
384 | |
415 | |