summaryrefslogtreecommitdiff
path: root/os2/Makefile.SHs
blob: 83227bb38ba4354b12fdd814835cef9f2dc4b78b (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
# This file is read by Makefile.SH to produce rules for $(perllib) (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).

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

AOUT_CCCMD	= \$(CC) $aout_ccflags $optimize
AOUT_AR		= $aout_ar
AOUT_OBJ_EXT	= $aout_obj_ext
AOUT_LIB_EXT	= $aout_lib_ext
aout_perllib	= libperl$aout_lib_ext
AOUT_CLDFLAGS	= $aout_ldflags

!GROK!THIS!

$spitshell >>Makefile <<'!NO!SUBS!'
$(perllib): perl.imp perl.dll perl5.def
	emximp -o $(perllib) perl.imp

perl.imp: perl5.def
	emximp -o perl.imp perl5.def

perl.dll: $(obj) perl5.def perl$(OBJ_EXT)
	$(LD) $(LDDLFLAGS) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def

perl5.def: perl.linkexp
	echo "LIBRARY 'Perl' INITINSTANCE TERMINSTANCE"	> $@
	echo DESCRIPTION "'Perl interpreter, export autogenerated'"	>>$@
	echo STACKSIZE 32768				>>$@
	echo CODE LOADONCALL				>>$@
	echo DATA LOADONCALL NONSHARED MULTIPLE		>>$@
	echo EXPORTS					>>$@
	echo '  "ctermid"'				>>$@
	echo '  "get_sysinfo"'				>>$@
	echo '  "Perl_OS2_init"'			>>$@
	echo '  "OS2_Perl_data"'			>>$@
	echo '  "dlopen"'				>>$@
	echo '  "dlsym"'				>>$@
	echo '  "dlerror"'				>>$@
!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	>>$@


# We assume here that perl is available somewhere ...

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

#		perl -ne 'print if (/^#!/ .. /^#\s/) && s/^(\w+) *$$/$$1/' > $@

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

perl.map: $(obj) perl$(OBJ_EXT) miniperlmain$(OBJ_EXT)
	$(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o dummy.exe miniperlmain$(OBJ_EXT) perl$(OBJ_EXT) $(obj) $(libs) -Zmap -Zlinker /map
	awk '{if ($$3 == "") print $$2}' <dummy.map | sort | uniq > perl.map
	rm dummy.exe dummy.map

depend: os2ish.h dlfcn.h 

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

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

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

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

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


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

# Aout section:

aout_obj = $(addsuffix $(AOUT_OBJ_EXT),$(basename $(obj)))
AOUT_DYNALOADER = $(addsuffix $(AOUT_LIB_EXT),$(basename $(DYNALOADER)))
aout_static_ext = $(addsuffix $(AOUT_LIB_EXT),$(basename $(dynamic_ext)))
aout_static_lib = $(addsuffix $(LIB_EXT),$(basename $(dynamic_ext)))

$(aout_perllib) : $(aout_obj) perl$(AOUT_OBJ_EXT)
	rm -f $(perllib)
	$(AOUT_AR) rcu $(aout_perllib) perl$(AOUT_OBJ_EXT) $(aout_obj)

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

aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
	sh writemain $(DYNALOADER) $(aout_static_lib) > tmp
	sh mv-if-diff tmp aout_perlmain.c

miniperl_: $& miniperlmain$(AOUT_OBJ_EXT) $(aout_perllib) ext.libs
	$(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o miniperl_ miniperlmain$(AOUT_OBJ_EXT) $(aout_perllib) `cat ext.libs` $(libs)

perl_: $& aout_perlmain$(AOUT_OBJ_EXT) $(aout_perllib) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs
	$(CC) $(LARGE) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER) $(aout_static_ext) $(aout_perllib) `cat ext.libs` $(libs)

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

aout_install: perl_ aout_install.perl

aout_install.perl: perl_ installperl
	./perl_ installperl

aout_test: perl_
	- cd t && (rm -f perl_$(EXE_EXT); $(LNS) ../perl_$(EXE_EXT) perl_$(EXE_EXT)) && ./perl_ TEST </dev/tty

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_
	cd $(dir $@) ; ../../miniperl_ Makefile.PL MAKEFILE=Makefile.aout INSTALLDIRS=perl 

!NO!SUBS!