This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
a675d7433d9d27627e348962ce7c2312580f4601
[perl5.git] / cygwin32 / Makefile.SHs
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
11 case $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         ;;
23 esac
24
25 addtopath=`pwd`
26 $spitshell >>Makefile <<!GROK!THIS!
27
28 # shell script feeding perlld to decent perl
29 ld2: $& Makefile perlld ${src}/cygwin32/ld2.in
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
39 DLLWRAP = 'dllwrap'
40
41 # following are optional.
42 WRAPDRIVER = gcc
43 DLLTOOL = dlltool
44 EXPORT_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
49 DEF_EXT = .def
50 EXP_EXT = .exp
51
52 perlld: $& Makefile ${src}/cygwin32/perlld.in
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
64 libperl=`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'
68 if ( ! ( echo $libperl | grep '^lib' >/dev/null ) )
69 then
70   libperl=lib$libperl
71 fi
72 linklibperl=-l`echo $libperl|sed -e s,^lib,,`
73
74 $spitshell >>Makefile <<!GROK!THIS!
75 LIBPERL = $libperl
76 LLIBPERL= $linklibperl
77 LDLIBPTH= PATH=$addtopath:\${PATH}
78 CLDFLAGS= -L$addtopath $ldflags
79 CAT = $cat
80 AWK = $awk
81 !GROK!THIS!
82
83 case "$useshrplib" in
84 true)
85         $spitshell >>Makefile <<'!NO!SUBS!'
86 cwobj = $(obj)
87
88 # override default rule (NB: make croaks!) to force dll usage
89 perlmain$(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
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
110 miniperl: $& 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
131 miniperl: $& 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         ;;
137 esac
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
144 perl: $& 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
147 pureperl: $& 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
150 purecovperl: $& 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
153 quantperl: $& 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
165 DIST_DIRECTORY = .dist
166
167 distdir: miniperl
168         -mkdir $(DIST_DIRECTORY)
169         ./miniperl '-MExtUtils::Manifest' \
170         -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
171
172 !NO!SUBS!