3 # This script acts as a simple interface for building extensions.
4 # (borrowed from make_ext; but it will be deleted in future versions)
5 # It primarily used by the perl Makefile:
7 # d_dummy $(dynamic_ext): miniperl preplibrary FORCE
8 # @sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
10 # It may be deleted in a later release of perl so try to
11 # avoid using it for other purposes.
15 makecmd=$1; shift # Should be something like MAKE=make
16 passthru="$*" # allow extra macro=value to be passed through
19 # Previously, $make was taken from config.sh. However, the user might
20 # instead be running a possibly incompatible make. This might happen if
21 # the user types "gmake" instead of a plain "make", for example. The
22 # correct current value of MAKE will come through from the main perl
23 # makefile as MAKE=/whatever/make in $makecmd. We'll be cautious in
24 # case third party users of this script (are there any?) don't have the
25 # MAKE=$(MAKE) argument, which was added after 5.004_03.
30 *) echo 'ext/util/make_ext: WARNING: Please include MAKE=$(MAKE)'
31 echo ' in your call to make_ext. See ext/util/make_ext for details.'
39 if test -f config.sh; then TOP=.;
40 elif test -f ../config.sh; then TOP=..;
41 elif test -f ../../config.sh; then TOP=../..;
42 elif test -f ../../../config.sh; then TOP=../../..;
43 elif test -f ../../../../config.sh; then TOP=../../../..;
45 echo "Can't find config.sh generated by Configure"; exit 1
51 if test "X$extspec" = X; then
52 echo "make_ext: no extension specified"
56 # The Perl Makefile.SH will expand all extensions to
57 # lib/auto/X/X.a (or lib/auto/X/Y/Y.a if nested)
58 # A user wishing to run make_ext might use
59 # X (or X/Y or X::Y if nested)
61 # canonise into X/Y form (pname)
63 lib*) # Remove lib/auto prefix and /*.* suffix
64 pname=`echo "$extspec" | sed -e 's:^lib/auto/::' -e 's:/[^/]*\.[^/]*$::' ` ;;
65 ext*) # Remove ext/ prefix and /pm_to_blib suffix
66 pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/pm_to_blib$::' ` ;;
67 *::*) # Convert :: to /
68 pname=`echo "$extspec" | sed -e 's/::/\//g' ` ;;
69 *.*o) pname=`echo "$extspec" | sed -e 's/\..*o//'` ;;
70 *) pname="$extspec" ;;
72 # echo "Converted $extspec to $pname"
74 mname=`echo "$pname" | sed -e 's!/!::!g'`
75 depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'`
80 if test ! -d "ext/$pname"; then
81 echo " Skipping $extspec (directory does not exist)"
82 exit 0 # not an error ?
86 echo " Making $mname ($target)"
90 # check link type and do any preliminaries. Valid link types are
91 # 'dynamic', 'static', and 'static_pic' (the last one respects
92 # CCCDLFLAGS such as -fPIC -- see static_target in the main Makefile.SH)
94 dynamic) makeargs="LINKTYPE=dynamic";
97 static) makeargs="LINKTYPE=static CCCDLFLAGS="
100 static_pic) makeargs="LINKTYPE=static"
107 *clean) # If Makefile has been moved to Makefile.old by a make clean
108 # then use Makefile.old for realclean rather than rebuild it
109 if test ! -f $makefile -a -f Makefile.old; then
110 makefile=Makefile.old
111 makeopts="-f $makefile"
112 echo "Note: Using Makefile.old"
116 *) # for the time being we are strict about what make_ext is used for
117 echo "make_ext: unknown make target '$target'"; exit 1
119 '') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1
123 if test ! -f $makefile ; then
124 test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib -MCross Makefile.PL INSTALLDIRS=perl PERL_CORE=1 $passthru
126 if test ! -f $makefile ; then
127 echo "Warning: No Makefile!"
133 *) # Give makefile an opportunity to rewrite itself.
134 # reassure users that life goes on...
135 $MAKE config MAKE=$MAKE $passthru || echo "$MAKE config failed, continuing anyway..."
139 $MAKE $makeopts $target MAKE=$MAKE $makeargs $passthru || exit