This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(Was Re: SunOS4.1 compilation error)
[perl5.git] / cygwin32 / 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
29ld2: $& Makefile perlld ${src}/cygwin32/ld2.in ${src}/impure_ptr\$(OBJ_EXT)
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
52perlld: $& Makefile ${src}/cygwin32/perlld.in ${src}/impure_ptr\$(OBJ_EXT)
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!'
86# impure pointer initialisation
87cwobj = impure_ptr$(OBJ_EXT) $(obj)
88
89# override default rule (NB: make croaks!) to force dll usage
90perlmain$(OBJ_EXT): perlmain.c
91 $(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB=\"$(LIBPERL)$(LIB_EXT)\" $*.c
92
93# library used to make statically linked executables
94# miniperl is linked against it to avoid libperl.dll locking
95$(LIBPERL)s$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
96 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
97
98impure_ptr$(OBJ_EXT): cygwin32/impure_ptr.c
99 $(CCCMD) $(PLDLFLAGS) cygwin32/impure_ptr.c
100
101# dll and import library
102$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) ld2
103 $(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \
104 perl$(OBJ_EXT) $(cwobj) $(libs)
105
106# How to build executables.
107
108# The miniperl -w -MExporter line is a basic cheap test to catch errors
109# before make goes on to run preplibrary and then MakeMaker on extensions.
110# This is very handy because later errors are often caused by miniperl
111# build problems but that's not obvious to the novice.
112# The Module used here must not depend on Config or any extensions.
113
114miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)s$(LIB_EXT)
115 $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL)s $(libs)
116 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
117
118!NO!SUBS!
119 ;;
120*)
121$spitshell >>Makefile <<'!NO!SUBS!'
122
123# perl library
124$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
125 $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
126
127# How to build executables.
128
129# The miniperl -w -MExporter line is a basic cheap test to catch errors
130# before make goes on to run preplibrary and then MakeMaker on extensions.
131# This is very handy because later errors are often caused by miniperl
132# build problems but that's not obvious to the novice.
133# The Module used here must not depend on Config or any extensions.
134
135miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT)
136 $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs)
137 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
138
139!NO!SUBS!
140 ;;
141esac
142
143# libperl.a is _the_ library both in dll and static cases
144# $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model
145#
146$spitshell >>Makefile <<'!NO!SUBS!'
147
148perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
149 $(SHRPENV) $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
150
151pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
152 $(SHRPENV) $(LDLIBPTH) purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
153
154purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
155 $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
156
157quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
158 $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
159
160!NO!SUBS!
161
162# suid perl is removed - i've never seen suid scripts for win32
163
164##############################################
165# additional targets
166
167$spitshell >>Makefile <<'!NO!SUBS!'
168
169DIST_DIRECTORY = .dist
170
171distdir: miniperl
172 -mkdir $(DIST_DIRECTORY)
173 ./miniperl '-MExtUtils::Manifest' \
174 -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
175
176!NO!SUBS!