3 # This script acts as a simple interface for building extensions.
4 # It primarily used by the perl Makefile:
6 # d_dummy $(dynamic_ext): miniperl preplibrary FORCE
7 # ext/util/make_ext dynamic $@
9 # It may be deleted in a later release of perl so try to
10 # avoid using it for other purposes.
14 passthru="$*" # allow extra macro=value to be passed through
19 if test -f config.sh; then TOP=.;
20 elif test -f ../config.sh; then TOP=..;
21 elif test -f ../../config.sh; then TOP=../..;
22 elif test -f ../../../config.sh; then TOP=../../..;
23 elif test -f ../../../../config.sh; then TOP=../../../..;
25 echo "Can't find config.sh generated by Configure"; exit 1
31 if test "X$extspec" = X; then
32 echo "make_ext: no extension specified"
36 # The Perl Makefile.SH will expand all extensions to
37 # lib/auto/X/X.a (or lib/auto/X/Y/Y.a if nested)
38 # A user wishing to run make_ext might use
39 # X (or X/Y or X::Y if nested)
41 # canonise into X/Y form (pname)
43 lib*) # Remove lib/auto prefix and /*.* suffix
44 pname=`echo "$extspec" | sed -e 's:^lib/auto/::' -e 's:/[^/]*\.[^/]*$::' ` ;;
45 *::*) # Convert :: to /
46 pname=`echo "$extspec" | sed -e 's/::/\//g' ` ;;
47 *) pname="$extspec" ;;
49 # echo "Converted $extspec to $pname"
51 mname=`echo "$pname" | sed -e 's!/!::!g'`
52 depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'`
57 if test ! -d "ext/$pname"; then
58 echo " Skipping $extspec (directory does not exist)"
59 exit 0 # not an error ?
63 echo " Making $mname ($target)"
67 # check link type and do any preliminaries
69 # convert 'static' or 'dynamic' into 'all LINKTYPE=XXX'
70 static) makeargs="LINKTYPE=static CCCDLFLAGS="
73 dynamic) makeargs="LINKTYPE=dynamic";
77 *clean) # If Makefile has been moved to Makefile.old by a make clean
78 # then use Makefile.old for realclean rather than rebuild it
79 if test ! -f $makefile -a -f Makefile.old; then
81 makeopts="-f $makefile"
82 echo "Note: Using Makefile.old"
86 *) # for the time being we are strict about what make_ext is used for
87 echo "make_ext: unknown make target '$target'"; exit 1
89 '') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1
93 if test ! -f $makefile ; then
94 test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL INSTALLDIRS=perl $passthru
96 if test ! -f $makefile ; then
97 if test -f Makefile.SH; then
98 echo "Warning: Writing $makefile from old-style Makefile.SH!"
101 echo "Warning: No Makefile!"
108 *) # Give makefile an opportunity to rewrite itself.
109 # reassure users that life goes on...
110 $make config $passthru || echo "$make config failed, continuing anyway..."
114 $make $makeopts $target $makeargs $passthru || exit