X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2Futil%2Fmake_ext;h=9afbbcccbbe468d239964143859e31329f28c96c;hb=3f872cb9b86492b28abfc3221567ac8cecfb2724;hp=fba77c0c9f97711915a1d12ee3e2397fba76b69d;hpb=a0d0e21ea6ea90a22318550944fe6cb09ae10cda;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/util/make_ext b/ext/util/make_ext index fba77c0..9afbbcc 100644 --- a/ext/util/make_ext +++ b/ext/util/make_ext @@ -1,14 +1,37 @@ +#!/bin/sh + # This script acts as a simple interface for building extensions. # It primarily used by the perl Makefile: # # d_dummy $(dynamic_ext): miniperl preplibrary FORCE -# ext/util/make_ext dynamic $@ +# @sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) # # It may be deleted in a later release of perl so try to # avoid using it for other purposes. -linktype=$1 -extspec=$2 +target=$1; shift +extspec=$1; shift +makecmd=$1; shift # Should be something like MAKE=make +passthru="$*" # allow extra macro=value to be passed through +echo "" + +# Previously, $make was taken from config.sh. However, the user might +# instead be running a possibly incompatible make. This might happen if +# the user types "gmake" instead of a plain "make", for example. The +# correct current value of MAKE will come through from the main perl +# makefile as MAKE=/whatever/make in $makecmd. We'll be cautious in +# case third party users of this script (are there any?) don't have the +# MAKE=$(MAKE) argument, which was added after 5.004_03. +case "$makecmd" in +MAKE=*) + eval $makecmd + ;; +*) echo 'ext/util/make_ext: WARNING: Please include MAKE=$(MAKE)' + echo ' in your call to make_ext. See ext/util/make_ext for details.' + exit 1 + ;; +esac + case $CONFIG in '') @@ -29,46 +52,95 @@ if test "X$extspec" = X; then exit 1; fi -# convert old style Name.a into ext/Name/Name.a format +# The Perl Makefile.SH will expand all extensions to +# lib/auto/X/X.a (or lib/auto/X/Y/Y.a if nested) +# A user wishing to run make_ext might use +# X (or X/Y or X::Y if nested) + +# canonise into X/Y form (pname) case "$extspec" in -ext/*) ;; -*) extspec=`echo "$extspec" | sed -e 's:\(.*\)\.\(.*\):ext/\1/\1.\2:'` +lib*) # Remove lib/auto prefix and /*.* suffix + pname=`echo "$extspec" | sed -e 's:^lib/auto/::' -e 's:/[^/]*\.[^/]*$::' ` ;; +ext*) # Remove ext/ prefix and /pm_to_blib suffix + pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/pm_to_blib$::' ` ;; +*::*) # Convert :: to / + pname=`echo "$extspec" | sed -e 's/::/\//g' ` ;; +*) pname="$extspec" ;; esac +# echo "Converted $extspec to $pname" -# get extension directory path, module name and depth -pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/[^/]*$::'` -mname=`echo "$pname" | sed -e 's!/!::!'` +mname=`echo "$pname" | sed -e 's!/!::!g'` depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'` +makefile=Makefile +makeargs='' +makeopts='' -if test ! -d "ext/$pname"; then - echo " Skipping $extspec (directory does not exist)" - exit 0 # not an error ? +if test ! -d "$src/ext/$pname"; then + echo " Skipping $extspec (directory does not exist)" + exit 0 # not an error ? fi -# check link type and do any preliminaries -case "$linktype" in -static) makeargs='CCCDLFLAGS=' ;; -dynamic) makeargs='' ;; -*) echo "make_ext: unknown link type '$linktype'"; exit 1;; -'') echo "make_ext: no link type specified (eg static or dynamic)"; exit 1;; -esac -echo "" -echo " Making $mname ($linktype)" +echo " Making $mname ($target)" +mkdir ext 2>/dev/null +mkdir ext/$pname 2>/dev/null +if test ! -f ext/$pname/Makefile.PL; then + cat $src/ext/$pname/Makefile.PL > ext/$pname/Makefile.PL +fi cd ext/$pname -if test ! -f Makefile ; then - test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL +# check link type and do any preliminaries +case "$target" in + # convert 'static' or 'dynamic' into 'all LINKTYPE=XXX' +static) makeargs="LINKTYPE=static CCCDLFLAGS=" + target=all + ;; +dynamic) makeargs="LINKTYPE=dynamic"; + target=all + ;; + +nonxs) makeargs=""; + target=all + ;; + +*clean) # If Makefile has been moved to Makefile.old by a make clean + # then use Makefile.old for realclean rather than rebuild it + if test ! -f $makefile -a -f Makefile.old; then + makefile=Makefile.old + makeopts="-f $makefile" + echo "Note: Using Makefile.old" + fi + ;; + +*) # for the time being we are strict about what make_ext is used for + echo "make_ext: unknown make target '$target'"; exit 1 + ;; +'') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1 + ;; +esac + +if test ! -f $makefile ; then + test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib -I$src/lib Makefile.PL INSTALLDIRS=perl $passthru fi -if test ! -f Makefile ; then - test -f Makefile.SH && sh Makefile.SH +if test ! -f $makefile ; then + if test -f Makefile.SH; then + echo "Warning: Writing $makefile from old-style Makefile.SH!" + sh Makefile.SH + else + echo "Warning: No Makefile!" + fi fi -make=${altmake-make} - -$make config +case "$target" in +clean) ;; +realclean) ;; +*) # Give makefile an opportunity to rewrite itself. + # reassure users that life goes on... + $MAKE config $passthru || echo "$MAKE config failed, continuing anyway..." + ;; +esac -$make $linktype $makeargs +$MAKE $makeopts $target $makeargs $passthru || exit exit $?