… | |
… | |
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.2 # 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_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" |
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 |
21 | i*86 | x86_64 | amd64 ) |
21 | i*86 | x86_64 | amd64 ) |
22 | #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 |
23 | PERL_OPTIMIZE="$PERL_OPTIMIZE" # x86/amd64 |
|
|
24 | case "$ARCH" in |
23 | case "$ARCH" in |
25 | i*86 ) |
24 | i*86 ) |
26 | 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 |
27 | ;; |
26 | ;; |
28 | esac |
27 | esac |
… | |
… | |
34 | # --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 |
35 | PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
34 | PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
36 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
35 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | |
36 | |
38 | # some configuration options for modules |
37 | # some configuration options for modules |
39 | export PERL_MM_USE_DEFAULT=1 |
38 | PERL_MM_USE_DEFAULT=1 |
40 | #export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
39 | #CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
41 | 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' |
40 | 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 | export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS |
42 | |
42 | |
43 | # which extra modules to install by default from CPAN that are |
43 | # which extra modules to install by default from CPAN that are |
44 | # required by mkbundle |
44 | # required by mkbundle |
45 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
45 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
46 | |
46 | |
… | |
… | |
67 | |
67 | |
68 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
68 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
69 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
69 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
70 | |
70 | |
71 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
71 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
72 | export LC_ALL=C # just to be on the safe side |
72 | LC_ALL=C; export LC_ALL # just to be on the safe side |
73 | |
73 | |
74 | # set version in a way that Makefile.PL can extract |
74 | # set version in a way that Makefile.PL can extract |
75 | VERSION=VERSION; eval \ |
75 | VERSION=VERSION; eval \ |
76 | $VERSION=0.911 |
76 | $VERSION=0.92 |
77 | |
77 | |
78 | BZ2=bz2 |
78 | BZ2=bz2 |
79 | BZIP2=bzip2 |
79 | BZIP2=bzip2 |
80 | |
80 | |
81 | fatal() { |
81 | fatal() { |
… | |
… | |
127 | |
127 | |
128 | clean() { |
128 | clean() { |
129 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
129 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
130 | } |
130 | } |
131 | |
131 | |
|
|
132 | realclean() { |
|
|
133 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
|
|
134 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
135 | rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
|
|
136 | } |
|
|
137 | |
132 | fetch() { |
138 | fetch() { |
133 | rcd "$STATICPERL" |
139 | rcd "$STATICPERL" |
134 | |
140 | |
135 | mkdir -p src |
141 | mkdir -p src |
136 | rcd src |
142 | rcd src |
… | |
… | |
146 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
152 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
147 | trying $URL |
153 | trying $URL |
148 | EOF |
154 | EOF |
149 | |
155 | |
150 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
156 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
|
|
157 | curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
151 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
158 | || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
152 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
|
|
153 | || fatal "$URL: unable to download" |
159 | || fatal "$URL: unable to download" |
154 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
160 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
155 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
161 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
156 | fi |
162 | fi |
157 | |
163 | |
… | |
… | |
174 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
180 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
175 | rm -f "$2" |
181 | rm -f "$2" |
176 | mv "$2~" "$2" |
182 | mv "$2~" "$2" |
177 | } |
183 | } |
178 | |
184 | |
|
|
185 | configure_failure() { |
|
|
186 | cat <<EOF |
|
|
187 | |
|
|
188 | |
|
|
189 | *** |
|
|
190 | *** Configure failed - see above for the exact error message(s). |
|
|
191 | *** |
|
|
192 | *** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
|
|
193 | *** flags are not supported by your compiler. Less often, this is because |
|
|
194 | *** PERL_LIBS either contains a library not available on your system (such as |
|
|
195 | *** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
|
|
196 | *** |
|
|
197 | *** You can provide your own flags by creating a ~/.staticperlrc file with |
|
|
198 | *** variable assignments. For example (these are the actual values used): |
|
|
199 | *** |
|
|
200 | |
|
|
201 | PERL_CC="$PERL_CC" |
|
|
202 | PERL_CCFLAGS="$PERL_CCFLAGS" |
|
|
203 | PERL_OPTIMIZE="$PERL_OPTIMIZE" |
|
|
204 | PERL_LDFLAGS="$PERL_LDFLAGS" |
|
|
205 | PERL_LIBS="$PERL_LIBS" |
|
|
206 | |
|
|
207 | EOF |
|
|
208 | exit 1 |
|
|
209 | } |
|
|
210 | |
179 | configure() { |
211 | configure() { |
180 | fetch |
212 | fetch |
181 | |
213 | |
182 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
214 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
183 | |
215 | |
… | |
… | |
189 | |
221 | |
190 | rm -f "$PERL_PREFIX/staticstamp.install" |
222 | rm -f "$PERL_PREFIX/staticstamp.install" |
191 | |
223 | |
192 | "$MAKE" distclean >/dev/null 2>&1 |
224 | "$MAKE" distclean >/dev/null 2>&1 |
193 | |
225 | |
|
|
226 | sedreplace '/^#define SITELIB/d' config_h.SH |
|
|
227 | |
194 | # I hate them |
228 | # I hate them for this |
195 | grep -q -- -fstack-protector Configure && \ |
229 | grep -q -- -fstack-protector Configure && \ |
196 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
230 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
197 | |
231 | |
198 | preconfigure |
232 | preconfigure |
199 | |
233 | |
… | |
… | |
205 | -Uusethreads \ |
239 | -Uusethreads \ |
206 | -Uuseithreads \ |
240 | -Uuseithreads \ |
207 | -Uusemultiplicity \ |
241 | -Uusemultiplicity \ |
208 | -Uusesfio \ |
242 | -Uusesfio \ |
209 | -Uuseshrplib \ |
243 | -Uuseshrplib \ |
|
|
244 | -A ccflags=" $PERL_CCFLAGS" \ |
210 | -Dcc="$PERL_CC" \ |
245 | -Dcc="$PERL_CC" \ |
211 | -Dcppflags="$PERL_CPPFLAGS" \ |
|
|
212 | -Dccflags="-g2 -fno-strict-aliasing" \ |
|
|
213 | -Doptimize="$PERL_OPTIMIZE" \ |
246 | -Doptimize="$PERL_OPTIMIZE" \ |
214 | -Dldflags="$PERL_LDFLAGS" \ |
247 | -Dldflags="$PERL_LDFLAGS" \ |
215 | -Dlibs="$PERL_LIBS" \ |
248 | -Dlibs="$PERL_LIBS" \ |
216 | -Dprefix="$PERL_PREFIX" \ |
249 | -Dprefix="$PERL_PREFIX" \ |
217 | -Dbin="$PERL_PREFIX/bin" \ |
250 | -Dbin="$PERL_PREFIX/bin" \ |
218 | -Dprivlib="$PERL_PREFIX/lib" \ |
251 | -Dprivlib="$PERL_PREFIX/lib" \ |
219 | -Darchlib="$PERL_PREFIX/lib" \ |
252 | -Darchlib="$PERL_PREFIX/lib" \ |
220 | -Uusevendorprefix \ |
253 | -Uusevendorprefix \ |
221 | -Dsitelib="$PERL_PREFIX/lib" \ |
254 | -Dsitelib="$PERL_PREFIX/lib" \ |
222 | -Dsitearch="$PERL_PREFIX/lib" \ |
255 | -Dsitearch="$PERL_PREFIX/lib" \ |
223 | -Usitelibexp \ |
|
|
224 | -Uman1dir \ |
256 | -Uman1dir \ |
225 | -Uman3dir \ |
257 | -Uman3dir \ |
226 | -Usiteman1dir \ |
258 | -Usiteman1dir \ |
227 | -Usiteman3dir \ |
259 | -Usiteman3dir \ |
228 | -Dpager=/usr/bin/less \ |
260 | -Dpager=/usr/bin/less \ |
229 | -Demail="$EMAIL" \ |
261 | -Demail="$EMAIL" \ |
230 | -Dcf_email="$EMAIL" \ |
262 | -Dcf_email="$EMAIL" \ |
231 | -Dcf_by="$EMAIL" \ |
263 | -Dcf_by="$EMAIL" \ |
232 | $PERL_CONFIGURE \ |
264 | $PERL_CONFIGURE \ |
233 | -Duseperlio \ |
265 | -Duseperlio \ |
234 | -dE || fatal "Configure failed" |
266 | -dE || configure_failure |
235 | |
267 | |
236 | sedreplace ' |
268 | sedreplace ' |
237 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
269 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
238 | s/ *-fno-stack-protector */ /g |
270 | s/ *-fno-stack-protector */ /g |
239 | ' config.sh |
271 | ' config.sh |
… | |
… | |
428 | command="${1#--}"; shift |
460 | command="${1#--}"; shift |
429 | case "$command" in |
461 | case "$command" in |
430 | version ) |
462 | version ) |
431 | echo "staticperl version $VERSION" |
463 | echo "staticperl version $VERSION" |
432 | ;; |
464 | ;; |
433 | fetch | configure | build | install | clean | distclean) |
465 | fetch | configure | build | install | clean | realclean | distclean) |
434 | ( "$command" ) |
466 | ( "$command" ) || exit |
435 | ;; |
467 | ;; |
436 | instsrc ) |
468 | instsrc ) |
437 | ( instsrc "$@" ) |
469 | ( instsrc "$@" ) || exit |
438 | exit |
470 | exit |
439 | ;; |
471 | ;; |
440 | instcpan ) |
472 | instcpan ) |
441 | ( instcpan "$@" ) |
473 | ( instcpan "$@" ) || exit |
442 | exit |
474 | exit |
443 | ;; |
475 | ;; |
444 | cpan ) |
476 | cpan ) |
445 | ( install ) |
477 | ( install ) || exit |
446 | "$PERL_PREFIX/bin/cpan" "$@" |
478 | "$PERL_PREFIX/bin/cpan" "$@" |
447 | exit |
479 | exit |
448 | ;; |
480 | ;; |
449 | mkbundle ) |
481 | mkbundle ) |
450 | ( install ) |
482 | ( install ) || exit |
451 | bundle "$@" |
483 | bundle "$@" |
452 | exit |
484 | exit |
453 | ;; |
485 | ;; |
454 | mkperl ) |
486 | mkperl ) |
455 | ( install ) |
487 | ( install ) || exit |
456 | bundle --perl "$@" |
488 | bundle --perl "$@" |
457 | exit |
489 | exit |
458 | ;; |
490 | ;; |
459 | mkapp ) |
491 | mkapp ) |
460 | ( install ) |
492 | ( install ) || exit |
461 | bundle --app "$@" |
493 | bundle --app "$@" |
462 | exit |
494 | exit |
463 | ;; |
495 | ;; |
464 | help ) |
496 | help ) |
465 | podusage 2 |
497 | podusage 2 |