This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use File::Find rather than shell globbing to get the list of *.pm files
[perl5.git] / cygwin / 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: libperl.a (for static linking),
7 # ld2 and perlld removed
8 #
9
10 #! /bin/sh
11 case $PERL_CONFIG_SH 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 | sed -e 's/ /\\\ /g'`
26 $spitshell >>Makefile <<!GROK!THIS!
27
28 cygwin.c: cygwin/cygwin.c
29         \$(LNS) cygwin/cygwin.c
30
31 !GROK!THIS!
32
33 # make sure that all library names are not malformed
34 libperl=`echo $libperl|sed -e s,\\\..*,,`
35 linklibperl=-l`echo $libperl|sed -e s,^lib,,`
36 vers=`echo $version|tr '.' '_'`
37 dllname=`echo $libperl|sed -e s,^lib,cyg,``echo $vers|sed -e s,_[0-9]$,,`
38 # append "d" suffix to -DDEBUGGING build: cygperl5_10d.dll
39 case $config_args in
40   *DEBUGGING*)
41       dllname="${dllname}"d
42       ;;
43 esac
44 # added -mms-bitfields to be able to link to MSVC win32 bitfields libs 
45 # (4 byte instead of 2 byte alignment)
46
47 $spitshell >>Makefile <<!GROK!THIS!
48 LIBPERL = $libperl
49 LLIBPERL= $linklibperl
50 DLLNAME= $dllname
51 CLDFLAGS= -L$addtopath $ldflags
52 LDDLFLAGS = --shared -L$addtopath $ldflags
53 CCFLAGS=$ccflags -mms-bitfields 
54 PLDLFLAGS = 
55 CAT = $cat
56 AWK = $awk
57 !GROK!THIS!
58
59 case "$useshrplib" in
60 true)
61         $spitshell >>Makefile <<'!NO!SUBS!'
62 cwobj = $(obj)
63
64 # override default rule (NB: make croaks!) to force dll usage
65 perlmain$(OBJ_EXT): perlmain.c
66         $(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB $*.c
67
68 # library used to make statically linked executables
69 # miniperl is linked against it to avoid libperl.dll locking
70 $(LIBPERL)$(LIB_EXT): $& $(cwobj)
71         $(AR) rcu $@ $(cwobj)
72
73 # dll and import library
74 $(LIBPERL).dll$(LIB_EXT): $& $(cwobj)
75         $(LDLIBPTH) $(CC) $(SHRPLDFLAGS) -o $(DLLNAME)$(DLSUFFIX) -Wl,--out-implib=$@ \
76         $(cwobj) $(libs)
77
78 # How to build executables.
79
80 # The miniperl -w -MExporter line is a basic cheap test to catch errors
81 # before make goes on to run preplibrary and then MakeMaker on extensions.
82 # This is very handy because later errors are often caused by miniperl
83 # build problems but that's not obvious to the novice.
84 # The Module used here must not depend on Config or any extensions.
85
86 miniperl.exe \
87 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
88         $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(libs)
89         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
90
91 perl.exe \
92 perl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
93         $(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
94
95 pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
96         $(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
97
98 purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
99         $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
100
101 quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
102         $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
103
104 !NO!SUBS!
105         ;;
106 *)
107 $spitshell >>Makefile <<'!NO!SUBS!'
108 cwobj = $(obj)
109
110 # perl library
111 $(LIBPERL)$(LIB_EXT): $& $(cwobj)
112         $(AR) rcu $@ $(cwobj)
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
122 miniperl.exe \
123 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
124         $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
125         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
126
127 perl.exe \
128 perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
129         $(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) -Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic `cat ext.libs` $(libs)
130
131 pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(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
134 purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(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
137 quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(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
140 !NO!SUBS!
141         ;;
142 esac
143
144 # libperl.a is _the_ library both in dll and static cases
145 # $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model
146 #
147 # NOTE: The "-Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic" is required to give
148 # the import library linking priority over the dynamic library, since both
149 # the .dll and .a are in the same directory.  When the new standard for
150 # naming import/dynamic/static libraries emerges this should be updated.
151 #
152 $spitshell >>Makefile <<'!NO!SUBS!'
153
154
155 !NO!SUBS!
156
157 # suid perl is removed - i've never seen suid scripts for win32
158
159 ##############################################
160 # additional targets
161
162 $spitshell >>Makefile <<'!NO!SUBS!'
163
164 DIST_DIRECTORY = .dist
165
166 distdir: miniperl
167         -mkdir $(DIST_DIRECTORY)
168         ./miniperl -Ilib '-MExtUtils::Manifest' \
169         -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
170
171 test_prep: 
172
173 !NO!SUBS!