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