… | |
… | |
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 |
… | |
… | |
46 | |
43 | |
47 | # which extra modules you might want to install |
44 | # which extra modules you might want to install |
48 | EXTRA_MODULES="" |
45 | EXTRA_MODULES="" |
49 | |
46 | |
50 | # overridable functions |
47 | # overridable functions |
|
|
48 | preconfigure() { : ; } |
51 | postconfigure() { : ; } |
49 | postconfigure() { : ; } |
52 | postbuild() { : ; } |
50 | postbuild() { : ; } |
53 | postinstall() { : ; } |
51 | postinstall() { : ; } |
54 | |
52 | |
55 | # now source user config, if any |
53 | # now source user config, if any |
|
|
54 | if [ "$STATICPERLRC" ]; then |
|
|
55 | . "$STATICPERLRC" |
|
|
56 | else |
56 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
57 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
57 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
58 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
58 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
59 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
|
|
60 | fi |
59 | |
61 | |
60 | ############################################################################# |
62 | ############################################################################# |
61 | # 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 |
62 | |
70 | |
63 | # set version in a way that Makefile.PL can extract |
71 | # set version in a way that Makefile.PL can extract |
64 | VERSION=VERSION; eval \ |
72 | VERSION=VERSION; eval \ |
65 | $VERSION=0.1 |
73 | $VERSION=0.911 |
66 | |
74 | |
67 | BZ2=bz2 |
75 | BZ2=bz2 |
68 | BZIP2=bzip2 |
76 | BZIP2=bzip2 |
69 | |
77 | |
70 | fatal() { |
78 | fatal() { |
… | |
… | |
103 | ############################################################################# |
111 | ############################################################################# |
104 | # clean |
112 | # clean |
105 | |
113 | |
106 | distclean() { |
114 | distclean() { |
107 | verblock <<EOF |
115 | verblock <<EOF |
108 | deleting everything installed by this script |
116 | deleting everything installed by this script (rm -rf $STATICPERL) |
109 | EOF |
117 | EOF |
110 | |
118 | |
111 | rm -rf "$STATICPERL" |
119 | rm -rf "$STATICPERL" |
112 | } |
120 | } |
113 | |
121 | |
114 | ############################################################################# |
122 | ############################################################################# |
115 | # download/configure/compile/install perl |
123 | # download/configure/compile/install perl |
116 | |
124 | |
117 | clean() { |
125 | clean() { |
118 | cd "$STATICPERL/src/perl-$PERL_VERSION" 2>/dev/null || return |
126 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
119 | |
|
|
120 | rm -f staticstamp.configure |
|
|
121 | make distclean >/dev/null 2>&1 |
|
|
122 | } |
127 | } |
123 | |
128 | |
124 | fetch() { |
129 | fetch() { |
125 | rcd "$STATICPERL" |
130 | rcd "$STATICPERL" |
126 | |
131 | |
… | |
… | |
149 | verblock <<EOF |
154 | verblock <<EOF |
150 | unpacking perl |
155 | unpacking perl |
151 | EOF |
156 | EOF |
152 | |
157 | |
153 | mkdir -p unpack |
158 | mkdir -p unpack |
154 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xpC unpack \ |
159 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
155 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
160 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
|
|
161 | chmod -R u+w unpack/perl-$PERL_VERSION |
156 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
162 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
157 | rmdir -p unpack |
163 | rmdir -p unpack |
158 | fi |
164 | fi |
159 | } |
165 | } |
160 | |
166 | |
… | |
… | |
173 | |
179 | |
174 | verblock <<EOF |
180 | verblock <<EOF |
175 | configuring $STATICPERL/src/perl-$PERL_VERSION |
181 | configuring $STATICPERL/src/perl-$PERL_VERSION |
176 | EOF |
182 | EOF |
177 | |
183 | |
178 | clean |
|
|
179 | |
|
|
180 | rm -f "$PERL_PREFIX/staticstamp.install" |
184 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
185 | |
|
|
186 | make distclean >/dev/null 2>&1 |
181 | |
187 | |
182 | # I hate them |
188 | # I hate them |
183 | grep -q -- -fstack-protector Configure && \ |
189 | grep -q -- -fstack-protector Configure && \ |
184 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
190 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
|
|
191 | |
|
|
192 | preconfigure |
185 | |
193 | |
186 | # trace configure \ |
194 | # trace configure \ |
187 | sh Configure -Duselargefiles \ |
195 | sh Configure -Duselargefiles \ |
188 | -Uuse64bitint \ |
196 | -Uuse64bitint \ |
189 | -Dusemymalloc=n \ |
197 | -Dusemymalloc=n \ |
… | |
… | |
245 | |
253 | |
246 | postbuild || fatal "postbuild hook failed" |
254 | postbuild || fatal "postbuild hook failed" |
247 | } |
255 | } |
248 | |
256 | |
249 | install() { |
257 | install() { |
250 | [ -e "$PERL_PREFIX/staticstamp.install" ] && return |
258 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
251 | |
|
|
252 | build |
259 | build |
253 | |
260 | |
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" |
280 | |
297 | |
281 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
298 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
282 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
299 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
283 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
300 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
284 | CPAN::Shell->o (conf => q<init>); |
301 | CPAN::Shell->o (conf => q<init>); |
285 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
302 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
286 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
303 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
287 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
304 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
288 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
305 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
289 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
306 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
290 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
307 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
291 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
308 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
292 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
309 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
293 | CPAN::Shell->o (conf => q<commit>); |
310 | CPAN::Shell->o (conf => q<commit>); |
294 | ' || fatal "error while initialising CPAN" |
311 | ' || fatal "error while initialising CPAN" |
295 | |
312 | |
|
|
313 | touch "$PERL_PREFIX/staticstamp.install" |
|
|
314 | fi |
|
|
315 | |
|
|
316 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
296 | NOCHECK_INSTALL=+ |
317 | NOCHECK_INSTALL=+ |
297 | instcpan $STATICPERL_MODULES |
318 | instcpan $STATICPERL_MODULES |
298 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
319 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
299 | |
320 | |
300 | postinstall || fatal "postinstall hook failed" |
321 | postinstall || fatal "postinstall hook failed" |
301 | |
322 | |
302 | touch "$PERL_PREFIX/staticstamp.install" |
323 | touch "$PERL_PREFIX/staticstamp.postinstall" |
|
|
324 | fi |
303 | } |
325 | } |
304 | |
326 | |
305 | ############################################################################# |
327 | ############################################################################# |
306 | # install a module from CPAN |
328 | # install a module from CPAN |
307 | |
329 | |
… | |
… | |
380 | } |
402 | } |
381 | |
403 | |
382 | bundle() { |
404 | bundle() { |
383 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
405 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
384 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
406 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
|
|
407 | CACHE="$STATICPERL/cache" |
|
|
408 | mkdir -p "$CACHE" |
385 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" |
409 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
386 | } |
410 | } |
387 | |
411 | |
388 | if [ $# -gt 0 ]; then |
412 | if [ $# -gt 0 ]; then |
389 | while [ $# -gt 0 ]; do |
413 | while [ $# -gt 0 ]; do |
390 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
414 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
391 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
415 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
392 | |
416 | |
393 | command="${1#--}"; shift |
417 | command="${1#--}"; shift |
394 | case "$command" in |
418 | case "$command" in |
|
|
419 | version ) |
|
|
420 | echo "staticperl version $VERSION" |
|
|
421 | ;; |
395 | fetch | configure | build | install | clean | distclean) |
422 | fetch | configure | build | install | clean | distclean) |
396 | verblock <<EOF |
|
|
397 | $command |
|
|
398 | EOF |
|
|
399 | ( "$command" ) |
423 | ( "$command" ) |
400 | ;; |
424 | ;; |
401 | instsrc ) |
425 | instsrc ) |
402 | ( instsrc "$@" ) |
426 | ( instsrc "$@" ) |
403 | exit |
427 | exit |
… | |
… | |
417 | exit |
441 | exit |
418 | ;; |
442 | ;; |
419 | mkperl ) |
443 | mkperl ) |
420 | ( install ) |
444 | ( install ) |
421 | bundle --perl "$@" |
445 | bundle --perl "$@" |
|
|
446 | exit |
|
|
447 | ;; |
|
|
448 | mkapp ) |
|
|
449 | ( install ) |
|
|
450 | bundle --app "$@" |
422 | exit |
451 | exit |
423 | ;; |
452 | ;; |
424 | help ) |
453 | help ) |
425 | podusage 2 |
454 | podusage 2 |
426 | ;; |
455 | ;; |