summaryrefslogtreecommitdiff
path: root/cygwin/Makefile.SHs
blob: 8c0e47a23eaf87ee380006a0ab4af87d33410e13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# This file is read by Makefile.SH to produce rules for $(LIBPERL) (and
# some additional rules as well).

# Rerun `sh Makefile.SH; make depend' after making any change.

# Additional rules supported: libperls.a (for static linking),
# ld2, perlld (dynamic linking tools)
#

#! /bin/sh
case $PERL_CONFIG_SH in
'')
	if test -f config.sh; then TOP=.;
	elif test -f ../config.sh; then TOP=..;
	elif test -f ../../config.sh; then TOP=../..;
	elif test -f ../../../config.sh; then TOP=../../..;
	elif test -f ../../../../config.sh; then TOP=../../../..;
	else
		echo "Can't find config.sh."; exit 1
	fi
	. $TOP/config.sh
	;;
esac

addtopath=`pwd | sed -e 's/ /\\\ /g'`
$spitshell >>Makefile <<!GROK!THIS!

cygwin.c: cygwin/cygwin.c
	\$(LNS) cygwin/cygwin.c

# shell script feeding perlld to decent perl
ld2: $& Makefile perlld ${src}/cygwin/ld2.in
	@echo "extracting ld2 (with variable substitutions)"
	@$sed s,@buildpath@,$addtopath,g <${src}/cygwin/ld2.in >ld2
	@chmod a+x ld2
	@echo "installing ld2 into $installbin"
# install is included in Cygwin distributions, and we make a note of the
# requirement in the README.cygwin file. However, let's give them
# a warning.
	@test -d ${installbin} || mkdir -p ${installbin}
	@/usr/bin/install -c -m 755 ld2 ${installbin}/ld2
	@if test ! -f  ${installbin}/ld2; then \
		echo "*************************************************" ; \
		echo "Make will probably fail in a few more steps." ; \
		echo "When it does, copy \"ld2\" to a directory in" ; \
		echo "your path, other than \".\"." ; \
		echo "\"/usr/local/bin\" or something similar will do." ; \
		echo "Then restart make." ; \
		echo "*************************************************" ; \
	fi

!GROK!THIS!

$spitshell >>Makefile <<!GROK!THIS!

# perlld parameters
#
# these ones are mandatory
VERSION = '$version'

# following are optional.
EXPORT_ALL = 1

# if some of extensions are empty,
# no corresponding output will be done.
# most probably, you'd like to have an export library
DEF_EXT = .def
EXP_EXT = .exp

perlld: $& Makefile ${src}/cygwin/perlld.in
	@echo "extracting perlld (with variable substitutions)"
	@$sed -e s,@CC@,\${CC}, -e s,@EXPORT_ALL@,\${EXPORT_ALL},g \\
	-e s,@DEF_EXT@,\${DEF_EXT},g -e s,@EXP_EXT@,\${EXP_EXT},g \\
	-e s,@LIB_EXT@,\${LIB_EXT},g -e s,@VERSION@,\${VERSION},g \\
	${src}/cygwin/perlld.in >perlld

!GROK!THIS!

# make sure that all library names are not malformed
libperl=`echo $libperl|sed -e s,\\\..*,,`

linklibperl=-l`echo $libperl|sed -e s,^lib,,`

$spitshell >>Makefile <<!GROK!THIS!
LIBPERL = $libperl
LLIBPERL= $linklibperl
CLDFLAGS= -L$addtopath $ldflags
CAT = $cat
AWK = $awk
!GROK!THIS!

case "$useshrplib" in
true)
	$spitshell >>Makefile <<'!NO!SUBS!'
cwobj = $(obj)

# override default rule (NB: make croaks!) to force dll usage
perlmain$(OBJ_EXT): perlmain.c
	$(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB $*.c

# library used to make statically linked executables
# miniperl is linked against it to avoid libperl.dll locking
$(LIBPERL)$(LIB_EXT): $& $(cwobj)
	$(AR) rcu $@ $(cwobj)

# dll and import library
$(LIBPERL).dll$(LIB_EXT): $& $(cwobj) ld2
	$(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \
	$(cwobj) $(libs)

# How to build executables.

# The miniperl -w -MExporter line is a basic cheap test to catch errors
# before make goes on to run preplibrary and then MakeMaker on extensions.
# This is very handy because later errors are often caused by miniperl
# build problems but that's not obvious to the novice.
# The Module used here must not depend on Config or any extensions.

miniperl.exe \
miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
	$(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
	$(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest

perl.exe \
perl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL).dll$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

!NO!SUBS!
	;;
*)
$spitshell >>Makefile <<'!NO!SUBS!'
cwobj = $(obj)

# perl library
$(LIBPERL)$(LIB_EXT): $& $(cwobj)
	$(AR) rcu $@ $(cwobj)

# How to build executables.

# The miniperl -w -MExporter line is a basic cheap test to catch errors
# before make goes on to run preplibrary and then MakeMaker on extensions.
# This is very handy because later errors are often caused by miniperl
# build problems but that's not obvious to the novice.
# The Module used here must not depend on Config or any extensions.

miniperl.exe \
miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
	$(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
	$(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest

perl.exe \
perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) -Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic `cat ext.libs` $(libs)

pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs
	$(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

!NO!SUBS!
	;;
esac

# libperl.a is _the_ library both in dll and static cases
# $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model
#
# NOTE: The "-Wl,-Bstatic $(LLIBPERL) -Wl,-Bdynamic" is required to give
# the import library linking priority over the dynamic library, since both
# the .dll and .a are in the same directory.  When the new standard for
# naming import/dynamic/static libraries emerges this should be updated.
#
$spitshell >>Makefile <<'!NO!SUBS!'


!NO!SUBS!

# suid perl is removed - i've never seen suid scripts for win32

##############################################
# additional targets

$spitshell >>Makefile <<'!NO!SUBS!'

DIST_DIRECTORY = .dist

distdir: miniperl
	-mkdir $(DIST_DIRECTORY)
	./miniperl '-MExtUtils::Manifest' \
	-e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"

cygwin1.dll: /bin/cygwin1.dll
	cp /bin/cygwin1.dll .

cygcrypt-0.dll: /bin/cygcrypt-0.dll
	cp /bin/cygcrypt-0.dll .

test_prep: cygwin1.dll cygcrypt-0.dll

!NO!SUBS!