summaryrefslogtreecommitdiff
path: root/makefile.in
blob: 423b15447e3f4e8f27c1da9e727ecf951806edb9 (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
#ifdef COMMENT
##############################################################################
#
# This Makefile has been completely re-vamped. Two reasons, first to allow
# for a full compile before installation, hence allowing us to make a binary
# distribution without installing and second to allow proper dependancy trees
# for the different versions of the library.
#
# As an aside, it would be useful if I could avoid GNU-make constucts.
#
##############################################################################
#endif

# Defaults, generic C
ARFLAGS =r
CFLAGS	=-O
LDFLAGS	=-s
MAKEARG	=CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' PREFIX=$(PREFIX) \
         LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)'
MAKEC=$(MAKE) -C
MAKEX=

#ifdef __GNUC__
# unproto is yukky, I've included '-w' in the local makefile.

WALL  =-Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \
       -Wcast-qual -Wcast-align -Wconversion -Waggregate-return \
       -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls \
       -Wnested-externs -Winline 

WALL  =-Wstrict-prototypes

CC	=gcc $(GCCFLAG)
#ifdef __i386__
CFLAGS	=-Wall $(WALL) -O2 -m486 -fno-strength-reduce
#else
CFLAGS	=-Wall $(WALL) -O2 -fno-strength-reduce
#endf
LDFLAGS	=-s
#endif

#ifndef GNUMAKE
MAKEC=sh makec
MAKEX=makec
#endif

#ifdef __minix
# Minix make doesn't understand -C, cc runs out of memory with the headers.
MAKEC=ash makec
MAKEX=makec
CFLAGS=-O -m -w -DPOSIX_HEADERS_MISSING -DVERY_SMALL_MEMORY
#endif

#ifdef __BCC__
CC	=bcc
#ifdef __AS386_32__
CFLAGS	=-3
LDFLAGS	=-3 -s -N
#else
CFLAGS	=-0
LDFLAGS	=-0 -s -H10000
#endif
#endif

# Alter these if for some reason you don't want this done as root.
INDAT=-o root -g root -m 644
INEXE=-o root -g root -m 755

all: check_config bcc unproto copt as86 ld86 library alt-libs elksemu 

install: check_config install-bcc install-man install-lib install-lib2 install-emu

install-all: install install-other

##############################################################################

LIBARGS= CC=ncc CCFLAGS= ARFLAGS=$(ARFLAGS)

# Season to taste
PREFIX=	 /usr/bcc
BINDIR=	 /usr/bin
LIBDIR=  $(PREFIX)/lib/bcc

DISTBIN= $(DIST)$(BINDIR)
DISTLIB= $(DIST)$(LIBDIR)
DISTPRE= $(DIST)$(PREFIX)

# Others to install
OTHERS=  tests dis88 doselks bootblocks

CLEANLIST= bcc as ld unproto copt libc elksemu libbsd $(OTHERS)

##############################################################################

bindir: $(MAKEX)
	@mkdir -p bin lib lib/i386
	@rm -f include
	@ln -s libc/include include 2>/dev/null || true

phony:

bcc: bindir
	$(MAKEC) bcc $(MAKEARG) bcc ncc bcc-cc1
	cp -p bcc/bcc bin/bcc
	cp -p bcc/ncc bin/ncc
	cp -p bcc/bcc-cc1 lib/bcc-cc1

unproto:  bindir
	$(MAKEC) unproto $(MAKEARG) unproto
	cp -p unproto/unproto lib/unproto

copt:  bindir
	$(MAKEC) copt $(MAKEARG) copt
	cp -p copt/copt lib/copt
	cp -p copt/rules.* lib/.

as86: bindir
	$(MAKEC) as $(MAKEARG) all
	cp -p as/as86 bin/as86
	cp -p as/as86_encap bin/as86_encap

ld86: bindir
	$(MAKEC) ld $(MAKEARG) ld86
	cp -p ld/ld86 bin/ld86

elksemu: bindir
	$(MAKEC) elksemu $(MAKEARG) elksemu
	cp -p elksemu/elksemu bin/elksemu

install-bcc: bcc unproto copt as86 ld86
	install -d $(DISTBIN) $(DISTLIB) $(DISTLIB)/i86
	install $(INEXE) bin/bcc 	$(DISTBIN)/bcc
	install $(INEXE) bin/as86_encap	$(DISTBIN)/as86_encap
	install $(INEXE) bin/as86 	$(DISTBIN)/as86
	install $(INEXE) bin/ld86 	$(DISTBIN)/ld86
	install $(INEXE) lib/bcc-cc1 	$(DISTLIB)/bcc-cc1
	install $(INEXE) lib/unproto 	$(DISTLIB)/unproto
	install $(INEXE) lib/copt 	$(DISTLIB)/copt
	install $(INDAT) lib/rules.* 	$(DISTLIB)/i86
	@test ! -f $(DISTLIB)/as86 || rm -f $(DISTLIB)/as86
	@test ! -f $(DISTLIB)/ld86 || rm -f $(DISTLIB)/ld86

install-emu: elksemu
	install -d $(DIST)/lib
	install $(INEXE) bin/elksemu 	$(DIST)/lib/elksemu

install-man:
	-$(MAKEC) man MANDIR=$(DIST)/usr/man install

install-lib: lib/lib0-done
	install -d $(DISTLIB)/i86
	$(MAKEC) libc $(LIBARGS) BCCHOME=$(DISTPRE) install_incl
	install $(INDAT) lib/crt0.o 	$(DISTLIB)/i86/crt0.o
	install $(INDAT) lib/libc.a 	$(DISTLIB)/i86/libc.a
	install -d $(DIST)/usr/lib
	install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt

install-lib2: lib/lib1-done
	install -d $(DISTLIB)/i86
	install $(INDAT) lib/libbsd.a	$(DISTLIB)/i86/libbsd.a
	install $(INDAT) lib/libc_f.a	$(DISTLIB)/i86/libc_f.a
	install $(INDAT) lib/libc_s.a	$(DISTLIB)/i86/libc_s.a
	install $(INDAT) lib/libdos.a	$(DISTLIB)/i86/libdos.a

	install -d $(DISTLIB)/i386
	install $(INDAT) lib/i386/crt0.o 	$(DISTLIB)/i386/crt0.o
	install $(INDAT) lib/i386/libc.a 	$(DISTLIB)/i386/libc.a

lib/lib0-done:
	$(MAKE) -f make.fil library

lib/lib1-done:
	$(MAKE) -f make.fil alt-libs

library: bindir
	$(MAKEC) libc $(LIBARGS) PLATFORM=i86-ELKS
	cp -p libc/crt0.o libc/libc.a lib/.
	@touch lib/lib0-done

alt-libs: lib-bsd lib-fast lib-stand lib-dos lib-386 
	@touch lib/lib1-done

lib-bsd: bindir
	$(MAKEC) libbsd $(LIBARGS)
	cp -p libbsd/libbsd.a lib/libbsd.a

lib-fast: bindir
	$(MAKEC) libc $(LIBARGS) PLATFORM=i86-FAST
	cp -p libc/libc_f.a lib/libc_f.a

lib-stand: bindir
	$(MAKEC) libc $(LIBARGS) PLATFORM=i86-BIOS
	cp -p libc/libc_s.a lib/libc_s.a

lib-dos: bindir
	$(MAKEC) libc $(LIBARGS) PLATFORM=i86-DOS
	cp -p libc/libdos.a lib/libdos.a

lib-386: bindir
	$(MAKEC) libc $(LIBARGS) PLATFORM=i386-BCC
	cp -p libc/crt3.o lib/i386/crt0.o
	cp -p libc/libc3.a lib/i386/libc.a

##############################################################################

#ifdef GNUMAKE

check_config: $(MAKEX)
	$(MAKEC) libc .config.dir

config: $(MAKEX)
	$(MAKEC) libc config

#else
check_config: $(MAKEX) ;

config: ;
#endif

makec:
	echo 'cd $$1 ; shift ; make "$$@"' > makec
	chmod +x makec

##############################################################################

install-other: phony
	@for i in $(OTHERS) ; do \
		$(MAKEC) $$i BCC=ncc DIST=$(DIST) install || exit 1 ; \
	done

other: phony
	@for i in $(OTHERS) ; do \
		$(MAKEC) $$i BCC=ncc || exit 1 ; done

tests: phony
	$(MAKEC) tests BCC=ncc

clean:
	-@for i in $(CLEANLIST) ; do $(MAKEC) $$i $@ ; true ; done

realclean:
	-@for i in $(CLEANLIST) ; do $(MAKEC) $$i $@ ; true ; done
	rm -rf bin lib
	rm -f include
	rm -f makec

##############################################################################