summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/os2/Makefile.SHs
blob: db23b1c9754d07b937421702a57f7f864f528553 (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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# 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: perl_, aout_test, aout_install, use them
# for a.out style perl (which may fork).

perl_fullversion="${PERL_REVISION}.00${PERL_VERSION}_${PERL_SUBVERSION}"
case "$archname" in
 *-thread*)	perl_fullversion="${perl_fullversion}-threaded";;
esac

dll_post="`echo $perl_fullversion | sum | sed -e 's/^0*//' | awk '{print $1}'`"
dll_post="`printf '%x' $dll_post | tr '[a-z]' '[A-Z]'`"

aout_extra_libs=''
aout_extra_sep=''
for xxx in $aout_extra_static_ext; do
  aout_extra_dir=`echo "$xxx" | sed -e 's/::/\//g'`
  aout_extra_lib="lib/auto/$aout_extra_dir/"`basename "$aout_extra_dir"`
  aout_extra_libs="$aout_extra_libs$aout_extra_sep$aout_extra_lib$aout_lib_ext"
  aout_extra_sep=' '
done

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

PERL_FULLVERSION = $perl_fullversion

AOUT_OPTIMIZE	= \$(OPTIMIZE)
AOUT_CCCMD	= \$(CC) -DPERL_CORE $aout_ccflags \$(AOUT_OPTIMIZE)
AOUT_AR		= $aout_ar
AOUT_OBJ_EXT	= $aout_obj_ext
AOUT_LIB_EXT	= $aout_lib_ext
AOUT_LIBPERL	= libperl$aout_lib_ext
AOUT_CLDFLAGS	= $aout_ldflags

AOUT_LIBPERL_DLL	= libperl_dll$aout_lib_ext
AOUT_CCCMD_DLL	= \$(CC) -DDOSISH -DOS2=2 -DEMBED -I. -DPACK_MALLOC -DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPERL_EMERGENCY_SBRK
AOUT_CLDFLAGS_DLL	= -Zexe -Zmt -Zcrtdll -Zstack 32000

# No -DPERL_CORE
SO_CCCMD	= \$(CC) $ccflags \$(OPTIMIZE)

LD_OPT		= \$(OPTIMIZE)
PERL_DLL_LD_OPT = -Zmap -Zlinker /map/li

PERL_DLL_BASE	= perl$dll_post
PERL_DLL	= \$(PERL_DLL_BASE)\$(DLSUFFIX)
TEST_PERL_DLL	= perl_dll_t
CONFIG_ARGS	= $config_args
AOUT_EXTRA_LIBS	= $aout_extra_libs

!GROK!THIS!

$spitshell >>Makefile <<'!NO!SUBS!'
PREPLIBRARY_LIBPERL = $(LIBPERL)
$(LIBPERL): perl.imp perl5.def libperl_override.lib
	emximp -o $(LIBPERL) perl.imp
	cp $(LIBPERL) perl.lib

imp_version: $(FIRSTMAKEFILE)
	echo $(PERL_DLL_BASE) > $@

libperl_override.imp: os2/os2add.sym miniperl imp_version
	./miniperl -wnle 'print "$$_\t$(PERL_DLL_BASE)\t$$_\t?"' os2/os2add.sym > $@
	echo	'strdup	$(PERL_DLL_BASE)	Perl_strdup	?' >> $@
	echo	'putenv	$(PERL_DLL_BASE)	Perl_putenv	?' >> $@

libperl_override.lib: libperl_override.imp
	emximp -o $@ libperl_override.imp

libperl_dllmain.imp: imp_version
	echo	'main	$(PERL_DLL_BASE)	dll_perlmain	?' > $@

libperl_dllmain.lib: libperl_dllmain.imp
	emximp -o $@ libperl_dllmain.imp

libperl_dllmain.a: libperl_dllmain.imp
	emximp -o $@ libperl_dllmain.imp

$(AOUT_LIBPERL_DLL): perl.imp $(PERL_DLL) perl5.def
	emximp -o $(AOUT_LIBPERL_DLL) perl.imp

perl.imp: perl5.def imp_version
	emximp -o perl.imp perl5.def
	echo	'emx_calloc		emxlibcm	400	?' >> $@
	echo	'emx_free		emxlibcm	401	?' >> $@
	echo	'emx_malloc		emxlibcm	402	?' >> $@
	echo	'emx_realloc		emxlibcm	403	?' >> $@

.PHONY: perl_dll installcmd aout_clean aout_install aout_install.perl \
	perlrexx test_prep_perl_ test_prep_perl_sys test_prep_perl_stat \
	test_prep_perl_stat_aout test_prep_various \
	stat_aout_harness aout_harness stat_harness sys_harness all_harness \
	stat_aout_test aout_test stat_test sys_test all_test \
	perl___harness test_harness_redir

perl_dll: $(PERL_DLL)

perl_dll_t: t/$(PERL_DLL)

t/$(PERL_DLL): $(PERL_DLL)
	$(LNS) $(PERL_DLL) t/$(PERL_DLL)

$(PERL_DLL): $(perllib_objs) perl5.def perl$(OBJ_EXT) perlmain$(OBJ_EXT) $(DYNALOADER)
	$(LD) $(LD_OPT) $(LDDLFLAGS) $(PERL_DLL_LD_OPT) -o $@ perl$(OBJ_EXT) $(perllib_objs) perlmain$(OBJ_EXT) $(DYNALOADER) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )

perl5.olddef: perl.linkexp
	echo "LIBRARY '$(PERL_DLL_BASE)' INITINSTANCE TERMINSTANCE"	> $@
	echo DESCRIPTION "'Perl interpreter v$(PERL_FULLVERSION), export autogenerated'"	>>$@
	echo STACKSIZE 32768				>>$@
	echo CODE LOADONCALL				>>$@
	echo DATA LOADONCALL NONSHARED MULTIPLE		>>$@
	echo EXPORTS					>>$@
!NO!SUBS!

if [ ! -z "$myttyname" ] ; then
  $spitshell >>Makefile <<'!NO!SUBS!'
	echo '  "ttyname"'				>>$@
!NO!SUBS!
fi

$spitshell >>Makefile <<'!NO!SUBS!'
	cat perl.linkexp	>>$@

#	grep -v '"\(malloc\|realloc\|free\)"' perl.linkexp	>>$@


perl.exports: perl.exp EXTERN.h perl.h
	(echo "#include \"EXTERN.h\" \n#include \"perl.h\" \n#include \"perl.exp\"";	\
	 echo "malloc\nrealloc\ncalloc\nfree") | \
		$(CC) -DEMBED  -E - | \
		awk '{if ($$2 == "") print $$1}' | sort | uniq > $@

perl.linkexp: perl.exports perl.map  os2/os2.sym
	cat perl.exports os2/os2.sym perl.map | sort | uniq -d | sed -e 's/\w\+/  "\0"/' > perl.linkexp

# We link miniperl statically, since .DLL depends on $(DYNALOADER) 

miniperl.map: miniperl

miniperl.exe: miniperl

miniperl: $(perllib_objs) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
	$(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) `echo $(perllib_objs)|sed -e 's/\bop\./opmini./g'` $(libs) -Zmap -Zlinker /map/PM:VIO
	@./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest

depend: os2ish.h dlfcn.h os2thread.h os2.c

# Stupid make? Needed...
os2$(OBJ_EXT) : os2.c

os2.c: os2/os2.c os2ish.h
	cp -f $< $@

dl_os2.c: os2/dl_os2.c os2ish.h
	cp -f $< $@

os2ish.h: os2/os2ish.h
	cp -f $< $@

os2thread.h: os2/os2thread.h
	cp -f $< $@

dlfcn.h: os2/dlfcn.h
	cp -f $< $@

# Non-Forking dynamically loaded perl
# Make many: they are useful in low-memory conditions (floppy boot?  Lot of shared memory used?)

perl___$(EXE_EXT) perl___: $& libperl_dllmain$(LIB_EXT)
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 8192 -o perl___8 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 4096 -o perl___4 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 2048 -o perl___2 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 1024 -o perl___1 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 512 -o perl___05 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 320 -o perl___03 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO

# This one is compiled -Zsys, so cannot do many things:

# Remove -Zcrtdll
STAT_CLDFLAGS = -Zexe -Zomf -Zmt -Zstack 32000

# Non-forking dynamically loaded perl with a wrong CRT library:

perl_stat perl_stat$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
	$(SHRPENV) $(CC) $(STAT_CLDFLAGS) $(CCDLFLAGS) -o perl_stat libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO

# Remove -Zcrtdll, add -Zsys
SYS_CLDFLAGS = $(STAT_CLDFLAGS) -Zsys

# Non-Forking dynamically loaded perl without EMX - so with wrong CRT library

perl_sys perl_sys$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
	$(SHRPENV) $(CC) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o perl_sys libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO

installcmd : 
	@perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
	./miniperl -Ilib os2/perl2cmd.pl $(INSTALLCMDDIR)

# Aout section:

aout_obj = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(perllib_objs)))
AOUT_DYNALOADER = $(addsuffix $(AOUT_LIB_EXT),$(basename $(DYNALOADER)))
aout_ext = $(static_ext) $(dynamic_ext) $(AOUT_EXTRA_LIBS)
aout_static_ext = $(addsuffix $(AOUT_LIB_EXT),$(basename $(aout_ext)))
aout_static_lib = $(addsuffix $(LIB_EXT),$(basename $(aout_ext)))

aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
DYNALOADER_OBJ = ext/DynaLoader/DynaLoader$(OBJ_EXT)
aout_static_ext_dll = $(addsuffix $(AOUT_LIB_EXT),$(basename $(static_ext)))
AOUT_DYNALOADER_OBJ = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(DYNALOADER_OBJ)))

$(AOUT_DYNALOADER_OBJ) : $(DYNALOADER_OBJ)
	emxaout -o $@ $<

$(DYNALOADER_OBJ) : $(DYNALOADER)
	@sh -c true

# Quick hack to construct directories necessary for /*/% stuff:

$(aout_static_ext) : $(static_ext) $(dynamic_ext)

$(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
	rm -f $@
	$(AOUT_AR) rc $@ perl$(AOUT_OBJ_EXT) $(aout_obj)
	cp $@ perl$(AOUT_LIB_EXT)

.c$(AOUT_OBJ_EXT):
	$(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c

opmini$(AOUT_OBJ_EXT): op.c
	$(AOUT_CCCMD) $(PLDLFLAGS) -DPERL_EXTERNAL_GLOB -o opmini$(AOUT_OBJ_EXT) -c op.c

perlmain(AOUT_OBJ_EXT): perlmain.c
	$(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c

# Assume that extensions are at most 4 deep (this is so with 5.8.1)
aout_extlist: $(aout_static_ext) $(AOUT_DYNALOADER)
	echo lib/auto/*.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a | tr ' ' '\n' | grep -v '\*' > $@

aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit) $(aout_static_ext) writemain aout_extlist
	sh writemain `cat aout_extlist` > aout_perlmain.c

_preplibrary = miniperl lib/Config.pm lib/lib.pm lib/re.pm

miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) opmini$(AOUT_OBJ_EXT) $(_preplibrary)
	$(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) opmini$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(libs)

# Forking statically loaded perl

# Need a miniperl_ dependency, since $(AOUT_DYNALOADER) is build via implicit
# rules, thus would not rebuild miniperl_ via an explicit rule

perl_$(EXE_EXT) perl_: $& miniperl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs aout_extlist
	$(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) `cat aout_extlist` $(AOUT_LIBPERL) `cat ext.libs` $(libs)

# Remove -Zcrtdll
STAT_AOUT_CLDFLAGS = -Zexe -Zmt -Zstack 32000

# Forking dynamically loaded perl with a wrong CRT library:

perl_stat_aout$(EXE_EXT) perl_stat_aout: $& libperl_dllmain$(AOUT_LIB_EXT)
	$(SHRPENV) $(CC) $(STAT_AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_stat_aout libperl_dllmain$(AOUT_LIB_EXT)

PERLREXX_DLL = perlrexx.dll

perl perl$(EXE_EXT) : perl__ perl___ $(PERLREXX_DLL) $(PERL_DLL)

# Dynamically loaded PM-application perl:

perl__$(EXE_EXT) perl__: $& libperl_dllmain$(LIB_EXT)
	$(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ libperl_dllmain$(LIB_EXT) -Zlinker /PM:PM

# Forking dynamically loaded perl:

perl$(EXE_EXT) perl: $& libperl_dllmain$(AOUT_LIB_EXT)
	$(CC) $(AOUT_CLDFLAGS_DLL) $(CCDLFLAGS) -o perl libperl_dllmain$(AOUT_LIB_EXT)

clean: aout_clean

aout_clean:
	-rm *perl_.* *.o *.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a ext/*/Makefile.aout ext/*/*/Makefile.aout  ext/*/*/*/Makefile.aout

aout_install: perl_ aout_install.perl

aout_install.perl: perl_ installperl
	./perl_ installperl --destdir="$(DESTDIR)"

perlrexx: $(PERLREXX_DLL)
	@sh -c true

perlrexx.c: os2/perlrexx.c
	@cp -f os2/$@ $@

# Remove -Zexe, add -Zdll -Zso.  No stack needed
SO_CLDFLAGS = -Zdll -Zso -Zomf -Zmt -Zsys

# A callable-from-REXX DLL

$(PERLREXX_DLL): perlrexx$(OBJ_EXT) perlrexx.def
	$(SHRPENV) $(CC) $(SO_CLDFLAGS) $(CCDLFLAGS) -o $@ perlrexx$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) perlrexx.def

perlrexx.def: miniperl $(_preplibrary)
	echo	"LIBRARY 'perlrexx' INITINSTANCE TERMINSTANCE"	> $@
	echo	"DESCRIPTION '@#perl5-porters@perl.org:`miniperl -Ilib -MConfig -e 'print \$$]'`#@ REXX to Perl `miniperl -Ilib -MConfig -e 'print \$$Config{version}'` interface'" >> $@
	echo	"EXPORTS"					>> $@
	echo	'  "PERL"'					>> $@
	echo	'  "PERLTERM"'					>> $@
	echo	'  "PERLINIT"'					>> $@
	echo	'  "PERLEXIT"'					>> $@
	echo	'  "PERLEVAL"'					>> $@
	echo	'  "PERLLASTERROR"'				>> $@
	echo	'  "PERLEVALSUBCOMMAND"'			>> $@
	echo	'  "PERLEXPORTALL"'				>> $@
	echo	'  "PERLDROPALL"'				>> $@
	echo	'  "PERLDROPALLEXIT"'				>> $@


perlrexx$(OBJ_EXT): perlrexx.c
	$(SO_CCCMD) $(PLDLFLAGS) -c perlrexx.c

# To test with harness, one needed to HARNESS_IGNORE_EXITCODE=2

# Define to be empty to get a TTY test
REDIR_TEST = 2>&1 | tee 00_$@

test_prep_perl_: test_prep_pre miniperl_ ./perl_$(EXE_EXT)
	PERL=./perl_ $(MAKE) _test_prep

test_prep_various: test_prep_pre miniperl $(dynamic_ext) $(TEST_PERL_DLL)

test_prep_perl_sys: test_prep_various ./perl_sys$(EXE_EXT)
	PERL=./perl_sys $(MAKE) _test_prep

test_prep_perl___: test_prep_various ./perl___$(EXE_EXT)
	PERL=./perl___ $(MAKE) _test_prep

test_prep_perl_stat: test_prep_various ./perl_stat$(EXE_EXT)
	PERL=./perl_stat $(MAKE) _test_prep

test_prep_perl_stat_aout: test_prep_various ./perl_stat_aout$(EXE_EXT)
	PERL=./perl_stat_aout $(MAKE) _test_prep

aout_test: test_prep_perl_
	PERL=./perl_ $(MAKE) _test

aout_harness: test_prep_perl_
	-PERL=./perl_ $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

sys_test: test_prep_perl_sys
	PERL=./perl_sys $(MAKE) _test

sys_harness: test_prep_perl_sys
	-PERL=./perl_sys $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

stat_test: test_prep_perl_stat
	PERL=./perl_stat $(MAKE) _test

stat_harness: test_prep_perl_stat
	-PERL=./perl_stat $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

stat_aout_test: test_prep_perl_stat_aout
	PERL=./perl_stat_aout $(MAKE) _test

stat_aout_harness: test_prep_perl_stat_aout
	-PERL=./perl_stat_aout $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

perl___test: test_prep_perl___
	PERL=./perl___ $(MAKE) _test

perl___harness: test_prep_perl___
	-PERL=./perl___ $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

all_test: test aout_test perl___test sys_test stat_test stat_aout_test

test_harness_redir: test_prep
	-PERL=./perl $(MAKE) TESTFILE=harness _test $(REDIR_TEST)

all_harness: test_harness_redir aout_harness perl___harness sys_harness stat_harness stat_aout_harness

!NO!SUBS!

# Now we need to find directories in ./ext/ which are up to 3 level deep
# Currently (2001/06) there is no directories 4 levels deep.
# (Only directories so that there is no Makefile.PL some levels up matter.)

dirs=''
ddirs=''
preci='ext/%/Makefile.aout '
for d in ext/*
do
	# echo "...Checking '$d'..."
	# skip the kid if the parent exists: cmp SDBFile/sdbm, done by MakeMaker
	if test ! -e "$d/Makefile.PL"; then
	    # Need to treat subdirectories manually
	    # echo "...Checking subdirs of '$d'..."
	    d_treated=''
	    for dd in $d/*
	    do
		if test ! -d $dd; then
		    continue
		fi
		if test -e "$dd/Makefile.PL"; then
		    if test "X$d_treated" = "X"; then
			d_treated=1
			# echo "...Found parentless 2-level deep Makefile.PL's in $d/*/:" $d/*/Makefile.PL
			dirs="$dirs $d"
			preci="$preci $d/%/Makefile.aout"
		    fi
		else
		    # Need to treat subsubdirectories manually
		    dd_treated=''
		    for ddd in $dd/*		# ext/*/*/*/Makefile.PL
		    do
			if test ! -d $ddd; then
			    continue
			fi
			if test -e "$ddd/Makefile.PL"; then
			    if test "X$dd_treated" = "X"; then
				dd_treated=1
				# echo "...Found parentless 3-level deep Makefile.PL's in $dd/*/:" $dd/*/Makefile.PL
				ddirs="$ddirs $dd"
				preci="$preci $dd/%/Makefile.aout"
			    fi
			fi
		    done
		fi
	   done
	fi
done

# ext/threads is marked as NORECURS, so we need to specialcase it
if echo "$static_ext $dynamic_ext" | grep -q threads/shared ; then
   preci="$preci ext/threads/%/Makefile.aout"
   dirs="$dirs ext/threads"
fi

$spitshell >>Makefile <<!GROK!THIS!
.PRECIOUS : $preci

# Set this to FORCE to force a rebuilt of aout extensions

AOUT_EXTENSIONS_FORCE = 

!GROK!THIS!

for d in $ddirs
do
    # Remove the leading component ext/
    dd=`dirname $d`
    pp=`basename $dd`
    p=$pp/`basename $d`
    $spitshell >>Makefile <<!GROK!THIS!
lib/auto/$p/*/%.a : $d/%/Makefile.aout
	@cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
	cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=

$d/%/Makefile.aout : miniperl_ \$(_preplibrary) \$(AOUT_EXTENSIONS_FORCE)
	cd \$(dir \$@) ; ../../../../miniperl_ -I ../../../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1

!GROK!THIS!

done

for d in $dirs
do
    p=`basename $d`
    $spitshell >>Makefile <<!GROK!THIS!
lib/auto/$p/*/%.a : $d/%/Makefile.aout
	@cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
	cd $d/\$(basename \$(notdir \$@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=

$d/%/Makefile.aout : miniperl_ \$(_preplibrary) \$(AOUT_EXTENSIONS_FORCE)
	cd \$(dir \$@) ; ../../../miniperl_ -I ../../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1

!GROK!THIS!

done

# We need to special-case OS2/DLL/DLL.a, since the recipe above will
# try to find it in ext/OS2-DLL

$spitshell >>Makefile <<'!NO!SUBS!'
lib/auto/OS2/DLL/DLL.a : lib/auto/OS2/REXX/REXX.a
	@sh -c true

lib/auto/*/%.a : ext/%/Makefile.aout
	@cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout config || echo "\$(MAKE) config failed, continuing anyway..."
	cd ext/$(basename $(notdir $@)) ; make -f Makefile.aout LINKTYPE=static CCCDLFLAGS=

ext/%/Makefile.aout : miniperl_ $(_preplibrary) $(AOUT_EXTENSIONS_FORCE)
	cd $(dir $@) ; ../../miniperl_ -I ../../lib Makefile.PL FIRST_MAKEFILE=Makefile.aout INSTALLDIRS=perl PERL_CORE=1

!NO!SUBS!