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.20 by root, Mon Dec 13 17:35:51 2010 UTC vs.
Revision 1.23 by root, Sat Dec 18 13:58:12 2010 UTC

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 9
10# perl build variables 10# perl build variables
11MAKE=make
11PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 12PERL_VERSION=5.12.2 # 5.8.9 is also a good choice
12PERL_CC=cc 13PERL_CC=cc
13PERL_CONFIGURE="" # additional Configure arguments 14PERL_CONFIGURE="" # additional Configure arguments
14PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 15PERL_CCFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG"
15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
16 17
17ARCH="$(uname -m)" 18ARCH="$(uname -m)"
18 19
19case "$ARCH" in 20case "$ARCH" in
20 i*86 | x86_64 | amd64 ) 21 i*86 | x86_64 | amd64 )
21 #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
22 PERL_OPTIMIZE="$PERL_OPTIMIZE" # x86/amd64
23 case "$ARCH" in 23 case "$ARCH" in
24 i*86 ) 24 i*86 )
25 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
26 ;; 26 ;;
27 esac 27 esac
70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
71export LC_ALL=C # just to be on the safe side 71export LC_ALL=C # just to be on the safe side
72 72
73# set version in a way that Makefile.PL can extract 73# set version in a way that Makefile.PL can extract
74VERSION=VERSION; eval \ 74VERSION=VERSION; eval \
75$VERSION=0.911 75$VERSION=0.912
76 76
77BZ2=bz2 77BZ2=bz2
78BZIP2=bzip2 78BZIP2=bzip2
79 79
80fatal() { 80fatal() {
126 126
127clean() { 127clean() {
128 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 128 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
129} 129}
130 130
131realclean() {
132 rm -f "$PERL_PREFIX/staticstamp.postinstall"
133 rm -f "$PERL_PREFIX/staticstamp.install"
134 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure"
135}
136
131fetch() { 137fetch() {
132 rcd "$STATICPERL" 138 rcd "$STATICPERL"
133 139
134 mkdir -p src 140 mkdir -p src
135 rcd src 141 rcd src
173 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 179 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
174 rm -f "$2" 180 rm -f "$2"
175 mv "$2~" "$2" 181 mv "$2~" "$2"
176} 182}
177 183
184configure_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
200PERL_CC="$PERL_CC"
201PERL_CCFLAGS="$PERL_CCFLAGS"
202PERL_OPTIMIZE="$PERL_OPTIMIZE"
203PERL_LDFLAGS="$PERL_LDFLAGS"
204PERL_LIBS="$PERL_LIBS"
205
206EOF
207 exit 1
208}
209
178configure() { 210configure() {
179 fetch 211 fetch
180 212
181 rcd "$STATICPERL/src/perl-$PERL_VERSION" 213 rcd "$STATICPERL/src/perl-$PERL_VERSION"
182 214
186configuring $STATICPERL/src/perl-$PERL_VERSION 218configuring $STATICPERL/src/perl-$PERL_VERSION
187EOF 219EOF
188 220
189 rm -f "$PERL_PREFIX/staticstamp.install" 221 rm -f "$PERL_PREFIX/staticstamp.install"
190 222
191 make distclean >/dev/null 2>&1 223 "$MAKE" distclean >/dev/null 2>&1
192 224
225 sedreplace '/^#define SITELIB/d' config_h.SH
226
193 # I hate them 227 # I hate them for this
194 grep -q -- -fstack-protector Configure && \ 228 grep -q -- -fstack-protector Configure && \
195 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 229 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
196 230
197 preconfigure 231 preconfigure
198 232
204 -Uusethreads \ 238 -Uusethreads \
205 -Uuseithreads \ 239 -Uuseithreads \
206 -Uusemultiplicity \ 240 -Uusemultiplicity \
207 -Uusesfio \ 241 -Uusesfio \
208 -Uuseshrplib \ 242 -Uuseshrplib \
243 -A ccflags=" $PERL_CCFLAGS" \
209 -Dcc="$PERL_CC" \ 244 -Dcc="$PERL_CC" \
210 -Dcppflags="$PERL_CPPFLAGS" \
211 -Dccflags="-g2 -fno-strict-aliasing" \
212 -Doptimize="$PERL_OPTIMIZE" \ 245 -Doptimize="$PERL_OPTIMIZE" \
213 -Dldflags="$PERL_LDFLAGS" \ 246 -Dldflags="$PERL_LDFLAGS" \
214 -Dlibs="$PERL_LIBS" \ 247 -Dlibs="$PERL_LIBS" \
215 -Dprefix="$PERL_PREFIX" \ 248 -Dprefix="$PERL_PREFIX" \
216 -Dbin="$PERL_PREFIX/bin" \ 249 -Dbin="$PERL_PREFIX/bin" \
217 -Dprivlib="$PERL_PREFIX/lib" \ 250 -Dprivlib="$PERL_PREFIX/lib" \
218 -Darchlib="$PERL_PREFIX/lib" \ 251 -Darchlib="$PERL_PREFIX/lib" \
219 -Uusevendorprefix \ 252 -Uusevendorprefix \
220 -Dsitelib="$PERL_PREFIX/lib" \ 253 -Dsitelib="$PERL_PREFIX/lib" \
221 -Dsitearch="$PERL_PREFIX/lib" \ 254 -Dsitearch="$PERL_PREFIX/lib" \
222 -Usitelibexp \
223 -Uman1dir \ 255 -Uman1dir \
224 -Uman3dir \ 256 -Uman3dir \
225 -Usiteman1dir \ 257 -Usiteman1dir \
226 -Usiteman3dir \ 258 -Usiteman3dir \
227 -Dpager=/usr/bin/less \ 259 -Dpager=/usr/bin/less \
228 -Demail="$EMAIL" \ 260 -Demail="$EMAIL" \
229 -Dcf_email="$EMAIL" \ 261 -Dcf_email="$EMAIL" \
230 -Dcf_by="$EMAIL" \ 262 -Dcf_by="$EMAIL" \
231 $PERL_CONFIGURE \ 263 $PERL_CONFIGURE \
232 -Duseperlio \ 264 -Duseperlio \
233 -dE || fatal "Configure failed" 265 -dE || configure_failure
234 266
235 sedreplace ' 267 sedreplace '
236 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 268 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
237 s/ *-fno-stack-protector */ /g 269 s/ *-fno-stack-protector */ /g
238 ' config.sh 270 ' config.sh
253building $STATICPERL/src/perl-$PERL_VERSION 285building $STATICPERL/src/perl-$PERL_VERSION
254EOF 286EOF
255 287
256 rm -f "$PERL_PREFIX/staticstamp.install" 288 rm -f "$PERL_PREFIX/staticstamp.install"
257 289
258 make || fatal "make: error while building perl" 290 "$MAKE" || fatal "make: error while building perl"
259 291
260 postbuild || fatal "postbuild hook failed" 292 postbuild || fatal "postbuild hook failed"
261} 293}
262 294
263install() { 295install() {
273 ln -sf "perl/lib/" "$STATICPERL/lib" 305 ln -sf "perl/lib/" "$STATICPERL/lib"
274 306
275 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 307 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
276 rm -rf "$PERL_PREFIX" # by this rm -rf 308 rm -rf "$PERL_PREFIX" # by this rm -rf
277 309
278 make install || fatal "make install: error while installing" 310 "$MAKE" install || fatal "make install: error while installing"
279 311
280 rcd "$PERL_PREFIX" 312 rcd "$PERL_PREFIX"
281 313
282 # create a "make install" replacement for CPAN 314 # create a "make install" replacement for CPAN
283 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 315 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
284make || exit 316"$MAKE" || exit
285 317
286if find blib/arch/auto -type f | grep -q -v .exists; then 318if find blib/arch/auto -type f | grep -q -v .exists; then
287 echo Probably an XS module, rebuilding perl 319 echo Probably an XS module, rebuilding perl
288 if make perl; then 320 if "$MAKE" perl; then
289 mv perl "$PERL_PREFIX"/bin/perl~ \ 321 mv perl "$PERL_PREFIX"/bin/perl~ \
290 && rm -f "$PERL_PREFIX"/bin/perl \ 322 && rm -f "$PERL_PREFIX"/bin/perl \
291 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl 323 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
292 make -f Makefile.aperl map_clean 324 "$MAKE" -f Makefile.aperl map_clean
293 else 325 else
294 make -f Makefile.aperl map_clean 326 "$MAKE" -f Makefile.aperl map_clean
295 exit 1 327 exit 1
296 fi 328 fi
297fi 329fi
298 330
299make install UNINST=1 331"$MAKE" install UNINST=1
300EOF 332EOF
301 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 333 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
302 334
303 # trick CPAN into avoiding ~/.cpan completely 335 # trick CPAN into avoiding ~/.cpan completely
304 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 336 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
364 for mod in "$@"; do 396 for mod in "$@"; do
365 echo 397 echo
366 echo $mod 398 echo $mod
367 ( 399 (
368 rcd $mod 400 rcd $mod
369 make -f Makefile.aperl map_clean >/dev/null 2>&1 401 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
370 make distclean >/dev/null 2>&1 402 "$MAKE" distclean >/dev/null 2>&1
371 "$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"
372 make || fatal "$mod: error building module" 404 "$MAKE" || fatal "$mod: error building module"
373 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 405 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module"
374 make distclean >/dev/null 2>&1 406 "$MAKE" distclean >/dev/null 2>&1
375 exit 0 407 exit 0
376 ) || exit $? 408 ) || exit $?
377 done 409 done
378} 410}
379 411
427 command="${1#--}"; shift 459 command="${1#--}"; shift
428 case "$command" in 460 case "$command" in
429 version ) 461 version )
430 echo "staticperl version $VERSION" 462 echo "staticperl version $VERSION"
431 ;; 463 ;;
432 fetch | configure | build | install | clean | distclean) 464 fetch | configure | build | install | clean | realclean | distclean)
433 ( "$command" ) 465 ( "$command" ) || exit
434 ;; 466 ;;
435 instsrc ) 467 instsrc )
436 ( instsrc "$@" ) 468 ( instsrc "$@" ) || exit
437 exit 469 exit
438 ;; 470 ;;
439 instcpan ) 471 instcpan )
440 ( instcpan "$@" ) 472 ( instcpan "$@" ) || exit
441 exit 473 exit
442 ;; 474 ;;
443 cpan ) 475 cpan )
444 ( install ) 476 ( install ) || exit
445 "$PERL_PREFIX/bin/cpan" "$@" 477 "$PERL_PREFIX/bin/cpan" "$@"
446 exit 478 exit
447 ;; 479 ;;
448 mkbundle ) 480 mkbundle )
449 ( install ) 481 ( install ) || exit
450 bundle "$@" 482 bundle "$@"
451 exit 483 exit
452 ;; 484 ;;
453 mkperl ) 485 mkperl )
454 ( install ) 486 ( install ) || exit
455 bundle --perl "$@" 487 bundle --perl "$@"
456 exit 488 exit
457 ;; 489 ;;
458 mkapp ) 490 mkapp )
459 ( install ) 491 ( install ) || exit
460 bundle --app "$@" 492 bundle --app "$@"
461 exit 493 exit
462 ;; 494 ;;
463 help ) 495 help )
464 podusage 2 496 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines