ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/staticperl/perl/ext/util/make_ext
Revision: 1.1
Committed: Thu Jun 30 14:27:07 2005 UTC (21 years, 4 months ago) by root
Branch: MAIN
CVS Tags: PERL-5-8-7, HEAD
Branch point for: PERL
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/bin/sh
2    
3     # This script acts as a simple interface for building extensions.
4     # It primarily used by the perl Makefile:
5     #
6     # d_dummy $(dynamic_ext): miniperl preplibrary FORCE
7     # @sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
8     #
9     # It may be deleted in a later release of perl so try to
10     # avoid using it for other purposes.
11    
12     target=$1; shift
13     extspec=$1; shift
14     makecmd=$1; shift # Should be something like MAKE=make
15     passthru="$*" # allow extra macro=value to be passed through
16     echo ""
17    
18     # Previously, $make was taken from config.sh. However, the user might
19     # instead be running a possibly incompatible make. This might happen if
20     # the user types "gmake" instead of a plain "make", for example. The
21     # correct current value of MAKE will come through from the main perl
22     # makefile as MAKE=/whatever/make in $makecmd. We'll be cautious in
23     # case third party users of this script (are there any?) don't have the
24     # MAKE=$(MAKE) argument, which was added after 5.004_03.
25     case "$makecmd" in
26     MAKE=*)
27     eval $makecmd
28     ;;
29     *) echo 'ext/util/make_ext: WARNING: Please include MAKE=$(MAKE)'
30     echo ' in your call to make_ext. See ext/util/make_ext for details.'
31     exit 1
32     ;;
33     esac
34    
35    
36     case $CONFIG in
37     '')
38     if test -f config.sh; then TOP=.;
39     elif 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     else
44     echo "Can't find config.sh generated by Configure"; exit 1
45     fi
46     . $TOP/config.sh
47     ;;
48     esac
49    
50     if test "X$extspec" = X; then
51     echo "make_ext: no extension specified"
52     exit 1;
53     fi
54    
55     # The Perl Makefile.SH will expand all extensions to
56     # lib/auto/X/X.a (or lib/auto/X/Y/Y.a if nested)
57     # A user wishing to run make_ext might use
58     # X (or X/Y or X::Y if nested)
59    
60     # canonise into X/Y form (pname)
61     case "$extspec" in
62     lib*) # Remove lib/auto prefix and /*.* suffix
63     pname=`echo "$extspec" | sed -e 's:^lib/auto/::' -e 's:/[^/]*\.[^/]*$::' ` ;;
64     ext*) # Remove ext/ prefix and /pm_to_blib suffix
65     pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/pm_to_blib$::' ` ;;
66     *::*) # Convert :: to /
67     pname=`echo "$extspec" | sed -e 's/::/\//g' ` ;;
68     *) pname="$extspec" ;;
69     esac
70     # echo "Converted $extspec to $pname"
71    
72     mname=`echo "$pname" | sed -e 's!/!::!g'`
73     depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'`
74     makefile=Makefile
75     makeargs=''
76     makeopts=''
77    
78     if test ! -d "ext/$pname"; then
79     echo " Skipping $extspec (directory does not exist)"
80     exit 0 # not an error ?
81     fi
82    
83    
84     echo " Making $mname ($target)"
85    
86     cd ext/$pname
87    
88     # check link type and do any preliminaries. Valid link types are
89     # 'dynamic', 'static', and 'static_pic' (the last one respects
90     # CCCDLFLAGS such as -fPIC -- see static_target in the main Makefile.SH)
91     case "$target" in
92     dynamic) makeargs="LINKTYPE=dynamic";
93     target=all
94     ;;
95     static) makeargs="LINKTYPE=static CCCDLFLAGS="
96     target=all
97     ;;
98     static_pic) makeargs="LINKTYPE=static"
99     target=all
100     ;;
101     nonxs) makeargs="";
102     target=all
103     ;;
104    
105     *clean) # If Makefile has been moved to Makefile.old by a make clean
106     # then use Makefile.old for realclean rather than rebuild it
107     if test ! -f $makefile -a -f Makefile.old; then
108     makefile=Makefile.old
109     makeopts="-f $makefile"
110     echo "Note: Using Makefile.old"
111     fi
112     ;;
113    
114     *) # for the time being we are strict about what make_ext is used for
115     echo "make_ext: unknown make target '$target'"; exit 1
116     ;;
117     '') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1
118     ;;
119     esac
120    
121     if test ! -f $makefile ; then
122     test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL INSTALLDIRS=perl PERL_CORE=1 $passthru
123     fi
124     if test ! -f $makefile ; then
125     if test -f Makefile.SH; then
126     echo "Warning: Writing $makefile from old-style Makefile.SH!"
127     sh Makefile.SH
128     else
129     echo "Warning: No Makefile!"
130     fi
131     fi
132    
133     case "$target" in
134     clean) ;;
135     realclean) ;;
136     *) # Give makefile an opportunity to rewrite itself.
137     # reassure users that life goes on...
138     $MAKE config $passthru || echo "$MAKE config failed, continuing anyway..."
139     ;;
140     esac
141    
142     $MAKE $makeopts $target $makeargs $passthru || exit
143    
144     exit $?