This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove hardcoded version number from cygwin/perlld.in
[perl5.git] / cygwin / Makefile.SHs
CommitLineData
8736538c
AS
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
8b56a609 11case $PERL_CONFIG_SH in
8736538c
AS
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
5db16f6a 28cygwin.c: cygwin/cygwin.c
6b49d266 29 \$(LNS) cygwin/cygwin.c
5db16f6a 30
8736538c 31# shell script feeding perlld to decent perl
2c2d71f5 32ld2: $& Makefile perlld ${src}/cygwin/ld2.in
8736538c 33 @echo "extracting ld2 (with variable substitutions)"
2c2d71f5 34 @$sed s,@buildpath@,$addtopath,g <${src}/cygwin/ld2.in >ld2
1cab015a
EF
35 @echo "installing ld2 into $installbin"
36# install is included in Cygwin distributions, and we make a note of th
2c2d71f5 37# requirement in the README.cygwin file. However, let's give them
1cab015a 38# a warning.
fef85aae 39 @/usr/bin/install -c -m 755 ld2 ${installbin}/ld2
b82baff6 40 @if test ! -f ${installbin}/ld2; then \
1cab015a 41 echo "*************************************************" ; \
1cab015a
EF
42 echo "Make will probably fail in a few more steps." ; \
43 echo "When it does, copy \"ld2\" to a directory in" ; \
44 echo "your path, other than \".\"." ; \
45 echo "\"/usr/local/bin\" or something similar will do." ; \
46 echo "Then restart make." ; \
47 echo "*************************************************" ; \
48 fi
49
8736538c
AS
50!GROK!THIS!
51
52$spitshell >>Makefile <<!GROK!THIS!
53
54# perlld parameters
55#
dfc05e5b 56# these ones are mandatory
8736538c 57DLLWRAP = 'dllwrap'
dfc05e5b 58VERSION = '$version'
8736538c
AS
59
60# following are optional.
61WRAPDRIVER = gcc
62DLLTOOL = dlltool
63EXPORT_ALL = 1
64
65# if some of extensions are empty,
66# no corresponding output will be done.
67# most probably, you'd like to have an export library
68DEF_EXT = .def
69EXP_EXT = .exp
70
2c2d71f5 71perlld: $& Makefile ${src}/cygwin/perlld.in
8736538c
AS
72 @echo "extracting perlld (with variable substitutions)"
73 @$sed -e s,@CC@,\${CC}, -e s,@DLLWRAP@,\${DLLWRAP},g \\
74 -e s,@WRAPDRIVER@,\${WRAPDRIVER},g -e s,@DLLTOOL@,\${DLLTOOL},g \\
75 -e s,@AS@,\${AS},g -e s,@EXPORT_ALL@,\${EXPORT_ALL},g \\
76 -e s,@DEF_EXT@,\${DEF_EXT},g -e s,@EXP_EXT@,\${EXP_EXT},g \\
dfc05e5b 77 -e s,@LIB_EXT@,\${LIB_EXT},g -e s,@VERSION@,\${VERSION},g \\
2c2d71f5 78 ${src}/cygwin/perlld.in >perlld
8736538c
AS
79
80!GROK!THIS!
81
82# make sure that all library names are not malformed
83libperl=`echo $libperl|sed -e s,\\\..*,,`
84
8736538c
AS
85linklibperl=-l`echo $libperl|sed -e s,^lib,,`
86
87$spitshell >>Makefile <<!GROK!THIS!
88LIBPERL = $libperl
89LLIBPERL= $linklibperl
8736538c
AS
90CLDFLAGS= -L$addtopath $ldflags
91CAT = $cat
92AWK = $awk
93!GROK!THIS!
94
95case "$useshrplib" in
96true)
97 $spitshell >>Makefile <<'!NO!SUBS!'
f89d6eaa 98cwobj = $(obj)
8736538c
AS
99
100# override default rule (NB: make croaks!) to force dll usage
101perlmain$(OBJ_EXT): perlmain.c
1cab015a 102 $(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB $*.c
8736538c
AS
103
104# library used to make statically linked executables
105# miniperl is linked against it to avoid libperl.dll locking
b53432e4 106$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
8736538c
AS
107 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
108
8736538c 109# dll and import library
b53432e4 110$(LIBPERL).dll$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) ld2
8736538c
AS
111 $(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \
112 perl$(OBJ_EXT) $(cwobj) $(libs)
113
114# How to build executables.
115
116# The miniperl -w -MExporter line is a basic cheap test to catch errors
117# before make goes on to run preplibrary and then MakeMaker on extensions.
118# This is very handy because later errors are often caused by miniperl
119# build problems but that's not obvious to the novice.
120# The Module used here must not depend on Config or any extensions.
121
30f43356 122miniperl.exe \
b53432e4
GH
123miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
124 $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
bd0dd1d8 125 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
8736538c 126
b53432e4
GH
127perl.exe \
128perl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
129 $(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
130
131pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
132 $(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
133
134purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
135 $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
136
137quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
138 $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
139
8736538c
AS
140!NO!SUBS!
141 ;;
142*)
143$spitshell >>Makefile <<'!NO!SUBS!'
d493b042 144cwobj = $(obj)
8736538c
AS
145
146# perl library
147$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
148 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
149
150# How to build executables.
151
152# The miniperl -w -MExporter line is a basic cheap test to catch errors
153# before make goes on to run preplibrary and then MakeMaker on extensions.
154# This is very handy because later errors are often caused by miniperl
155# build problems but that's not obvious to the novice.
156# The Module used here must not depend on Config or any extensions.
157
30f43356 158miniperl.exe \
bd0dd1d8 159miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
74294fdf 160 $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
bd0dd1d8 161 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
8736538c 162
b53432e4
GH
163perl.exe \
164perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
165 $(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) -Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic `cat ext.libs` $(libs)
166
167pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
168 $(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
169
170purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
171 $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
172
173quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
174 $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
175
8736538c
AS
176!NO!SUBS!
177 ;;
178esac
179
180# libperl.a is _the_ library both in dll and static cases
181# $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model
182#
b250498f
GS
183# NOTE: The "-Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic" is required to give
184# the import library linking priority over the dynamic library, since both
185# the .dll and .a are in the same directory. When the new standard for
186# naming import/dynamic/static libraries emerges this should be updated.
187#
8736538c
AS
188$spitshell >>Makefile <<'!NO!SUBS!'
189
8736538c
AS
190
191!NO!SUBS!
192
193# suid perl is removed - i've never seen suid scripts for win32
194
195##############################################
196# additional targets
197
198$spitshell >>Makefile <<'!NO!SUBS!'
199
200DIST_DIRECTORY = .dist
201
202distdir: miniperl
203 -mkdir $(DIST_DIRECTORY)
204 ./miniperl '-MExtUtils::Manifest' \
205 -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
206
207!NO!SUBS!