… | |
… | |
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 | # perl build variables |
10 | # perl build variables |
|
|
11 | MAKE=make |
11 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
12 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
|
|
13 | PERL_CC=cc |
12 | PERL_CONFIGURE="" # additional Configure arguments |
14 | PERL_CONFIGURE="" # additional Configure arguments |
13 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
15 | PERL_CCFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG" |
14 | 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" |
15 | |
17 | |
16 | ARCH="$(uname -m)" |
18 | ARCH="$(uname -m)" |
17 | |
19 | |
18 | case "$ARCH" in |
20 | case "$ARCH" in |
… | |
… | |
68 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
70 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
69 | export LC_ALL=C # just to be on the safe side |
71 | export LC_ALL=C # just to be on the safe side |
70 | |
72 | |
71 | # set version in a way that Makefile.PL can extract |
73 | # set version in a way that Makefile.PL can extract |
72 | VERSION=VERSION; eval \ |
74 | VERSION=VERSION; eval \ |
73 | $VERSION=0.911 |
75 | $VERSION=0.912 |
74 | |
76 | |
75 | BZ2=bz2 |
77 | BZ2=bz2 |
76 | BZIP2=bzip2 |
78 | BZIP2=bzip2 |
77 | |
79 | |
78 | fatal() { |
80 | fatal() { |
… | |
… | |
124 | |
126 | |
125 | clean() { |
127 | clean() { |
126 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
128 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
127 | } |
129 | } |
128 | |
130 | |
|
|
131 | realclean() { |
|
|
132 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
|
|
133 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
134 | rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
|
|
135 | } |
|
|
136 | |
129 | fetch() { |
137 | fetch() { |
130 | rcd "$STATICPERL" |
138 | rcd "$STATICPERL" |
131 | |
139 | |
132 | mkdir -p src |
140 | mkdir -p src |
133 | rcd src |
141 | rcd src |
… | |
… | |
146 | |
154 | |
147 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
155 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
148 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
156 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
149 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
157 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
150 | || fatal "$URL: unable to download" |
158 | || fatal "$URL: unable to download" |
|
|
159 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
151 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
160 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
152 | fi |
161 | fi |
153 | |
162 | |
154 | verblock <<EOF |
163 | verblock <<EOF |
155 | unpacking perl |
164 | unpacking perl |
156 | EOF |
165 | EOF |
157 | |
166 | |
158 | mkdir -p unpack |
167 | mkdir -p unpack |
|
|
168 | rm -rf unpack/perl-$PERL_VERSION |
159 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
169 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
160 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
170 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
161 | chmod -R u+w unpack/perl-$PERL_VERSION |
171 | chmod -R u+w unpack/perl-$PERL_VERSION |
162 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
172 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
163 | rmdir -p unpack |
173 | rmdir -p unpack |
… | |
… | |
165 | } |
175 | } |
166 | |
176 | |
167 | # similar to GNU-sed -i or perl -pi |
177 | # similar to GNU-sed -i or perl -pi |
168 | sedreplace() { |
178 | sedreplace() { |
169 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
179 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
|
|
180 | rm -f "$2" |
170 | mv "$2~" "$2" |
181 | mv "$2~" "$2" |
|
|
182 | } |
|
|
183 | |
|
|
184 | configure_failure() { |
|
|
185 | cat <<EOF |
|
|
186 | |
|
|
187 | |
|
|
188 | *** |
|
|
189 | *** Configure failed - see above for the exact error message(s). |
|
|
190 | *** |
|
|
191 | *** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
|
|
192 | *** flags are not supported by your compiler. Less often, this is because |
|
|
193 | *** PERL_LIBS either contains a library not available on your system (such as |
|
|
194 | *** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
|
|
195 | *** |
|
|
196 | *** You can provide your own flags by creating a ~/.staticperlrc file with |
|
|
197 | *** variable assignments. For example (these are the actual values used): |
|
|
198 | *** |
|
|
199 | |
|
|
200 | PERL_CC="$PERL_CC" |
|
|
201 | PERL_CCFLAGS="$PERL_CCFLAGS" |
|
|
202 | PERL_OPTIMIZE="$PERL_OPTIMIZE" |
|
|
203 | PERL_LDFLAGS="$PERL_LDFLAGS" |
|
|
204 | PERL_LIBS="$PERL_LIBS" |
|
|
205 | |
|
|
206 | EOF |
|
|
207 | exit 1 |
171 | } |
208 | } |
172 | |
209 | |
173 | configure() { |
210 | configure() { |
174 | fetch |
211 | fetch |
175 | |
212 | |
… | |
… | |
181 | configuring $STATICPERL/src/perl-$PERL_VERSION |
218 | configuring $STATICPERL/src/perl-$PERL_VERSION |
182 | EOF |
219 | EOF |
183 | |
220 | |
184 | rm -f "$PERL_PREFIX/staticstamp.install" |
221 | rm -f "$PERL_PREFIX/staticstamp.install" |
185 | |
222 | |
186 | make distclean >/dev/null 2>&1 |
223 | "$MAKE" distclean >/dev/null 2>&1 |
187 | |
224 | |
|
|
225 | sedreplace '/^#define SITELIB/d' config_h.SH |
|
|
226 | |
188 | # I hate them |
227 | # I hate them for this |
189 | grep -q -- -fstack-protector Configure && \ |
228 | grep -q -- -fstack-protector Configure && \ |
190 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
229 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
191 | |
230 | |
192 | preconfigure |
231 | preconfigure |
193 | |
232 | |
… | |
… | |
197 | -Dusemymalloc=n \ |
236 | -Dusemymalloc=n \ |
198 | -Uusedl \ |
237 | -Uusedl \ |
199 | -Uusethreads \ |
238 | -Uusethreads \ |
200 | -Uuseithreads \ |
239 | -Uuseithreads \ |
201 | -Uusemultiplicity \ |
240 | -Uusemultiplicity \ |
202 | -Duseperlio \ |
|
|
203 | -Uusesfio \ |
241 | -Uusesfio \ |
204 | -Uuseshrplib \ |
242 | -Uuseshrplib \ |
205 | -Dcppflags="$PERL_CPPFLAGS" \ |
243 | -A ccflags=" $PERL_CCFLAGS" \ |
206 | -Dccflags="-g2 -fno-strict-aliasing" \ |
244 | -Dcc="$PERL_CC" \ |
207 | -Doptimize="$PERL_OPTIMIZE" \ |
245 | -Doptimize="$PERL_OPTIMIZE" \ |
208 | -Dldflags="$PERL_LDFLAGS" \ |
246 | -Dldflags="$PERL_LDFLAGS" \ |
209 | -Dlibs="$PERL_LIBS" \ |
247 | -Dlibs="$PERL_LIBS" \ |
210 | -Dprefix="$PERL_PREFIX" \ |
248 | -Dprefix="$PERL_PREFIX" \ |
211 | -Dbin="$PERL_PREFIX/bin" \ |
249 | -Dbin="$PERL_PREFIX/bin" \ |
212 | -Dprivlib="$PERL_PREFIX/lib" \ |
250 | -Dprivlib="$PERL_PREFIX/lib" \ |
213 | -Darchlib="$PERL_PREFIX/lib" \ |
251 | -Darchlib="$PERL_PREFIX/lib" \ |
214 | -Uusevendorprefix \ |
252 | -Uusevendorprefix \ |
215 | -Dsitelib="$PERL_PREFIX/lib" \ |
253 | -Dsitelib="$PERL_PREFIX/lib" \ |
216 | -Dsitearch="$PERL_PREFIX/lib" \ |
254 | -Dsitearch="$PERL_PREFIX/lib" \ |
217 | -Usitelibexp \ |
|
|
218 | -Uman1dir \ |
255 | -Uman1dir \ |
219 | -Uman3dir \ |
256 | -Uman3dir \ |
220 | -Usiteman1dir \ |
257 | -Usiteman1dir \ |
221 | -Usiteman3dir \ |
258 | -Usiteman3dir \ |
222 | -Dpager=/usr/bin/less \ |
259 | -Dpager=/usr/bin/less \ |
223 | -Demail="$EMAIL" \ |
260 | -Demail="$EMAIL" \ |
224 | -Dcf_email="$EMAIL" \ |
261 | -Dcf_email="$EMAIL" \ |
225 | -Dcf_by="$EMAIL" \ |
262 | -Dcf_by="$EMAIL" \ |
226 | $PERL_CONFIGURE \ |
263 | $PERL_CONFIGURE \ |
|
|
264 | -Duseperlio \ |
227 | -dE || fatal "Configure failed" |
265 | -dE || configure_failure |
228 | |
266 | |
229 | sedreplace ' |
267 | sedreplace ' |
230 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
268 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
231 | s/ *-fno-stack-protector */ /g |
269 | s/ *-fno-stack-protector */ /g |
232 | ' config.sh |
270 | ' config.sh |
… | |
… | |
247 | building $STATICPERL/src/perl-$PERL_VERSION |
285 | building $STATICPERL/src/perl-$PERL_VERSION |
248 | EOF |
286 | EOF |
249 | |
287 | |
250 | rm -f "$PERL_PREFIX/staticstamp.install" |
288 | rm -f "$PERL_PREFIX/staticstamp.install" |
251 | |
289 | |
252 | make || fatal "make: error while building perl" |
290 | "$MAKE" || fatal "make: error while building perl" |
253 | |
291 | |
254 | postbuild || fatal "postbuild hook failed" |
292 | postbuild || fatal "postbuild hook failed" |
255 | } |
293 | } |
256 | |
294 | |
257 | install() { |
295 | install() { |
… | |
… | |
267 | ln -sf "perl/lib/" "$STATICPERL/lib" |
305 | ln -sf "perl/lib/" "$STATICPERL/lib" |
268 | |
306 | |
269 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
307 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
270 | rm -rf "$PERL_PREFIX" # by this rm -rf |
308 | rm -rf "$PERL_PREFIX" # by this rm -rf |
271 | |
309 | |
272 | make install || fatal "make install: error while installing" |
310 | "$MAKE" install || fatal "make install: error while installing" |
273 | |
311 | |
274 | rcd "$PERL_PREFIX" |
312 | rcd "$PERL_PREFIX" |
275 | |
313 | |
276 | # create a "make install" replacement for CPAN |
314 | # create a "make install" replacement for CPAN |
277 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
315 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
278 | make || exit |
316 | "$MAKE" || exit |
279 | |
317 | |
280 | if find blib/arch/auto -type f | grep -q -v .exists; then |
318 | if find blib/arch/auto -type f | grep -q -v .exists; then |
281 | echo Probably an XS module, rebuilding perl |
319 | echo Probably an XS module, rebuilding perl |
282 | if make perl; then |
320 | if "$MAKE" perl; then |
283 | mv perl "$PERL_PREFIX"/bin/perl |
321 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
|
|
322 | && rm -f "$PERL_PREFIX"/bin/perl \ |
|
|
323 | && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl |
284 | make -f Makefile.aperl map_clean |
324 | "$MAKE" -f Makefile.aperl map_clean |
285 | else |
325 | else |
286 | make -f Makefile.aperl map_clean |
326 | "$MAKE" -f Makefile.aperl map_clean |
287 | exit 1 |
327 | exit 1 |
288 | fi |
328 | fi |
289 | fi |
329 | fi |
290 | |
330 | |
291 | make install UNINST=1 |
331 | "$MAKE" install UNINST=1 |
292 | EOF |
332 | EOF |
293 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
333 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
294 | |
334 | |
295 | # trick CPAN into avoiding ~/.cpan completely |
335 | # trick CPAN into avoiding ~/.cpan completely |
296 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
336 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
… | |
… | |
356 | for mod in "$@"; do |
396 | for mod in "$@"; do |
357 | echo |
397 | echo |
358 | echo $mod |
398 | echo $mod |
359 | ( |
399 | ( |
360 | rcd $mod |
400 | rcd $mod |
361 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
401 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
362 | make distclean >/dev/null 2>&1 |
402 | "$MAKE" distclean >/dev/null 2>&1 |
363 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
403 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
364 | make || fatal "$mod: error building module" |
404 | "$MAKE" || fatal "$mod: error building module" |
365 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
405 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
366 | make distclean >/dev/null 2>&1 |
406 | "$MAKE" distclean >/dev/null 2>&1 |
367 | exit 0 |
407 | exit 0 |
368 | ) || exit $? |
408 | ) || exit $? |
369 | done |
409 | done |
370 | } |
410 | } |
371 | |
411 | |
… | |
… | |
419 | command="${1#--}"; shift |
459 | command="${1#--}"; shift |
420 | case "$command" in |
460 | case "$command" in |
421 | version ) |
461 | version ) |
422 | echo "staticperl version $VERSION" |
462 | echo "staticperl version $VERSION" |
423 | ;; |
463 | ;; |
424 | fetch | configure | build | install | clean | distclean) |
464 | fetch | configure | build | install | clean | realclean | distclean) |
425 | ( "$command" ) |
465 | ( "$command" ) || exit |
426 | ;; |
466 | ;; |
427 | instsrc ) |
467 | instsrc ) |
428 | ( instsrc "$@" ) |
468 | ( instsrc "$@" ) || exit |
429 | exit |
469 | exit |
430 | ;; |
470 | ;; |
431 | instcpan ) |
471 | instcpan ) |
432 | ( instcpan "$@" ) |
472 | ( instcpan "$@" ) || exit |
433 | exit |
473 | exit |
434 | ;; |
474 | ;; |
435 | cpan ) |
475 | cpan ) |
436 | ( install ) |
476 | ( install ) || exit |
437 | "$PERL_PREFIX/bin/cpan" "$@" |
477 | "$PERL_PREFIX/bin/cpan" "$@" |
438 | exit |
478 | exit |
439 | ;; |
479 | ;; |
440 | mkbundle ) |
480 | mkbundle ) |
441 | ( install ) |
481 | ( install ) || exit |
442 | bundle "$@" |
482 | bundle "$@" |
443 | exit |
483 | exit |
444 | ;; |
484 | ;; |
445 | mkperl ) |
485 | mkperl ) |
446 | ( install ) |
486 | ( install ) || exit |
447 | bundle --perl "$@" |
487 | bundle --perl "$@" |
448 | exit |
488 | exit |
449 | ;; |
489 | ;; |
450 | mkapp ) |
490 | mkapp ) |
451 | ( install ) |
491 | ( install ) || exit |
452 | bundle --app "$@" |
492 | bundle --app "$@" |
453 | exit |
493 | exit |
454 | ;; |
494 | ;; |
455 | help ) |
495 | help ) |
456 | podusage 2 |
496 | podusage 2 |