Prevent the pragmas from ${^OPEN} propagated to %^H from deparsing.
[p5sagit/p5-mst-13.2.git] / ext / util / make_ext_cross
CommitLineData
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
13target=$1; shift
14extspec=$1; shift
15makecmd=$1; shift # Should be something like MAKE=make
16passthru="$*" # allow extra macro=value to be passed through
17echo ""
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.
26case "$makecmd" in
27MAKE=*)
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 ;;
34esac
35
36
37case $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 ;;
49esac
50
51if test "X$extspec" = X; then
52 echo "make_ext: no extension specified"
53 exit 1;
54fi
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)
62case "$extspec" in
63lib*) # Remove lib/auto prefix and /*.* suffix
64 pname=`echo "$extspec" | sed -e 's:^lib/auto/::' -e 's:/[^/]*\.[^/]*$::' ` ;;
65ext*) # 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" ;;
71esac
72# echo "Converted $extspec to $pname"
73
74mname=`echo "$pname" | sed -e 's!/!::!g'`
75depth=`echo "$pname" | sed -e 's![^/][^/]*!..!g'`
76makefile=Makefile
77makeargs=''
78makeopts=''
79
80if test ! -d "ext/$pname"; then
81 echo " Skipping $extspec (directory does not exist)"
82 exit 0 # not an error ?
83fi
84
85
86echo " Making $mname ($target)"
87
88cd 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)
93case "$target" in
94dynamic) makeargs="LINKTYPE=dynamic";
95 target=all
96 ;;
97static) makeargs="LINKTYPE=static CCCDLFLAGS="
98 target=all
99 ;;
100static_pic) makeargs="LINKTYPE=static"
101 target=all
102 ;;
103nonxs) 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 ;;
121esac
122
123if test ! -f $makefile ; then
124 test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib -MCross Makefile.PL INSTALLDIRS=perl PERL_CORE=1 $passthru
125fi
126if test ! -f $makefile ; then
127 echo "Warning: No Makefile!"
128fi
129
130case "$target" in
131clean) ;;
132realclean) ;;
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 ;;
137esac
138
139$MAKE $makeopts $target MAKE=$MAKE $makeargs $passthru || exit
140
141exit $?