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.18 by root, Mon Dec 13 16:34:13 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
13PERL_CC=cc
12PERL_CONFIGURE="" # additional Configure arguments 14PERL_CONFIGURE="" # additional Configure arguments
13PERL_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"
14PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
15 17
16ARCH="$(uname -m)" 18ARCH="$(uname -m)"
17 19
18case "$ARCH" in 20case "$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
69unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
70export LC_ALL=C # just to be on the safe side 71export 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
73VERSION=VERSION; eval \ 74VERSION=VERSION; eval \
74$VERSION=0.911 75$VERSION=0.912
75 76
76BZ2=bz2 77BZ2=bz2
77BZIP2=bzip2 78BZIP2=bzip2
78 79
79fatal() { 80fatal() {
125 126
126clean() { 127clean() {
127 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 128 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
128} 129}
129 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
130fetch() { 137fetch() {
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
156unpacking perl 164unpacking perl
157EOF 165EOF
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
169sedreplace() { 178sedreplace() {
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
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
172} 208}
173 209
174configure() { 210configure() {
175 fetch 211 fetch
176 212
182configuring $STATICPERL/src/perl-$PERL_VERSION 218configuring $STATICPERL/src/perl-$PERL_VERSION
183EOF 219EOF
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
248building $STATICPERL/src/perl-$PERL_VERSION 285building $STATICPERL/src/perl-$PERL_VERSION
249EOF 286EOF
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
258install() { 295install() {
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
279make || exit 316"$MAKE" || exit
280 317
281if find blib/arch/auto -type f | grep -q -v .exists; then 318if 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
290fi 329fi
291 330
292make install UNINST=1 331"$MAKE" install UNINST=1
293EOF 332EOF
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines