This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.000
[perl5.git] / ext / POSIX / Makefile.SH
CommitLineData
a0d0e21e
LW
1: This forces SH files to create target in same directory as SH file.
2: This is so that make depend always knows where to find SH derivatives.
3
4case "$0" in
5*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
6esac
7
8if test -f config.sh; then TOP=.;
9elif test -f ../config.sh; then TOP=..;
10elif test -f ../../config.sh; then TOP=../..;
11elif test -f ../../../config.sh; then TOP=../../..;
12elif test -f ../../../../config.sh; then TOP=../../../..;
13else
14 echo "Can't find config.sh."; exit 1
15fi
16
17: Find absolute path name for TOP. This is needed when we cd to TOP
18: to run perl on autosplit.
19oldpwd=`pwd`; cd $TOP; ABSTOP=`pwd`; cd $oldpwd
20
21case $CONFIG in
22'')
23 . $TOP/config.sh
24 ;;
25esac
26
27: Find out directory name. This is also the extension name.
28ext=`pwd | $sed -e 's@.*/@@'`
29
30: This extension might have its own typemap
31if test -f typemap; then
32 exttypemap='typemap'
33else
34 exttypemap=''
35fi
36
37: This extension might need additional libraries.
38potential_libs="-lm -lposix -lcposix "
39. $TOP/ext/util/extliblist
40
41: This extension might need bootstrap support
42if test -f ${ext}_BS; then
43 bootdep=${ext}_BS
44else
45 bootdep=''
46fi
47
48case "$dlsrc" in
49dl_aix*)
50 echo "#!" > $ext.exp
51 echo "boot_$ext" >> $ext.exp
52 ;;
53esac
54
55echo "Extracting ext/$ext/Makefile (with variable substitutions)"
56: This section of the file will have variable substitutions done on it.
57: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
58: Protect any dollar signs and backticks that you do not want interpreted
59: by putting a backslash in front. You may delete these comments.
60$spitshell >Makefile << !GROK!THIS!
61#
62# This Makefile is for the $ext extension to perl.
63#
64CC = $cc
65RANLIB = $ranlib
66TOP = $TOP
67ABSTOP = $ABSTOP
68LDFLAGS = $ldflags
69CLDFLAGS = $ldflags
70SMALL = $small
71LARGE = $large $split
72
73# To use an alternate make, set \$altmake in config.sh.
74MAKE = ${altmake-make}
75
76EXT = $ext
77
78# $ext might have its own typemap
79EXTTYPEMAP = $exttypemap
80
81# $ext might have its own bootstrap support
82BOOTDEP = $bootdep
83BOOTSTRAP = $ext.bs
84
85# The following are used to build and install shared libraries for
86# dynamic loading.
87LDDLFLAGS = $lddlflags
88CCDLFLAGS = $ccdlflags
89CCCDLFLAGS = $cccdlflags
90SO = $so
91DLEXT = $dlext
92
93# $ext might need to be linked with some extra libraries.
94# EXTRALIBS = full list of libraries needed for static linking.
95# Only those libraries that actually exist are included.
96# DYNLOADLIBS = list of those libraries that are needed but can be
97# linked in dynamically on this platform. On SunOS, for
98# example, this would be .so* libraries, but not archive
99# libraries. The bootstrap file is installed only if
100# this list is not empty.
101# STATLOADLIBS = list of those libraries which must be statically
102# linked into the shared library. On SunOS 4.1.3,
103# for example, I have only an archive version of
104# -lm, and it must be linked in statically.
105EXTRALIBS = $extralibs
106DYNALOADLIBS = $dynaloadlibs
107STATLOADLIBS = $statloadlibs
108
109!GROK!THIS!
110
111$spitshell >>Makefile <<'!NO!SUBS!'
112
113# Where to put things:
114AUTO = $(TOP)/lib/auto
115INSTALLBOOT = $(AUTO)/$(EXT)/$(EXT).bs
116INSTALLDYNAMIC = $(AUTO)/$(EXT)/$(EXT).$(DLEXT)
117INSTALLSTATIC = $(EXT).a
118INSTALLPM = $(TOP)/lib/$(EXT).pm
119
120PERL = $(ABSTOP)/miniperl
121XSUBPP = $(TOP)/ext/xsubpp
122SHELL = /bin/sh
123CCCMD = `sh $(shellflags) $(TOP)/cflags $@`
124
125.c.o:
126 $(CCCMD) $(CCCDLFLAGS) -I$(TOP) $*.c
127
128all: dynamic
129# Phony target to force checking subdirectories.
130FORCE:
131
132config:
133
134# Target for Dynamic Loading:
135dynamic: $(INSTALLDYNAMIC) $(INSTALLPM) $(INSTALLBOOT)
136
137$(INSTALLDYNAMIC): $(EXT).o
138 @test -d $(AUTO) || mkdir $(AUTO)
139 @test -d $(AUTO)/$(EXT) || mkdir $(AUTO)/$(EXT)
140 ld $(LDDLFLAGS) -o $@ $(EXT).o $(STATLOADLIBS)
141
142$(BOOTSTRAP): Makefile $(BOOTDEP)
143 $(PERL) -I$(TOP)/lib $(TOP)/ext/util/mkbootstrap $(DYNALOADLIBS)
144 touch $(BOOTSTRAP)
145
146$(INSTALLBOOT): $(BOOTSTRAP)
147 @test ! -s $(BOOTSTRAP) || cp $(BOOTSTRAP) $@
148
149# Target for Static Loading:
150static: $(INSTALLSTATIC) $(INSTALLPM)
151
152$(INSTALLSTATIC): $(EXT).o
153 ar cr $@ $(EXT).o
154 $(RANLIB) $@
155 echo $(EXTRALIBS) >> $(TOP)/ext.libs
156
157$(EXT).c: $(EXT).xs $(XSUBPP) $(TOP)/ext/typemap $(EXTTYPEMAP) $(TOP)/cflags Makefile
158 $(PERL) $(XSUBPP) $(EXT).xs >tmp
159 mv tmp $@
160
161$(INSTALLPM): $(EXT).pm
162 rm -f $@
163 cp $(EXT).pm $@
164 cd $(TOP); $(PERL) autosplit $(EXT)
165
166clean:
167 rm -f *.o *.a mon.out core $(EXT).c so_locations $(BOOTSTRAP) $(EXT).exp
168
169realclean: clean
170 rm -f makefile Makefile
171 rm -f $(INSTALLPM) $(INSTALLDYNAMIC) $(INSTALLSTATIC) $(INSTALLBOOT)
172 rm -rf $(AUTO)/$(EXT)
173
174purge: realclean
175
176$(EXT).o : $(TOP)/EXTERN.h
177$(EXT).o : $(TOP)/perl.h
178$(EXT).o : $(TOP)/embed.h
179$(EXT).o : $(TOP)/config.h
180$(EXT).o : $(TOP)/unixish.h
181$(EXT).o : $(TOP)/handy.h
182$(EXT).o : $(TOP)/regexp.h
183$(EXT).o : $(TOP)/sv.h
184$(EXT).o : $(TOP)/util.h
185$(EXT).o : $(TOP)/form.h
186$(EXT).o : $(TOP)/gv.h
187$(EXT).o : $(TOP)/cv.h
188$(EXT).o : $(TOP)/opcode.h
189$(EXT).o : $(TOP)/op.h
190$(EXT).o : $(TOP)/cop.h
191$(EXT).o : $(TOP)/av.h
192$(EXT).o : $(TOP)/hv.h
193$(EXT).o : $(TOP)/mg.h
194$(EXT).o : $(TOP)/scope.h
195$(EXT).o : $(TOP)/pp.h
196$(EXT).o : $(TOP)/proto.h
197$(EXT).o : $(TOP)/XSUB.h
198
199Makefile: Makefile.SH $(TOP)/config.sh ; /bin/sh Makefile.SH
200$(TOP)/config.h: $(TOP)/config.sh; cd $(TOP); /bin/sh config_h.SH
201$(TOP)/embed.h: $(TOP)/config.sh; cd $(TOP); /bin/sh embed_h.SH
202$(TOP)/cflags: $(TOP)/config.sh; cd $(TOP); /bin/sh cflags.SH
203
204!NO!SUBS!
205chmod 644 Makefile
206$eunicefix Makefile
207