perl 5.000
[p5sagit/p5-mst-13.2.git] / ext / util / make_ext
CommitLineData
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
10linktype=$1
11extspec=$2
12
13case $CONFIG in
14'')
15 if test -f config.sh; then TOP=.;
16 elif test -f ../config.sh; then TOP=..;
17 elif test -f ../../config.sh; then TOP=../..;
18 elif test -f ../../../config.sh; then TOP=../../..;
19 elif test -f ../../../../config.sh; then TOP=../../../..;
20 else
21 echo "Can't find config.sh generated by Configure"; exit 1
22 fi
23 . $TOP/config.sh
24 ;;
25esac
26
27if test "X$extspec" = X; then
28 echo "make_ext: no extension specified"
29 exit 1;
30fi
31
32# convert old style Name.a into ext/Name/Name.a format
33case "$extspec" in
34ext/*) ;;
35*) extspec=`echo "$extspec" | sed -e 's:\(.*\)\.\(.*\):ext/\1/\1.\2:'`
36esac
37
38# get extension directory path, module name and depth
39pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/[^/]*$::'`
40mname=`echo "$pname" | sed -e 's!/!::!'`
41depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'`
42
43if test ! -d "ext/$pname"; then
44 echo " Skipping $extspec (directory does not exist)"
45 exit 0 # not an error ?
46fi
47
48# check link type and do any preliminaries
49case "$linktype" in
50static) makeargs='CCCDLFLAGS=' ;;
51dynamic) makeargs='' ;;
52*) echo "make_ext: unknown link type '$linktype'"; exit 1;;
53'') echo "make_ext: no link type specified (eg static or dynamic)"; exit 1;;
54esac
55
56echo ""
57echo " Making $mname ($linktype)"
58
59cd ext/$pname
60
61if test ! -f Makefile ; then
62 test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL
63fi
64if test ! -f Makefile ; then
65 test -f Makefile.SH && sh Makefile.SH
66fi
67
68make=${altmake-make}
69
70$make config
71
72$make $linktype $makeargs
73
74exit $?