1 | #!/bin/sh |
1 | #!/bin/sh |
2 | |
2 | |
3 | ############################################################################# |
3 | ############################################################################# |
4 | # configuration to fill in |
4 | # configuration to fill in (or to replace in your .staticperlrc) |
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 | DLCACHE= |
10 | MKBUNDLE="$STATICPERL/mkbundle" |
|
|
11 | |
10 | |
12 | # perl build variables |
11 | # perl build variables |
13 | PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed |
12 | MAKE=make |
14 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
13 | PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds |
|
|
14 | PERL_CC=cc |
15 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CONFIGURE="" # additional Configure arguments |
16 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
16 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
17 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
18 | |
18 | |
19 | ARCH="$(uname -m)" |
19 | ARCH="$(uname -m)" |
20 | |
20 | |
21 | case "$ARCH" in |
21 | #case "$ARCH" in |
22 | i*86 | x86_64 | amd64 ) |
22 | # i*86 | x86_64 | amd64 ) |
23 | PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 |
23 | # PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 |
24 | case "$ARCH" in |
24 | # case "$ARCH" in |
25 | i*86 ) |
25 | # i*86 ) |
26 | PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only |
26 | # PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only |
27 | ;; |
27 | # ;; |
28 | esac |
28 | # esac |
29 | ;; |
29 | # ;; |
30 | esac |
30 | #esac |
31 | |
31 | |
32 | # -Wl,--gc-sections makes it impossible to check for undefined references |
32 | # -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 :/ |
33 | # 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 |
34 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
35 | PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" |
35 | #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
|
|
36 | PERL_LDFLAGS= |
36 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | |
38 | |
38 | # some configuration options for modules |
39 | # some configuration options for modules |
39 | export PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_USE_DEFAULT=1 |
|
|
41 | PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
40 | #export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
42 | #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' |
43 | #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' |
|
|
44 | export PERL_MM_USE_DEFAULT PERL_MM_OPT |
42 | |
45 | |
43 | # which extra modules to install by default from CPAN that are |
46 | # which extra modules to install by default from CPAN that are |
44 | # required by mkbundle |
47 | # required by mkbundle |
45 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
48 | STATICPERL_MODULES="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI PPI::XS Pod::Usage" |
46 | |
49 | |
47 | # which extra modules you might want to install |
50 | # which extra modules you might want to install |
48 | EXTRA_MODULES="" |
51 | EXTRA_MODULES="" |
49 | |
52 | |
50 | # overridable functions |
53 | # overridable functions |
51 | preconfigure() { : ; } |
54 | preconfigure() { : ; } |
|
|
55 | patchconfig() { : ; } |
52 | postconfigure() { : ; } |
56 | postconfigure() { : ; } |
53 | postbuild() { : ; } |
57 | postbuild() { : ; } |
|
|
58 | postcpanconfig() { : ; } |
54 | postinstall() { : ; } |
59 | postinstall() { : ; } |
55 | |
60 | |
56 | # now source user config, if any |
61 | # now source user config, if any |
|
|
62 | if [ "$STATICPERLRC" ]; then |
|
|
63 | . "$STATICPERLRC" |
|
|
64 | else |
57 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
65 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
58 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
66 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
59 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
67 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
|
|
68 | fi |
60 | |
69 | |
61 | ############################################################################# |
70 | ############################################################################# |
62 | # support |
71 | # support |
63 | |
72 | |
|
|
73 | # work around ExtUtils::CBuilder and others |
|
|
74 | export CC="$PERL_CC" |
|
|
75 | export CFLAGS="$PERL_CFLAGS" |
|
|
76 | export LD="$PERL_CC" |
|
|
77 | export LDFLAGS="$PERL_LDFLAGS" |
|
|
78 | unset LIBS |
|
|
79 | |
|
|
80 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
|
|
81 | |
64 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
82 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
83 | unset PERL_MB_OPT |
65 | export LC_ALL=C # just to be on the safe side |
84 | LC_ALL=C; export LC_ALL # just to be on the safe side |
|
|
85 | |
|
|
86 | # prepend PATH - not required by staticperl itself, but might make |
|
|
87 | # life easier when working in e.g. "staticperl cpan / look" |
|
|
88 | PATH="$PERL_PREFIX/perl/bin:$PATH" |
66 | |
89 | |
67 | # set version in a way that Makefile.PL can extract |
90 | # set version in a way that Makefile.PL can extract |
68 | VERSION=VERSION; eval \ |
91 | VERSION=VERSION; eval \ |
69 | $VERSION=0.9 |
92 | $VERSION="1.46" |
70 | |
|
|
71 | BZ2=bz2 |
|
|
72 | BZIP2=bzip2 |
|
|
73 | |
93 | |
74 | fatal() { |
94 | fatal() { |
75 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
95 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
76 | exit 1 |
96 | exit 1 |
77 | } |
97 | } |
… | |
… | |
107 | ############################################################################# |
127 | ############################################################################# |
108 | # clean |
128 | # clean |
109 | |
129 | |
110 | distclean() { |
130 | distclean() { |
111 | verblock <<EOF |
131 | verblock <<EOF |
112 | deleting everything installed by this script |
132 | deleting everything installed by this script (rm -rf $STATICPERL) |
113 | EOF |
133 | EOF |
114 | |
134 | |
115 | rm -rf "$STATICPERL" |
135 | rm -rf "$STATICPERL" |
116 | } |
136 | } |
117 | |
137 | |
118 | ############################################################################# |
138 | ############################################################################# |
119 | # download/configure/compile/install perl |
139 | # download/configure/compile/install perl |
120 | |
140 | |
121 | clean() { |
141 | clean() { |
122 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
142 | rm -rf "$STATICPERL/src" |
|
|
143 | } |
|
|
144 | |
|
|
145 | realclean() { |
|
|
146 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
|
|
147 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
148 | rm -f "$STATICPERL/src/perl/staticstamp.configure" |
123 | } |
149 | } |
124 | |
150 | |
125 | fetch() { |
151 | fetch() { |
|
|
152 | ( |
126 | rcd "$STATICPERL" |
153 | rcd "$STATICPERL" |
127 | |
154 | |
128 | mkdir -p src |
155 | mkdir -p src |
129 | rcd src |
156 | rcd src |
130 | |
157 | |
131 | if ! [ -d "perl-$PERL_VERSION" ]; then |
158 | if ! [ -d "perl" ]; then |
132 | if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
159 | rm -rf unpack |
|
|
160 | mkdir -p unpack |
133 | |
161 | |
|
|
162 | case "$PERL_VERSION" in |
|
|
163 | *:* ) |
|
|
164 | # url |
|
|
165 | PERLURL="$PERL_VERSION" |
|
|
166 | PERLTAR="$(basename "$PERL_VERSION")" |
|
|
167 | ;; |
|
|
168 | /* ) |
|
|
169 | # directory |
|
|
170 | verbose "copying $PERL_VERSION" |
|
|
171 | cp -Rp "$PERL_VERSION/." unpack/. |
|
|
172 | chmod -R u+w unpack |
|
|
173 | mv unpack perl |
|
|
174 | return |
|
|
175 | ;; |
|
|
176 | * ) |
134 | URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" |
177 | PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2" |
|
|
178 | PERLTAR=perl-$PERL_VERSION.tar.bz2 |
|
|
179 | ;; |
|
|
180 | esac |
135 | |
181 | |
|
|
182 | if ! [ -e "$PERLTAR" ]; then |
136 | verblock <<EOF |
183 | verblock <<EOF |
137 | downloading perl |
184 | downloading perl |
|
|
185 | |
|
|
186 | trying to download from $PERLURL |
|
|
187 | |
|
|
188 | you can configure a download cache directory via DLCACHE |
|
|
189 | in your .staticperlrc to avoid repeated downloads. |
|
|
190 | |
138 | to manually download perl yourself, place |
191 | to manually download perl yourself, place a suitable tarball in |
139 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
192 | $DLCACHE/$PERLTAR |
140 | trying $URL |
|
|
141 | EOF |
|
|
142 | |
193 | |
|
|
194 | either curl or wget is required for automatic download. |
|
|
195 | curl is tried first, then wget. |
|
|
196 | EOF |
|
|
197 | |
143 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
198 | rm -f $PERLTAR~ # just to be on the safe side |
144 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
199 | { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
145 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
200 | || wget -O $PERLTAR~ "$PERLURL" \ |
|
|
201 | || curl -f >$PERLTAR~ "$PERLURL" \ |
146 | || fatal "$URL: unable to download" |
202 | || fatal "$URL: unable to download" |
147 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
203 | rm -f $PERLTAR |
|
|
204 | mv $PERLTAR~ $PERLTAR |
|
|
205 | if [ "$DLCACHE" ]; then |
|
|
206 | mkdir -p "$DLCACHE" |
|
|
207 | cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \ |
|
|
208 | mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR |
|
|
209 | fi |
148 | fi |
210 | fi |
149 | |
211 | |
150 | verblock <<EOF |
212 | verblock <<EOF |
151 | unpacking perl |
213 | unpacking perl |
152 | EOF |
214 | EOF |
153 | |
215 | |
154 | mkdir -p unpack |
216 | case "$PERLTAR" in |
155 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ |
217 | *.xz ) UNCOMPRESS="xz -d" ;; |
|
|
218 | *.lzma ) UNCOMPRESS="lzma -d" ;; |
|
|
219 | *.bz2 ) UNCOMPRESS="bzip2 -d" ;; |
|
|
220 | *.gz ) UNCOMPRESS="gzip -d" ;; |
|
|
221 | *.tar ) UNCOMPRESS="cat" ;; |
|
|
222 | * ) |
|
|
223 | fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." |
|
|
224 | exit 1 |
|
|
225 | ;; |
|
|
226 | esac |
|
|
227 | |
|
|
228 | <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ |
156 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
229 | || fatal "$PERLTAR: error during unpacking" |
157 | chmod -R u+w unpack/perl-$PERL_VERSION |
230 | |
158 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
231 | if [ -d unpack/*/ ]; then |
|
|
232 | chmod -R u+w unpack/*/ |
|
|
233 | mv unpack/*/ perl |
159 | rmdir -p unpack |
234 | rmdir -p unpack |
|
|
235 | else |
|
|
236 | fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" |
|
|
237 | fi |
|
|
238 | |
|
|
239 | rm "$PERLTAR" |
160 | fi |
240 | fi |
|
|
241 | ) || exit |
161 | } |
242 | } |
162 | |
243 | |
163 | # similar to GNU-sed -i or perl -pi |
244 | # similar to GNU-sed -i or perl -pi |
164 | sedreplace() { |
245 | sedreplace() { |
165 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
246 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
|
|
247 | rm -f "$2" |
166 | mv "$2~" "$2" |
248 | mv "$2~" "$2" |
167 | } |
249 | } |
168 | |
250 | |
|
|
251 | configure_failure() { |
|
|
252 | cat <<EOF |
|
|
253 | |
|
|
254 | |
|
|
255 | *** |
|
|
256 | *** Configure failed - see above for the exact error message(s). |
|
|
257 | *** |
|
|
258 | *** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
|
|
259 | *** flags are not supported by your compiler. Less often, this is because |
|
|
260 | *** PERL_LIBS either contains a library not available on your system (such as |
|
|
261 | *** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
|
|
262 | *** |
|
|
263 | *** You can provide your own flags by creating a ~/.staticperlrc file with |
|
|
264 | *** variable assignments. For example (these are the actual values used): |
|
|
265 | *** |
|
|
266 | |
|
|
267 | PERL_CC="$PERL_CC" |
|
|
268 | PERL_CCFLAGS="$PERL_CCFLAGS" |
|
|
269 | PERL_OPTIMIZE="$PERL_OPTIMIZE" |
|
|
270 | PERL_LDFLAGS="$PERL_LDFLAGS" |
|
|
271 | PERL_LIBS="$PERL_LIBS" |
|
|
272 | |
|
|
273 | EOF |
|
|
274 | exit 1 |
|
|
275 | } |
|
|
276 | |
169 | configure() { |
277 | configure() { |
|
|
278 | ( |
170 | fetch |
279 | fetch |
171 | |
280 | |
172 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
281 | rcd "$STATICPERL/src/perl" |
173 | |
282 | |
174 | [ -e staticstamp.configure ] && return |
283 | [ -e staticstamp.configure ] && return |
175 | |
284 | |
176 | verblock <<EOF |
285 | verblock <<EOF |
177 | configuring $STATICPERL/src/perl-$PERL_VERSION |
286 | configuring $STATICPERL/src/perl |
178 | EOF |
287 | EOF |
179 | |
288 | |
180 | rm -f "$PERL_PREFIX/staticstamp.install" |
289 | rm -f "$PERL_PREFIX/staticstamp.install" |
181 | |
290 | |
182 | make distclean >/dev/null 2>&1 |
291 | "$MAKE" distclean >/dev/null 2>&1 |
183 | |
292 | |
|
|
293 | sedreplace '/^#define SITELIB/d' config_h.SH |
|
|
294 | |
184 | # I hate them |
295 | # I hate them for this |
185 | grep -q -- -fstack-protector Configure && \ |
296 | grep -q -- -fstack-protector Configure && \ |
186 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
297 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
187 | |
298 | |
188 | preconfigure |
299 | # what did that bloke think |
|
|
300 | grep -q -- usedl=.define hints/darwin.sh && \ |
|
|
301 | sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
|
|
302 | |
|
|
303 | preconfigure || fatal "preconfigure hook failed" |
189 | |
304 | |
190 | # trace configure \ |
305 | # trace configure \ |
191 | sh Configure -Duselargefiles \ |
306 | sh Configure -Duselargefiles \ |
192 | -Uuse64bitint \ |
307 | -Uuse64bitint \ |
193 | -Dusemymalloc=n \ |
308 | -Dusemymalloc=n \ |
194 | -Uusedl \ |
309 | -Uusedl \ |
195 | -Uusethreads \ |
310 | -Uusethreads \ |
196 | -Uuseithreads \ |
311 | -Uuseithreads \ |
197 | -Uusemultiplicity \ |
312 | -Uusemultiplicity \ |
198 | -Duseperlio \ |
|
|
199 | -Uusesfio \ |
313 | -Uusesfio \ |
200 | -Uuseshrplib \ |
314 | -Uuseshrplib \ |
|
|
315 | -Uinstallusrbinperl \ |
201 | -Dcppflags="$PERL_CPPFLAGS" \ |
316 | -A ccflags=" $PERL_CCFLAGS" \ |
202 | -Dccflags="-g2 -fno-strict-aliasing" \ |
317 | -Dcc="$PERL_CC" \ |
203 | -Doptimize="$PERL_OPTIMIZE" \ |
318 | -Doptimize="$PERL_OPTIMIZE" \ |
204 | -Dldflags="$PERL_LDFLAGS" \ |
319 | -Dldflags="$PERL_LDFLAGS" \ |
205 | -Dlibs="$PERL_LIBS" \ |
320 | -Dlibs="$PERL_LIBS" \ |
206 | -Dprefix="$PERL_PREFIX" \ |
321 | -Dprefix="$PERL_PREFIX" \ |
207 | -Dbin="$PERL_PREFIX/bin" \ |
322 | -Dbin="$PERL_PREFIX/bin" \ |
208 | -Dprivlib="$PERL_PREFIX/lib" \ |
323 | -Dprivlib="$PERL_PREFIX/lib" \ |
209 | -Darchlib="$PERL_PREFIX/lib" \ |
324 | -Darchlib="$PERL_PREFIX/lib" \ |
210 | -Uusevendorprefix \ |
325 | -Uusevendorprefix \ |
211 | -Dsitelib="$PERL_PREFIX/lib" \ |
326 | -Dsitelib="$PERL_PREFIX/lib" \ |
212 | -Dsitearch="$PERL_PREFIX/lib" \ |
327 | -Dsitearch="$PERL_PREFIX/lib" \ |
213 | -Usitelibexp \ |
|
|
214 | -Uman1dir \ |
328 | -Uman1dir \ |
215 | -Uman3dir \ |
329 | -Uman3dir \ |
216 | -Usiteman1dir \ |
330 | -Usiteman1dir \ |
217 | -Usiteman3dir \ |
331 | -Usiteman3dir \ |
218 | -Dpager=/usr/bin/less \ |
332 | -Dpager=/usr/bin/less \ |
219 | -Demail="$EMAIL" \ |
333 | -Demail="$EMAIL" \ |
220 | -Dcf_email="$EMAIL" \ |
334 | -Dcf_email="$EMAIL" \ |
221 | -Dcf_by="$EMAIL" \ |
335 | -Dcf_by="$EMAIL" \ |
222 | $PERL_CONFIGURE \ |
336 | $PERL_CONFIGURE \ |
|
|
337 | -Duseperlio \ |
|
|
338 | -Uversiononly \ |
223 | -dE || fatal "Configure failed" |
339 | -dE || configure_failure |
224 | |
340 | |
225 | sedreplace ' |
341 | sedreplace ' |
226 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
342 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
227 | s/ *-fno-stack-protector */ /g |
343 | s/ *-fno-stack-protector */ /g |
228 | ' config.sh |
344 | ' config.sh |
229 | |
345 | |
|
|
346 | patchconfig || fatal "patchconfig hook failed" |
|
|
347 | |
230 | sh Configure -S || fatal "Configure -S failed" |
348 | sh Configure -S || fatal "Configure -S failed" |
231 | |
349 | |
232 | postconfigure || fatal "postconfigure hook failed" |
350 | postconfigure || fatal "postconfigure hook failed" |
233 | |
351 | |
234 | touch staticstamp.configure |
352 | : > staticstamp.configure |
|
|
353 | ) || exit |
|
|
354 | } |
|
|
355 | |
|
|
356 | write_shellscript() { |
|
|
357 | { |
|
|
358 | echo "#!/bin/sh" |
|
|
359 | echo "STATICPERL=\"$STATICPERL\"" |
|
|
360 | echo "PERL_PREFIX=\"$PERL_PREFIX\"" |
|
|
361 | echo "MAKE=\"$MAKE\"" |
|
|
362 | cat |
|
|
363 | } >"$PERL_PREFIX/bin/$1" |
|
|
364 | chmod 755 "$PERL_PREFIX/bin/$1" |
235 | } |
365 | } |
236 | |
366 | |
237 | build() { |
367 | build() { |
|
|
368 | ( |
238 | configure |
369 | configure |
239 | |
370 | |
240 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
371 | rcd "$STATICPERL/src/perl" |
241 | |
372 | |
242 | verblock <<EOF |
373 | verblock <<EOF |
243 | building $STATICPERL/src/perl-$PERL_VERSION |
374 | building $STATICPERL/src/perl |
244 | EOF |
375 | EOF |
245 | |
376 | |
246 | rm -f "$PERL_PREFIX/staticstamp.install" |
377 | rm -f "$PERL_PREFIX/staticstamp.install" |
247 | |
378 | |
248 | make || fatal "make: error while building perl" |
379 | "$MAKE" || fatal "make: error while building perl" |
249 | |
380 | |
250 | postbuild || fatal "postbuild hook failed" |
381 | postbuild || fatal "postbuild hook failed" |
|
|
382 | ) || exit |
|
|
383 | } |
|
|
384 | |
|
|
385 | _postinstall() { |
|
|
386 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
|
|
387 | NOCHECK_INSTALL=+ |
|
|
388 | instcpan $STATICPERL_MODULES |
|
|
389 | [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES |
|
|
390 | |
|
|
391 | postinstall || fatal "postinstall hook failed" |
|
|
392 | |
|
|
393 | : > "$PERL_PREFIX/staticstamp.postinstall" |
|
|
394 | fi |
251 | } |
395 | } |
252 | |
396 | |
253 | install() { |
397 | install() { |
|
|
398 | ( |
254 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
399 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
255 | build |
400 | build |
256 | |
401 | |
257 | verblock <<EOF |
402 | verblock <<EOF |
258 | installing $STATICPERL/src/perl-$PERL_VERSION |
403 | installing $STATICPERL/src/perl |
259 | to $PERL_PREFIX |
404 | to $PERL_PREFIX |
260 | EOF |
405 | EOF |
261 | |
406 | |
262 | rm -rf "$PERL_PREFIX" |
407 | ln -sf "perl/bin/" "$STATICPERL/bin" |
263 | |
408 | ln -sf "perl/lib/" "$STATICPERL/lib" |
|
|
409 | |
|
|
410 | mkdir "$STATICPERL/patched" |
|
|
411 | |
|
|
412 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
|
|
413 | rm -rf "$PERL_PREFIX" # by this rm -rf |
|
|
414 | |
|
|
415 | rcd "$STATICPERL/src/perl" |
|
|
416 | |
264 | make install || fatal "make install: error while installing" |
417 | "$MAKE" install || fatal "make install: error while installing" |
265 | |
418 | |
266 | rcd "$PERL_PREFIX" |
419 | rcd "$PERL_PREFIX" |
267 | |
420 | |
268 | # create a "make install" replacement for CPAN |
421 | # create a "make install" replacement for CPAN |
269 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
422 | write_shellscript SP-make-make <<'end_of_make' |
270 | make || exit |
423 | #CAT make-make.sh |
|
|
424 | end_of_make |
271 | |
425 | |
272 | if find blib/arch/auto -type f | grep -q -v .exists; then |
426 | # create a "make install" replacement for CPAN |
273 | echo Probably an XS module, rebuilding perl |
427 | write_shellscript SP-make-install-make <<'end_of_make_install_make' |
274 | if make perl; then |
428 | #CAT make-install-make.sh |
275 | mv perl "$PERL_PREFIX"/bin/perl |
429 | end_of_make_install_make |
276 | make -f Makefile.aperl map_clean |
|
|
277 | else |
|
|
278 | make -f Makefile.aperl map_clean |
|
|
279 | exit 1 |
|
|
280 | fi |
|
|
281 | fi |
|
|
282 | |
430 | |
283 | make install UNINST=1 |
431 | # create a "patch modules" helper |
284 | EOF |
432 | write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall' |
285 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
433 | #CAT patch-postinstall.sh |
|
|
434 | end_of_patch_postinstall |
286 | |
435 | |
|
|
436 | # immediately use it |
|
|
437 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
|
|
438 | |
287 | # trick CPAN into avoiding ~/.cpan completely |
439 | # help to trick CPAN into avoiding ~/.cpan completely |
288 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
440 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
289 | |
441 | |
|
|
442 | # we call cpan with -MCPAN::MyConfig in this script, which |
|
|
443 | # is strictly unnecessary as we have to patch CPAN anyway, |
|
|
444 | # so consider it "for good measure". |
290 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
445 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
291 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
446 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
|
|
447 | CPAN::Shell->o (conf => pushy_https => "0"); |
292 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
448 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
293 | CPAN::Shell->o (conf => q<init>); |
449 | CPAN::Shell->o (conf => q<init>); |
294 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
450 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
295 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
451 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
296 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
452 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
297 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
453 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
298 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
454 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
|
|
455 | CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); |
|
|
456 | CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make"); |
299 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
457 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
300 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
458 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
301 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
459 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); |
|
|
460 | CPAN::Shell->o (conf => q<recommends_policy>, q<0>); |
|
|
461 | CPAN::Shell->o (conf => q<suggests_policy>, q<0>); |
|
|
462 | CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>); |
302 | CPAN::Shell->o (conf => q<commit>); |
463 | CPAN::Shell->o (conf => q<commit>); |
303 | ' || fatal "error while initialising CPAN" |
464 | ' || fatal "error while initialising CPAN" |
304 | |
465 | |
|
|
466 | postcpanconfig |
|
|
467 | |
305 | touch "$PERL_PREFIX/staticstamp.install" |
468 | : > "$PERL_PREFIX/staticstamp.install" |
306 | fi |
469 | fi |
307 | |
470 | |
|
|
471 | _postinstall |
|
|
472 | ) || exit |
|
|
473 | } |
|
|
474 | |
|
|
475 | import() { |
|
|
476 | ( |
|
|
477 | IMPORT="$1" |
|
|
478 | |
|
|
479 | rcd "$STATICPERL" |
|
|
480 | |
308 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
481 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
309 | NOCHECK_INSTALL=+ |
482 | verblock <<EOF |
310 | instcpan $STATICPERL_MODULES |
483 | import perl from $IMPORT to $STATICPERL |
311 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
484 | EOF |
312 | |
485 | |
313 | postinstall || fatal "postinstall hook failed" |
486 | rm -rf bin cpan lib patched perl src |
|
|
487 | mkdir -m 755 perl perl/bin |
|
|
488 | ln -s perl/bin/ bin |
|
|
489 | ln -s "$IMPORT" perl/bin/ |
314 | |
490 | |
|
|
491 | echo "$IMPORT" > "$PERL_PREFIX/.import" |
|
|
492 | |
315 | touch "$PERL_PREFIX/staticstamp.postinstall" |
493 | : > "$PERL_PREFIX/staticstamp.install" |
316 | fi |
494 | fi |
|
|
495 | |
|
|
496 | _postinstall |
|
|
497 | ) || exit |
317 | } |
498 | } |
318 | |
499 | |
319 | ############################################################################# |
500 | ############################################################################# |
320 | # install a module from CPAN |
501 | # install a module from CPAN |
321 | |
502 | |
322 | instcpan() { |
503 | instcpan() { |
323 | [ $NOCHECK_INSTALL ] || install |
504 | [ $NOCHECK_INSTALL ] || install |
324 | |
505 | |
325 | verblock <<EOF |
506 | verblock <<EOF |
326 | installing modules from CPAN |
507 | installing modules from CPAN |
327 | $@ |
508 | $* |
328 | EOF |
509 | EOF |
329 | |
510 | |
330 | for mod in "$@"; do |
511 | MYCONFIG= |
331 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
512 | [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
332 | || fatal "$mod: unable to install from CPAN" |
513 | |
333 | done |
514 | "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
|
|
515 | |
|
|
516 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
|
|
517 | fatal "failure while installing modules from CPAN ($*)" |
|
|
518 | fi |
334 | rm -rf "$STATICPERL/build" |
519 | rm -f "$STATICPERL/instcpan.log" |
335 | } |
520 | } |
336 | |
521 | |
337 | ############################################################################# |
522 | ############################################################################# |
338 | # install a module from unpacked sources |
523 | # install a module from unpacked sources |
339 | |
524 | |
340 | instsrc() { |
525 | instsrc() { |
341 | [ $NOCHECK_INSTALL ] || install |
526 | [ $NOCHECK_INSTALL ] || install |
342 | |
527 | |
343 | verblock <<EOF |
528 | verblock <<EOF |
344 | installing modules from source |
529 | installing modules from source |
345 | $@ |
530 | $* |
346 | EOF |
531 | EOF |
347 | |
532 | |
348 | for mod in "$@"; do |
533 | for mod in "$@"; do |
349 | echo |
534 | echo |
350 | echo $mod |
535 | echo $mod |
351 | ( |
536 | ( |
352 | rcd $mod |
537 | rcd $mod |
353 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
538 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
354 | make distclean >/dev/null 2>&1 |
539 | "$MAKE" distclean >/dev/null 2>&1 |
355 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
540 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
356 | make || fatal "$mod: error building module" |
541 | "$MAKE" || fatal "$mod: error building module" |
357 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
542 | "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
358 | make distclean >/dev/null 2>&1 |
543 | "$MAKE" distclean >/dev/null 2>&1 |
359 | exit 0 |
544 | exit 0 |
360 | ) || exit $? |
545 | ) || exit $? |
361 | done |
546 | done |
362 | } |
547 | } |
363 | |
548 | |
364 | ############################################################################# |
549 | ############################################################################# |
365 | # main |
550 | # main |
366 | |
551 | |
367 | podusage() { |
552 | podusage() { |
368 | echo |
553 | echo |
|
|
554 | |
369 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
555 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
370 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
556 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
371 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
557 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
372 | 2>/dev/null && exit |
558 | 2>/dev/null && exit |
373 | fi |
559 | fi |
|
|
560 | |
374 | # try whatever perl we can find |
561 | # try whatever perl we can find |
375 | perl -MPod::Usage -e \ |
562 | perl -MPod::Usage -e \ |
376 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
563 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
377 | 2>/dev/null && exit |
564 | 2>/dev/null && exit |
378 | |
565 | |
379 | fatal "displaying documentation requires a working perl - try '$0 install' first" |
566 | fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
380 | } |
567 | } |
381 | |
568 | |
382 | usage() { |
569 | usage() { |
383 | podusage 0 |
570 | podusage 0 |
384 | } |
571 | } |
… | |
… | |
386 | catmkbundle() { |
573 | catmkbundle() { |
387 | { |
574 | { |
388 | read dummy |
575 | read dummy |
389 | echo "#!$PERL_PREFIX/bin/perl" |
576 | echo "#!$PERL_PREFIX/bin/perl" |
390 | cat |
577 | cat |
391 | } <<'MKBUNDLE' |
578 | } <<'end_of_mkbundle' |
392 | #CAT mkbundle |
579 | #CAT mkbundle |
393 | MKBUNDLE |
580 | end_of_mkbundle |
394 | } |
581 | } |
395 | |
582 | |
396 | bundle() { |
583 | bundle() { |
|
|
584 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
397 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
585 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
398 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
586 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
399 | CACHE="$STATICPERL/cache" |
587 | CACHE="$STATICPERL/cache" |
400 | mkdir -p "$CACHE" |
588 | mkdir -p "$CACHE" |
401 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
589 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
… | |
… | |
406 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
594 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
407 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
595 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
408 | |
596 | |
409 | command="${1#--}"; shift |
597 | command="${1#--}"; shift |
410 | case "$command" in |
598 | case "$command" in |
|
|
599 | version ) |
|
|
600 | echo "staticperl version $VERSION" |
|
|
601 | ;; |
411 | fetch | configure | build | install | clean | distclean) |
602 | fetch | configure | build | install | clean | realclean | distclean ) |
412 | verblock <<EOF |
|
|
413 | $command |
|
|
414 | EOF |
|
|
415 | ( "$command" ) |
603 | ( "$command" ) || exit |
|
|
604 | ;; |
|
|
605 | import ) |
|
|
606 | ( import "$1" ) || exit |
|
|
607 | shift |
416 | ;; |
608 | ;; |
417 | instsrc ) |
609 | instsrc ) |
418 | ( instsrc "$@" ) |
610 | ( instsrc "$@" ) || exit |
419 | exit |
611 | exit |
420 | ;; |
612 | ;; |
421 | instcpan ) |
613 | instcpan ) |
422 | ( instcpan "$@" ) |
614 | ( instcpan "$@" ) || exit |
423 | exit |
615 | exit |
424 | ;; |
616 | ;; |
|
|
617 | perl ) |
|
|
618 | ( install ) || exit |
|
|
619 | exec "$PERL_PREFIX/bin/perl" "$@" |
|
|
620 | exit |
|
|
621 | ;; |
425 | cpan ) |
622 | cpan ) |
426 | ( install ) |
623 | ( install ) || exit |
|
|
624 | PERL="$PERL_PREFIX/bin/perl" |
|
|
625 | export PERL |
427 | "$PERL_PREFIX/bin/cpan" "$@" |
626 | exec "$PERL_PREFIX/bin/cpan" "$@" |
428 | exit |
627 | exit |
429 | ;; |
628 | ;; |
430 | mkbundle ) |
629 | mkbundle ) |
431 | ( install ) |
630 | ( install ) || exit |
432 | bundle "$@" |
631 | bundle "$@" |
433 | exit |
632 | exit |
434 | ;; |
633 | ;; |
435 | mkperl ) |
634 | mkperl ) |
436 | ( install ) |
635 | ( install ) || exit |
437 | bundle --perl "$@" |
636 | bundle --perl "$@" |
438 | exit |
637 | exit |
439 | ;; |
638 | ;; |
440 | mkapp ) |
639 | mkapp ) |
441 | ( install ) |
640 | ( install ) || exit |
442 | bundle --app "$@" |
641 | bundle --app "$@" |
443 | exit |
642 | exit |
444 | ;; |
643 | ;; |
445 | help ) |
644 | help ) |
446 | podusage 2 |
645 | podusage 2 |