Patch applying of #3499 had gone awry.
[p5sagit/p5-mst-13.2.git] / cygwin32 / Makefile.SHs
CommitLineData
8736538c 1# This file is read by Makefile.SH to produce rules for $(LIBPERL) (and
2# some additional rules as well).
3
4# Rerun `sh Makefile.SH; make depend' after making any change.
5
6# Additional rules supported: libperls.a (for static linking),
7# ld2, perlld (dynamic linking tools)
8#
9
10#! /bin/sh
11case $CONFIG in
12'')
13 if test -f config.sh; then TOP=.;
14 elif test -f ../config.sh; then TOP=..;
15 elif test -f ../../config.sh; then TOP=../..;
16 elif test -f ../../../config.sh; then TOP=../../..;
17 elif test -f ../../../../config.sh; then TOP=../../../..;
18 else
19 echo "Can't find config.sh."; exit 1
20 fi
21 . $TOP/config.sh
22 ;;
23esac
24
25addtopath=`pwd`
26$spitshell >>Makefile <<!GROK!THIS!
27
28# shell script feeding perlld to decent perl
f89d6eaa 29ld2: $& Makefile perlld ${src}/cygwin32/ld2.in
8736538c 30 @echo "extracting ld2 (with variable substitutions)"
31 @$sed s,@buildpath@,$addtopath,g <${src}/cygwin32/ld2.in >ld2
32!GROK!THIS!
33
34$spitshell >>Makefile <<!GROK!THIS!
35
36# perlld parameters
37#
38# this one is pretty mandatory
39DLLWRAP = 'dllwrap'
40
41# following are optional.
42WRAPDRIVER = gcc
43DLLTOOL = dlltool
44EXPORT_ALL = 1
45
46# if some of extensions are empty,
47# no corresponding output will be done.
48# most probably, you'd like to have an export library
49DEF_EXT = .def
50EXP_EXT = .exp
51
f89d6eaa 52perlld: $& Makefile ${src}/cygwin32/perlld.in
8736538c 53 @echo "extracting perlld (with variable substitutions)"
54 @$sed -e s,@CC@,\${CC}, -e s,@DLLWRAP@,\${DLLWRAP},g \\
55 -e s,@WRAPDRIVER@,\${WRAPDRIVER},g -e s,@DLLTOOL@,\${DLLTOOL},g \\
56 -e s,@AS@,\${AS},g -e s,@EXPORT_ALL@,\${EXPORT_ALL},g \\
57 -e s,@DEF_EXT@,\${DEF_EXT},g -e s,@EXP_EXT@,\${EXP_EXT},g \\
58 -e s,@LIB_EXT@,\${LIB_EXT},g \\
59 ${src}/cygwin32/perlld.in >perlld
60
61!GROK!THIS!
62
63# make sure that all library names are not malformed
64libperl=`echo $libperl|sed -e s,\\\..*,,`
65
66# it would be nice to allow dll to have any name,
67# but for now i insist on 'lib<whatever>.dll'
68if ( ! ( echo $libperl | grep '^lib' >/dev/null ) )
69then
70 libperl=lib$libperl
71fi
72linklibperl=-l`echo $libperl|sed -e s,^lib,,`
73
74$spitshell >>Makefile <<!GROK!THIS!
75LIBPERL = $libperl
76LLIBPERL= $linklibperl
77LDLIBPTH= PATH=$addtopath:\${PATH}
78CLDFLAGS= -L$addtopath $ldflags
79CAT = $cat
80AWK = $awk
81!GROK!THIS!
82
83case "$useshrplib" in
84true)
85 $spitshell >>Makefile <<'!NO!SUBS!'
f89d6eaa 86cwobj = $(obj)
8736538c 87
88# override default rule (NB: make croaks!) to force dll usage
89perlmain$(OBJ_EXT): perlmain.c
90 $(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB=\"$(LIBPERL)$(LIB_EXT)\" $*.c
91
92# library used to make statically linked executables
93# miniperl is linked against it to avoid libperl.dll locking
94$(LIBPERL)s$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
95 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
96
8736538c 97# dll and import library
98$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) ld2
99 $(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \
100 perl$(OBJ_EXT) $(cwobj) $(libs)
101
102# How to build executables.
103
104# The miniperl -w -MExporter line is a basic cheap test to catch errors
105# before make goes on to run preplibrary and then MakeMaker on extensions.
106# This is very handy because later errors are often caused by miniperl
107# build problems but that's not obvious to the novice.
108# The Module used here must not depend on Config or any extensions.
109
110miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)s$(LIB_EXT)
111 $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL)s $(libs)
112 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
113
114!NO!SUBS!
115 ;;
116*)
117$spitshell >>Makefile <<'!NO!SUBS!'
118
119# perl library
120$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
121 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
122
123# How to build executables.
124
125# The miniperl -w -MExporter line is a basic cheap test to catch errors
126# before make goes on to run preplibrary and then MakeMaker on extensions.
127# This is very handy because later errors are often caused by miniperl
128# build problems but that's not obvious to the novice.
129# The Module used here must not depend on Config or any extensions.
130
131miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT)
132 $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs)
133 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
134
135!NO!SUBS!
136 ;;
137esac
138
139# libperl.a is _the_ library both in dll and static cases
140# $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model
141#
142$spitshell >>Makefile <<'!NO!SUBS!'
143
144perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
145 $(SHRPENV) $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
146
147pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
148 $(SHRPENV) $(LDLIBPTH) purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
149
150purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
151 $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
152
153quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
154 $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
155
156!NO!SUBS!
157
158# suid perl is removed - i've never seen suid scripts for win32
159
160##############################################
161# additional targets
162
163$spitshell >>Makefile <<'!NO!SUBS!'
164
165DIST_DIRECTORY = .dist
166
167distdir: miniperl
168 -mkdir $(DIST_DIRECTORY)
169 ./miniperl '-MExtUtils::Manifest' \
170 -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
171
172!NO!SUBS!