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