ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
(Generate patch)

Comparing App-Staticperl/staticperl.sh (file contents):
Revision 1.9 by root, Tue Dec 7 20:03:15 2010 UTC vs.
Revision 1.45 by root, Sun Jun 26 17:26:52 2011 UTC

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
6STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
7CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9 9DLCACHE=
10MKBUNDLE="$STATICPERL/mkbundle"
11 10
12# perl build variables 11# perl build variables
13PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed 12MAKE=make
14PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 13PERL_VERSION=5.12.3 # 5.8.9 is also a good choice
14PERL_CC=cc
15PERL_CONFIGURE="" # additional Configure arguments 15PERL_CONFIGURE="" # additional Configure arguments
16PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 16PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 18
19ARCH="$(uname -m)" 19ARCH="$(uname -m)"
20 20
21case "$ARCH" in 21case "$ARCH" in
29 ;; 29 ;;
30esac 30esac
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
35PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 35#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LDFLAGS=
36PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 37PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
37 38
38# some configuration options for modules 39# some configuration options for modules
39export PERL_MM_USE_DEFAULT=1 40PERL_MM_USE_DEFAULT=1
41PERL_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
41export 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' 43EV_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'
44export PERL_MM_USE_DEFAULT PERL_MM_OPT CORO_INTERFACE EV_EXTRA_DEFS
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
45STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 48STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
46 49
47# which extra modules you might want to install 50# which extra modules you might want to install
48EXTRA_MODULES="" 51EXTRA_MODULES=""
49 52
50# overridable functions 53# overridable functions
51preconfigure() { : ; } 54preconfigure() { : ; }
55patchconfig() { : ; }
52postconfigure() { : ; } 56postconfigure() { : ; }
53postbuild() { : ; } 57postbuild() { : ; }
54postinstall() { : ; } 58postinstall() { : ; }
55 59
56# now source user config, if any 60# now source user config, if any
61if [ "$STATICPERLRC" ]; then
62 . "$STATICPERLRC"
63else
57[ -r /etc/staticperlrc ] && . /etc/staticperlrc 64 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
58[ -r ~/.staticperlrc ] && . ~/.staticperlrc 65 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
59[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 66 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
67fi
60 68
61############################################################################# 69#############################################################################
62# support 70# support
71
72PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
73
74unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
75unset PERL_MB_OPT
76LC_ALL=C; export LC_ALL # just to be on the safe side
77
78# prepend PATH - not required by staticperl itself, but might make
79# life easier when working in e.g. "staticperl cpan / look"
80PATH="$PERL_PREFIX/perl/bin:$PATH"
63 81
64# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
65VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
66$VERSION=0.1 84$VERSION="1.31"
67 85
68BZ2=bz2 86BZ2=bz2
69BZIP2=bzip2 87BZIP2=bzip2
70 88
71fatal() { 89fatal() {
104############################################################################# 122#############################################################################
105# clean 123# clean
106 124
107distclean() { 125distclean() {
108 verblock <<EOF 126 verblock <<EOF
109deleting everything installed by this script 127 deleting everything installed by this script (rm -rf $STATICPERL)
110EOF 128EOF
111 129
112 rm -rf "$STATICPERL" 130 rm -rf "$STATICPERL"
113} 131}
114 132
117 135
118clean() { 136clean() {
119 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 137 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
120} 138}
121 139
140realclean() {
141 rm -f "$PERL_PREFIX/staticstamp.postinstall"
142 rm -f "$PERL_PREFIX/staticstamp.install"
143 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure"
144}
145
122fetch() { 146fetch() {
123 rcd "$STATICPERL" 147 rcd "$STATICPERL"
124 148
125 mkdir -p src 149 mkdir -p src
126 rcd src 150 rcd src
127 151
128 if ! [ -d "perl-$PERL_VERSION" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
129 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
130 154
155 if ! [ -e $PERLTAR ]; then
131 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
132 157
133 verblock <<EOF 158 verblock <<EOF
134downloading perl 159downloading perl
135to manually download perl yourself, place 160to manually download perl yourself, place
136perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
137trying $URL 162trying $URL
138EOF
139 163
164either curl or wget is required for automatic download.
165curl is tried first, then wget.
166
167you can configure a download cache directory via DLCACHE
168in your .staticperlrc to avoid repeated downloads.
169EOF
170
140 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 171 rm -f $PERLTAR~ # just to be on the safe side
141 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp -l "$DLCACHE"/$PERLTAR $PERLTAR~; } \
142 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
143 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
144 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
177 mv $PERLTAR~ $PERLTAR
178 if [ "$DLCACHE" ]; then
179 mkdir -p "$DLCACHE"
180 cp -l $PERLTAR "$DLCACHE"/$PERLTAR~ && \
181 mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR
182 fi
145 fi 183 fi
146 184
147 verblock <<EOF 185 verblock <<EOF
148unpacking perl 186unpacking perl
149EOF 187EOF
150 188
151 mkdir -p unpack 189 mkdir -p unpack
152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ 190 rm -rf unpack/perl-$PERL_VERSION
191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION 193 chmod -R u+w unpack/perl-$PERL_VERSION
155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
156 rmdir -p unpack 195 rmdir -p unpack
157 fi 196 fi
158} 197}
159 198
160# similar to GNU-sed -i or perl -pi 199# similar to GNU-sed -i or perl -pi
161sedreplace() { 200sedreplace() {
162 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 201 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
202 rm -f "$2"
163 mv "$2~" "$2" 203 mv "$2~" "$2"
204}
205
206configure_failure() {
207 cat <<EOF
208
209
210***
211*** Configure failed - see above for the exact error message(s).
212***
213*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
214*** flags are not supported by your compiler. Less often, this is because
215*** PERL_LIBS either contains a library not available on your system (such as
216*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
217***
218*** You can provide your own flags by creating a ~/.staticperlrc file with
219*** variable assignments. For example (these are the actual values used):
220***
221
222PERL_CC="$PERL_CC"
223PERL_CCFLAGS="$PERL_CCFLAGS"
224PERL_OPTIMIZE="$PERL_OPTIMIZE"
225PERL_LDFLAGS="$PERL_LDFLAGS"
226PERL_LIBS="$PERL_LIBS"
227
228EOF
229 exit 1
164} 230}
165 231
166configure() { 232configure() {
167 fetch 233 fetch
168 234
174configuring $STATICPERL/src/perl-$PERL_VERSION 240configuring $STATICPERL/src/perl-$PERL_VERSION
175EOF 241EOF
176 242
177 rm -f "$PERL_PREFIX/staticstamp.install" 243 rm -f "$PERL_PREFIX/staticstamp.install"
178 244
179 make distclean >/dev/null 2>&1 245 "$MAKE" distclean >/dev/null 2>&1
180 246
247 sedreplace '/^#define SITELIB/d' config_h.SH
248
181 # I hate them 249 # I hate them for this
182 grep -q -- -fstack-protector Configure && \ 250 grep -q -- -fstack-protector Configure && \
183 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 251 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
184 252
185 preconfigure 253 # what did that bloke think
254 grep -q -- usedl=.define hints/darwin.sh && \
255 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
256
257 preconfigure || fatal "preconfigure hook failed"
186 258
187# trace configure \ 259# trace configure \
188 sh Configure -Duselargefiles \ 260 sh Configure -Duselargefiles \
189 -Uuse64bitint \ 261 -Uuse64bitint \
190 -Dusemymalloc=n \ 262 -Dusemymalloc=n \
191 -Uusedl \ 263 -Uusedl \
192 -Uusethreads \ 264 -Uusethreads \
193 -Uuseithreads \ 265 -Uuseithreads \
194 -Uusemultiplicity \ 266 -Uusemultiplicity \
195 -Duseperlio \
196 -Uusesfio \ 267 -Uusesfio \
197 -Uuseshrplib \ 268 -Uuseshrplib \
269 -Uinstallusrbinperl \
198 -Dcppflags="$PERL_CPPFLAGS" \ 270 -A ccflags=" $PERL_CCFLAGS" \
199 -Dccflags="-g2 -fno-strict-aliasing" \ 271 -Dcc="$PERL_CC" \
200 -Doptimize="$PERL_OPTIMIZE" \ 272 -Doptimize="$PERL_OPTIMIZE" \
201 -Dldflags="$PERL_LDFLAGS" \ 273 -Dldflags="$PERL_LDFLAGS" \
202 -Dlibs="$PERL_LIBS" \ 274 -Dlibs="$PERL_LIBS" \
203 -Dprefix="$PERL_PREFIX" \ 275 -Dprefix="$PERL_PREFIX" \
204 -Dbin="$PERL_PREFIX/bin" \ 276 -Dbin="$PERL_PREFIX/bin" \
205 -Dprivlib="$PERL_PREFIX/lib" \ 277 -Dprivlib="$PERL_PREFIX/lib" \
206 -Darchlib="$PERL_PREFIX/lib" \ 278 -Darchlib="$PERL_PREFIX/lib" \
207 -Uusevendorprefix \ 279 -Uusevendorprefix \
208 -Dsitelib="$PERL_PREFIX/lib" \ 280 -Dsitelib="$PERL_PREFIX/lib" \
209 -Dsitearch="$PERL_PREFIX/lib" \ 281 -Dsitearch="$PERL_PREFIX/lib" \
210 -Usitelibexp \
211 -Uman1dir \ 282 -Uman1dir \
212 -Uman3dir \ 283 -Uman3dir \
213 -Usiteman1dir \ 284 -Usiteman1dir \
214 -Usiteman3dir \ 285 -Usiteman3dir \
215 -Dpager=/usr/bin/less \ 286 -Dpager=/usr/bin/less \
216 -Demail="$EMAIL" \ 287 -Demail="$EMAIL" \
217 -Dcf_email="$EMAIL" \ 288 -Dcf_email="$EMAIL" \
218 -Dcf_by="$EMAIL" \ 289 -Dcf_by="$EMAIL" \
219 $PERL_CONFIGURE \ 290 $PERL_CONFIGURE \
291 -Duseperlio \
220 -dE || fatal "Configure failed" 292 -dE || configure_failure
221 293
222 sedreplace ' 294 sedreplace '
223 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 295 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
224 s/ *-fno-stack-protector */ /g 296 s/ *-fno-stack-protector */ /g
225 ' config.sh 297 ' config.sh
226 298
299 patchconfig || fatal "patchconfig hook failed"
300
227 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
228 302
229 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
230 304
231 touch staticstamp.configure 305 touch staticstamp.configure
306}
307
308write_shellscript() {
309 {
310 echo "#!/bin/sh"
311 echo "STATICPERL=\"$STATICPERL\""
312 echo "PERL_PREFIX=\"$PERL_PREFIX\""
313 echo "MAKE=\"$MAKE\""
314 cat
315 } >"$PERL_PREFIX/bin/$1"
316 chmod 755 "$PERL_PREFIX/bin/$1"
232} 317}
233 318
234build() { 319build() {
235 configure 320 configure
236 321
240building $STATICPERL/src/perl-$PERL_VERSION 325building $STATICPERL/src/perl-$PERL_VERSION
241EOF 326EOF
242 327
243 rm -f "$PERL_PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
244 329
245 make || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
246 331
247 postbuild || fatal "postbuild hook failed" 332 postbuild || fatal "postbuild hook failed"
248} 333}
249 334
250install() { 335install() {
254 verblock <<EOF 339 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 340installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 341to $PERL_PREFIX
257EOF 342EOF
258 343
259 rm -rf "$PERL_PREFIX" 344 ln -sf "perl/bin/" "$STATICPERL/bin"
260 345 ln -sf "perl/lib/" "$STATICPERL/lib"
346
347 mkdir "$STATICPERL/patched"
348
349 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
350 rm -rf "$PERL_PREFIX" # by this rm -rf
351
261 make install || fatal "make install: error while installing" 352 "$MAKE" install || fatal "make install: error while installing"
262 353
263 rcd "$PERL_PREFIX" 354 rcd "$PERL_PREFIX"
264 355
265 # create a "make install" replacement for CPAN 356 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 357 write_shellscript SP-make-install-make <<'EOF'
267make install UNINST=1 358#CAT make-install-make.sh
268if find blib/arch/auto -type f | grep -q -v .exists; then
269 echo Probably an XS module, rebuilding perl
270 make perl
271 rm -f "$PERL_PREFIX"/bin/perl
272 make -f Makefile.aperl inst_perl
273 make -f Makefile.aperl map_clean
274fi
275EOF 359EOF
276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
277 360
361 # create a "patch modules" helper
362 write_shellscript SP-patch-postinstall <<'EOF'
363#CAT patch-postinstall.sh
364EOF
365
366 "$PERL_PREFIX/bin/SP-patch-postinstall"
367
278 # trick CPAN into avoiding ~/.cpan completely 368 # help to trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 369 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
280 370
371 # we call cpan with -MCPAN::MyConfig in this script, which
372 # is strictly unnecssary as we have to patch CPAN anyway,
373 # so consider it "for good measure".
281 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 374 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
282 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 375 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
283 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 376 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
284 CPAN::Shell->o (conf => q<init>); 377 CPAN::Shell->o (conf => q<init>);
285 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 378 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
286 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 379 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
287 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 380 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
288 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 381 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
289 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 382 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"); 383 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
291 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 384 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
292 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 385 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
386 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
293 CPAN::Shell->o (conf => q<commit>); 387 CPAN::Shell->o (conf => q<commit>);
294 ' || fatal "error while initialising CPAN" 388 ' || fatal "error while initialising CPAN"
295 389
296 touch "$PERL_PREFIX/staticstamp.install" 390 touch "$PERL_PREFIX/staticstamp.install"
297 fi 391 fi
298 392
299 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then 393 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
300 NOCHECK_INSTALL=+ 394 NOCHECK_INSTALL=+
301 instcpan $STATICPERL_MODULES 395 instcpan $STATICPERL_MODULES
302 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 396 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
303 397
304 postinstall || fatal "postinstall hook failed" 398 postinstall || fatal "postinstall hook failed"
317installing modules from CPAN 411installing modules from CPAN
318$@ 412$@
319EOF 413EOF
320 414
321 for mod in "$@"; do 415 for mod in "$@"; do
322 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 416 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \
323 || fatal "$mod: unable to install from CPAN" 417 || fatal "$mod: unable to install from CPAN"
324 done 418 done
325 rm -rf "$STATICPERL/build" 419 rm -rf "$STATICPERL/build"
326} 420}
327 421
339 for mod in "$@"; do 433 for mod in "$@"; do
340 echo 434 echo
341 echo $mod 435 echo $mod
342 ( 436 (
343 rcd $mod 437 rcd $mod
344 make -f Makefile.aperl map_clean >/dev/null 2>&1 438 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
345 make distclean >/dev/null 2>&1 439 "$MAKE" distclean >/dev/null 2>&1
346 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 440 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
347 make || fatal "$mod: error building module" 441 "$MAKE" || fatal "$mod: error building module"
348 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 442 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
349 make distclean >/dev/null 2>&1 443 "$MAKE" distclean >/dev/null 2>&1
350 exit 0 444 exit 0
351 ) || exit $? 445 ) || exit $?
352 done 446 done
353} 447}
354 448
355############################################################################# 449#############################################################################
356# main 450# main
357 451
358podusage() { 452podusage() {
359 echo 453 echo
454
360 if [ -e "$PERL_PREFIX/bin/perl" ]; then 455 if [ -e "$PERL_PREFIX/bin/perl" ]; then
361 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 456 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
362 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 457 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
363 2>/dev/null && exit 458 2>/dev/null && exit
364 fi 459 fi
460
365 # try whatever perl we can find 461 # try whatever perl we can find
366 perl -MPod::Usage -e \ 462 perl -MPod::Usage -e \
367 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 463 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
368 2>/dev/null && exit 464 2>/dev/null && exit
369 465
370 fatal "displaying documentation requires a working perl - try '$0 install' first" 466 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
371} 467}
372 468
373usage() { 469usage() {
374 podusage 0 470 podusage 0
375} 471}
383#CAT mkbundle 479#CAT mkbundle
384MKBUNDLE 480MKBUNDLE
385} 481}
386 482
387bundle() { 483bundle() {
484 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
388 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 485 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
389 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 486 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
487 CACHE="$STATICPERL/cache"
488 mkdir -p "$CACHE"
390 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 489 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
391} 490}
392 491
393if [ $# -gt 0 ]; then 492if [ $# -gt 0 ]; then
394 while [ $# -gt 0 ]; do 493 while [ $# -gt 0 ]; do
395 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 494 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
396 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 495 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
397 496
398 command="${1#--}"; shift 497 command="${1#--}"; shift
399 case "$command" in 498 case "$command" in
499 version )
500 echo "staticperl version $VERSION"
501 ;;
400 fetch | configure | build | install | clean | distclean) 502 fetch | configure | build | install | clean | realclean | distclean)
401 verblock <<EOF
402$command
403EOF
404 ( "$command" ) 503 ( "$command" ) || exit
405 ;; 504 ;;
406 instsrc ) 505 instsrc )
407 ( instsrc "$@" ) 506 ( instsrc "$@" ) || exit
408 exit 507 exit
409 ;; 508 ;;
410 instcpan ) 509 instcpan )
411 ( instcpan "$@" ) 510 ( instcpan "$@" ) || exit
511 exit
512 ;;
513 perl )
514 ( install ) || exit
515 exec "$PERL_PREFIX/bin/perl" "$@"
412 exit 516 exit
413 ;; 517 ;;
414 cpan ) 518 cpan )
415 ( install ) 519 ( install ) || exit
416 "$PERL_PREFIX/bin/cpan" "$@" 520 exec "$PERL_PREFIX/bin/cpan" "$@"
417 exit 521 exit
418 ;; 522 ;;
419 mkbundle ) 523 mkbundle )
420 ( install ) 524 ( install ) || exit
421 bundle "$@" 525 bundle "$@"
422 exit 526 exit
423 ;; 527 ;;
424 mkperl ) 528 mkperl )
425 ( install ) 529 ( install ) || exit
426 bundle --perl "$@" 530 bundle --perl "$@"
531 exit
532 ;;
533 mkapp )
534 ( install ) || exit
535 bundle --app "$@"
427 exit 536 exit
428 ;; 537 ;;
429 help ) 538 help )
430 podusage 2 539 podusage 2
431 ;; 540 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines