Commit | Line | Data |
a0d0e21e |
1 | # This script acts as a simple interface for building extensions. |
2 | # It primarily used by the perl Makefile: |
3 | # |
4 | # d_dummy $(dynamic_ext): miniperl preplibrary FORCE |
5 | # ext/util/make_ext dynamic $@ |
6 | # |
7 | # It may be deleted in a later release of perl so try to |
8 | # avoid using it for other purposes. |
9 | |
42793c05 |
10 | target=$1; shift |
11 | extspec=$1; shift |
12 | passthru="$*" # allow extra macro=value to be passed through |
13 | echo "" |
a0d0e21e |
14 | |
15 | case $CONFIG in |
16 | '') |
17 | if test -f config.sh; then TOP=.; |
18 | elif test -f ../config.sh; then TOP=..; |
19 | elif test -f ../../config.sh; then TOP=../..; |
20 | elif test -f ../../../config.sh; then TOP=../../..; |
21 | elif test -f ../../../../config.sh; then TOP=../../../..; |
22 | else |
23 | echo "Can't find config.sh generated by Configure"; exit 1 |
24 | fi |
25 | . $TOP/config.sh |
26 | ;; |
27 | esac |
28 | |
29 | if test "X$extspec" = X; then |
30 | echo "make_ext: no extension specified" |
31 | exit 1; |
32 | fi |
33 | |
ecfc5424 |
34 | # canonise |
35 | extspec=`echo "$extspec" | sed -e 's:^ext/::' -e 's:\.[^\.]*$::'` |
36 | extspec="ext/$extspec" |
37 | tailext=`echo "$extspec" | sed -e 's:.*/\([^/]*\)$:\1:'"` |
38 | headext=`echo "$extspec" | sed -e 's:/[^/]*$::'"` |
39 | if test -d "$headext/$tailext"; then |
40 | extspec="$headext/$tailext" |
41 | fi |
42 | if test -f "$extspec/$tailext.xs"; then |
43 | extspec="$extspec/$tailext" |
44 | fi |
a0d0e21e |
45 | |
46 | # get extension directory path, module name and depth |
47 | pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/[^/]*$::'` |
e1666bf5 |
48 | mname=`echo "$pname" | sed -e 's!/!::!g'` |
a0d0e21e |
49 | depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'` |
42793c05 |
50 | make=${altmake-make} |
51 | makeargs='' |
a0d0e21e |
52 | |
53 | if test ! -d "ext/$pname"; then |
42793c05 |
54 | echo " Skipping $extspec (directory does not exist)" |
55 | exit 0 # not an error ? |
a0d0e21e |
56 | fi |
57 | |
a0d0e21e |
58 | |
42793c05 |
59 | echo " Making $mname ($target)" |
a0d0e21e |
60 | |
61 | cd ext/$pname |
62 | |
42793c05 |
63 | # check link type and do any preliminaries |
64 | case "$target" in |
65 | # convert 'static' or 'dynamic' into 'all LINKTYPE=XXX' |
66 | static) makeargs="LINKTYPE=static CCCDLFLAGS="; target=all ;; |
67 | dynamic) makeargs="LINKTYPE=dynamic"; target=all ;; |
68 | *clean) ;; |
69 | *) # for the time being we are strict about what make_ext is used for |
70 | echo "make_ext: unknown make target '$target'"; exit 1;; |
71 | '') echo "make_ext: no make target specified (eg static or dynamic)"; exit 1;; |
72 | esac |
73 | |
a0d0e21e |
74 | if test ! -f Makefile ; then |
75 | test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL |
76 | fi |
77 | if test ! -f Makefile ; then |
78 | test -f Makefile.SH && sh Makefile.SH |
79 | fi |
80 | |
42793c05 |
81 | case "$target" in |
82 | clean) ;; |
83 | realclean) ;; |
84 | *) $make config $passthru;; |
85 | esac |
a0d0e21e |
86 | |
42793c05 |
87 | $make $target $makeargs $passthru || exit |
a0d0e21e |
88 | |
89 | exit $? |