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