Commit | Line | Data |
8ed6d636 |
1 | #!/bin/sh |
2 | |
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: |
6 | # |
7 | # d_dummy $(dynamic_ext): miniperl preplibrary FORCE |
8 | # @sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) |
9 | # |
10 | # It may be deleted in a later release of perl so try to |
11 | # avoid using it for other purposes. |
12 | |
13 | target=$1; shift |
14 | extspec=$1; shift |
15 | makecmd=$1; shift # Should be something like MAKE=make |
16 | passthru="$*" # allow extra macro=value to be passed through |
17 | echo "" |
18 | |
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. |
26 | case "$makecmd" in |
27 | MAKE=*) |
28 | eval $makecmd |
29 | ;; |
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.' |
32 | exit 1 |
33 | ;; |
34 | esac |
35 | |
36 | |
37 | case $CONFIG in |
38 | '') |
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=../../../..; |
44 | else |
45 | echo "Can't find config.sh generated by Configure"; exit 1 |
46 | fi |
47 | . $TOP/config.sh |
48 | ;; |
49 | esac |
50 | |
51 | if test "X$extspec" = X; then |
52 | echo "make_ext: no extension specified" |
53 | exit 1; |
54 | fi |
55 | |
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) |
60 | |
61 | # canonise into X/Y form (pname) |
62 | case "$extspec" in |
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" ;; |
71 | esac |
72 | # echo "Converted $extspec to $pname" |
73 | |
74 | mname=`echo "$pname" | sed -e 's!/!::!g'` |
75 | depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'` |
76 | makefile=Makefile |
77 | makeargs='' |
78 | makeopts='' |
79 | |
80 | if test ! -d "ext/$pname"; then |
81 | echo " Skipping $extspec (directory does not exist)" |
82 | exit 0 # not an error ? |
83 | fi |
84 | |
85 | |
86 | echo " Making $mname ($target)" |
87 | |
88 | cd ext/$pname |
89 | |
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) |
93 | case "$target" in |
94 | dynamic) makeargs="LINKTYPE=dynamic"; |
95 | target=all |
96 | ;; |
97 | static) makeargs="LINKTYPE=static CCCDLFLAGS=" |
98 | target=all |
99 | ;; |
100 | static_pic) makeargs="LINKTYPE=static" |
101 | target=all |
102 | ;; |
103 | nonxs) makeargs=""; |
104 | target=all |
105 | ;; |
106 | |
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" |
113 | fi |
114 | ;; |
115 | |
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 |
118 | ;; |
119 | '') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1 |
120 | ;; |
121 | esac |
122 | |
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 |
125 | fi |
126 | if test ! -f $makefile ; then |
127 | echo "Warning: No Makefile!" |
128 | fi |
129 | |
130 | case "$target" in |
131 | clean) ;; |
132 | realclean) ;; |
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..." |
136 | ;; |
137 | esac |
138 | |
139 | $MAKE $makeopts $target MAKE=$MAKE $makeargs $passthru || exit |
140 | |
141 | exit $? |