… | |
… | |
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 | PERL_MM_USE_DEFAULT=1 |
39 | PERL_MM_USE_DEFAULT=1 |
39 | #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 |
… | |
… | |
47 | # which extra modules you might want to install |
48 | # which extra modules you might want to install |
48 | EXTRA_MODULES="" |
49 | EXTRA_MODULES="" |
49 | |
50 | |
50 | # overridable functions |
51 | # overridable functions |
51 | preconfigure() { : ; } |
52 | preconfigure() { : ; } |
|
|
53 | patchconfig() { : ; } |
52 | postconfigure() { : ; } |
54 | postconfigure() { : ; } |
53 | postbuild() { : ; } |
55 | postbuild() { : ; } |
54 | postinstall() { : ; } |
56 | postinstall() { : ; } |
55 | |
57 | |
56 | # now source user config, if any |
58 | # now source user config, if any |
… | |
… | |
71 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
73 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
72 | LC_ALL=C; export LC_ALL # just to be on the safe side |
74 | LC_ALL=C; export LC_ALL # just to be on the safe side |
73 | |
75 | |
74 | # set version in a way that Makefile.PL can extract |
76 | # set version in a way that Makefile.PL can extract |
75 | VERSION=VERSION; eval \ |
77 | VERSION=VERSION; eval \ |
76 | $VERSION=0.92 |
78 | $VERSION="1.21" |
77 | |
79 | |
78 | BZ2=bz2 |
80 | BZ2=bz2 |
79 | BZIP2=bzip2 |
81 | BZIP2=bzip2 |
80 | |
82 | |
81 | fatal() { |
83 | fatal() { |
… | |
… | |
165 | unpacking perl |
167 | unpacking perl |
166 | EOF |
168 | EOF |
167 | |
169 | |
168 | mkdir -p unpack |
170 | mkdir -p unpack |
169 | rm -rf unpack/perl-$PERL_VERSION |
171 | rm -rf unpack/perl-$PERL_VERSION |
170 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
172 | $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar xf - ) \ |
171 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
173 | || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" |
172 | chmod -R u+w unpack/perl-$PERL_VERSION |
174 | chmod -R u+w unpack/perl-$PERL_VERSION |
173 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
175 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
174 | rmdir -p unpack |
176 | rmdir -p unpack |
175 | fi |
177 | fi |
176 | } |
178 | } |
… | |
… | |
227 | |
229 | |
228 | # I hate them for this |
230 | # I hate them for this |
229 | grep -q -- -fstack-protector Configure && \ |
231 | grep -q -- -fstack-protector Configure && \ |
230 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
232 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
231 | |
233 | |
232 | 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" |
233 | |
239 | |
234 | # trace configure \ |
240 | # trace configure \ |
235 | sh Configure -Duselargefiles \ |
241 | sh Configure -Duselargefiles \ |
236 | -Uuse64bitint \ |
242 | -Uuse64bitint \ |
237 | -Dusemymalloc=n \ |
243 | -Dusemymalloc=n \ |
… | |
… | |
239 | -Uusethreads \ |
245 | -Uusethreads \ |
240 | -Uuseithreads \ |
246 | -Uuseithreads \ |
241 | -Uusemultiplicity \ |
247 | -Uusemultiplicity \ |
242 | -Uusesfio \ |
248 | -Uusesfio \ |
243 | -Uuseshrplib \ |
249 | -Uuseshrplib \ |
|
|
250 | -Uinstallusrbinperl \ |
244 | -A ccflags=" $PERL_CCFLAGS" \ |
251 | -A ccflags=" $PERL_CCFLAGS" \ |
245 | -Dcc="$PERL_CC" \ |
252 | -Dcc="$PERL_CC" \ |
246 | -Doptimize="$PERL_OPTIMIZE" \ |
253 | -Doptimize="$PERL_OPTIMIZE" \ |
247 | -Dldflags="$PERL_LDFLAGS" \ |
254 | -Dldflags="$PERL_LDFLAGS" \ |
248 | -Dlibs="$PERL_LIBS" \ |
255 | -Dlibs="$PERL_LIBS" \ |
… | |
… | |
268 | sedreplace ' |
275 | sedreplace ' |
269 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
276 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
270 | s/ *-fno-stack-protector */ /g |
277 | s/ *-fno-stack-protector */ /g |
271 | ' config.sh |
278 | ' config.sh |
272 | |
279 | |
|
|
280 | patchconfig || fatal "patchconfig hook failed" |
|
|
281 | |
273 | sh Configure -S || fatal "Configure -S failed" |
282 | sh Configure -S || fatal "Configure -S failed" |
274 | |
283 | |
275 | postconfigure || fatal "postconfigure hook failed" |
284 | postconfigure || fatal "postconfigure hook failed" |
276 | |
285 | |
277 | touch staticstamp.configure |
286 | touch staticstamp.configure |
… | |
… | |
313 | rcd "$PERL_PREFIX" |
322 | rcd "$PERL_PREFIX" |
314 | |
323 | |
315 | # create a "make install" replacement for CPAN |
324 | # create a "make install" replacement for CPAN |
316 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
325 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
317 | "$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 |
318 | |
343 | |
319 | 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 |
320 | echo Probably an XS module, rebuilding perl |
345 | echo Probably an XS module, rebuilding perl |
321 | if "$MAKE" perl; then |
346 | if "$MAKE" perl; then |
322 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
347 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
… | |
… | |
334 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
359 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
335 | |
360 | |
336 | # trick CPAN into avoiding ~/.cpan completely |
361 | # trick CPAN into avoiding ~/.cpan completely |
337 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
362 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
338 | |
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 | |
339 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
368 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
340 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
369 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
341 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
370 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
342 | CPAN::Shell->o (conf => q<init>); |
371 | CPAN::Shell->o (conf => q<init>); |
343 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
372 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
344 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
373 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
… | |
… | |
346 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
375 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
347 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
376 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
348 | 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"); |
349 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
378 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
350 | 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"); |
351 | CPAN::Shell->o (conf => q<commit>); |
381 | CPAN::Shell->o (conf => q<commit>); |
352 | ' || fatal "error while initialising CPAN" |
382 | ' || fatal "error while initialising CPAN" |
353 | |
383 | |
354 | touch "$PERL_PREFIX/staticstamp.install" |
384 | touch "$PERL_PREFIX/staticstamp.install" |
355 | fi |
385 | fi |
… | |
… | |
375 | installing modules from CPAN |
405 | installing modules from CPAN |
376 | $@ |
406 | $@ |
377 | EOF |
407 | EOF |
378 | |
408 | |
379 | for mod in "$@"; do |
409 | for mod in "$@"; do |
380 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
410 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \ |
381 | || fatal "$mod: unable to install from CPAN" |
411 | || fatal "$mod: unable to install from CPAN" |
382 | done |
412 | done |
383 | rm -rf "$STATICPERL/build" |
413 | rm -rf "$STATICPERL/build" |
384 | } |
414 | } |
385 | |
415 | |