summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 21abf57645a0661ac98bc9be88906db7a55a4342 (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
# Makefile for Mach 4 kernel directory
# Copyright 1997, 1999 Free Software Foundation, Inc.
#
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
#
# THE FREE SOFTWARE FOUNDATION ALLOWS FREE USE OF THIS SOFTWARE IN ITS
# "AS IS" CONDITION.  THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
# LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
# USE OF THIS SOFTWARE.




# Variables from `configure'.
srcdir=@srcdir@
systype=@systype@
prefix=@prefix@

exec_prefix=$(prefix)

bootdir=$(exec_prefix)/boot
includedir=$(prefix)/include
libexecdir=$(exec_prefix)/libexec
bindir=$(exec_prefix)/bin

sysdep = $(srcdir)/$(systype)

# Detect if the user wants KDB
ifeq ($(findstring -DMACH_KDB,@DEFS@),-DMACH_KDB)
enable_kdb=yes
else
enable_kdb=no
endif

# Detect if the user wants KMSG
ifeq ($(findstring -DMACH_KMSG,@DEFS@),-DMACH_KMSG)
enable_kmsg=yes
else
enable_kmsg=no
endif

# Programs found by configure.
AWK = @AWK@
INSTALL = @INSTALL@
CC = @CC@
LD = @LD@
NM = @NM@
MIG = @MIG@

INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

CFLAGS = @CFLAGS@

all:

# All the possible architectures
all-archs = i386 linux

all-archs-subdirs = $(patsubst %,$(srcdir)/%/Subdirs,$(all-archs))
all-archs-files = $(patsubst %,$(srcdir)/%/Files,$(all-archs))
all-archs-configures = $(patsubst %,$(srcdir)/%/configure,$(all-archs))

# Files distributed from the top level directory:
topfiles = ChangeLog ChangeLog.0 ChangeLog.00 Drivers.macros Makefile.in \
	README INSTALL config.guess config.sub configure configure.in \
	gensym.awk install-sh version.c NEWS aclocal.m4 COPYING

# All the source in each directory.

# Old crud from a previous configure scheme
bogus-files = bootstrap_symbols.h fast_tas.h hw_footprint.h net_atm.h \
	power_save.h simple_clock.h stat_time.h xpr_debug.h \
	$(patsubst %,mach_%.h,assert counters debug fixpri host ipc_compat \
	ipc_debug ipc_test kdb ldebug lock_mon machine_routines mp_debug \
	pagemap pcsample ttd vm_debug) \
	$(patsubst %,norma_%.h,device ether ipc task vm)

# Generic code for various hardware drivers
chips-files = atm.c audio.c bt431.c bt455.c bt459.c build_font.c busses.c \
	cfb_hdw.c cfb_misc.c dc503.c dtop_handlers.c dtop_hdw.c dz_hdw.c \
	fb_hdw.c fb_misc.c fdc_82077_hdw.c frc.c ims332.c isdn_79c30_hdw.c \
	kernel_font.c lance.c lance_mapped.c lk201.c mc_clock.c mouse.c \
	nc.c nw_mk.c pm_hdw.c pm_misc.c scc_8530_hdw.c screen.c \
	screen_switch.c serial_console.c sfb_hdw.c sfb_misc.c spans.c \
	tca100.c tca100_if.c xcfb_hdw.c xcfb_misc.c \
	atmreg.h audio_config.h audio_defs.h bt431.h bt455.h bt459.h \
	bt478.h busses.h dc503.h dtop.h dz_7085.h dz_defs.h eccreg.h \
	fdc_82077.h ims332.h isdn_79c30.h lance.h lk201.h mc_clock.h \
	nc.h nw.h nw_mk.h pm_defs.h scc_8530.h screen.h screen_defs.h \
	screen_switch.h serial_defs.h spans.h tca100.h tca100_if.h \
	vs42x_rb.h xcfb_monitor.h

# Generic code for various SCSI unit types
scsi-files = disk_label.c mapped_scsi.c pc_scsi_label.c rz.c rz_audio.c \
	rz_cpu.c rz_disk.c rz_disk_bbr.c rz_host.c rz_tape.c scsi.c \
	scsi_alldevs.c scsi_comm.c scsi_cpu.c scsi_disk.c scsi_jukebox.c \
	scsi_optical.c scsi_printer.c scsi_rom.c scsi_scanner.c \
	scsi_tape.c scsi_worm.c \
	compat_30.h mapped_scsi.h rz.h rz_labels.h scsi.h scsi2.h \
	scsi_defs.h scsi_endian.h

# Icky kernel debugger
ddb-cfiles = $(addprefix db_,$(ddb-names))
ddb-names = access.c aout.c break.c command.c cond.c examine.c expr.c \
	ext_symtab.c input.c lex.c macro.c mp.c output.c print.c run.c \
	sym.c task_thread.c trap.c variables.c watch.c write_cmd.c
ddb-files = $(ddb-cfiles) $(patsubst %,db_%.h, \
	access break command expr lex output print run sym task_thread \
	variables watch) nlist.h stab.h tr.h

# Device support interfaces
device-files = blkio.c chario.c cirbuf.c cons.c dev_lookup.c dev_name.c \
	dev_pager.c device_init.c dk_label.c ds_routines.c net_io.c subrs.c \
	buf.h cirbuf.h conf.h cons.h dev_hdr.h dev_master.h device_port.h \
	device_types_kernel.h ds_routines.h errno.h if_ether.h if_hdr.h \
	io_req.h kmsg.c kmsg.h net_io.h param.h tty.h memory_object_reply.cli \
	dev_forward.defs device_pager.srv device_reply.cli device.srv

# IPC implementation
ipc-cfiles = $(addprefix ipc_,$(ipc-names)) \
		mach_msg.c mach_port.c mach_rpc.c mach_debug.c fipc.c
ipc-names = entry.c hash.c init.c kmsg.c marequest.c mqueue.c \
	notify.c object.c port.c pset.c right.c space.c splay.c \
	table.c target.c thread.c
ipc-files = $(ipc-cfiles) mach_port.srv fipc.h port.h mach_msg.h \
	$(patsubst %,ipc_%.h, \
	entry hash init kmsg kmsg_queue machdep marequest mqueue notify \
	object port pset right space splay table target thread types)

# "kernel" implementation (tasks, threads, trivia, etc.)
kern-cfiles = act.c ast.c bootstrap.c counters.c debug.c eventcount.c \
	exception.c host.c ipc_host.c ipc_kobject.c ipc_mig.c ipc_sched.c \
	ipc_tt.c kalloc.c lock.c lock_mon.c mach_clock.c mach_factor.c \
	machine.c pc_sample.c printf.c priority.c processor.c profile.c \
	queue.c sched_prim.c startup.c strings.c syscall_emulation.c \
	syscall_subr.c syscall_sw.c task.c thread.c thread_swap.c \
	time_stamp.c timer.c xpr.c zalloc.c elf-load.c
kern-files = $(kern-cfiles) \
	act.h assert.h ast.h compat_xxx_defs.h counters.h cpu_number.h \
	debug.h eventcount.h host.h ipc_host.h ipc_kobject.h ipc_sched.h \
	ipc_tt.h kalloc.h kern_types.h lock.h mach_param.h macro_help.h \
	pc_sample.h processor.h queue.h refcount.h sched.h sched_prim.h \
	shuttle.h strings.h syscall_emulation.h syscall_subr.h syscall_sw.h \
	task.h thread.h thread_swap.h time_out.h time_stamp.h timer.h xpr.h \
	zalloc.h \
	mach.srv mach4.srv mach_debug.srv mach_host.srv

# Still more trivia
util-cfiles = about_to_die.c cpu.c cpu_init.c die.c putchar.c puts.c
util-files = $(util-cfiles) config.h cpu.h cpu_subs.h cpus.h debug.h \
	phys_mem.h ref_count.h

# Virtual memory implementation
vm-cfiles = $(addprefix vm_,$(vm-names)) memory_object.c
vm-names = debug.c external.c fault.c init.c kern.c map.c \
	object.c pageout.c resident.c user.c
vm-files = $(vm-cfiles) memory_object_default.cli memory_object_user.cli \
	memory_object.h pmap.h $(patsubst %,vm_%.h, \
	external fault kern map object page pageout user)



# Object files that go into the kernel image.  (This will be augmented by the
# machine dependent Makefile fragment.)

# Basic kernel source for Mach
objfiles := $(subst .c,.o,$(ipc-cfiles) $(kern-cfiles) \
			  $(util-cfiles) $(vm-cfiles))
vpath %.c $(srcdir)/ipc $(srcdir)/kern $(srcdir)/util $(srcdir)/vm

# These device support files are always needed; the others are needed only
# if particular drivers want the routines.
# XXX functions in device/subrs.c should each be moved elsewhere
objfiles += cons.o dev_lookup.o dev_name.o dev_pager.o device_init.o \
	ds_routines.o subrs.o net_io.o blkio.o chario.o
ifeq ($(enable_kmsg),yes)
objfiles += kmsg.o
endif
vpath %.c $(srcdir)/device

# DDB support -- eventually to die.  Please.
objfiles += $(subst .c,.o,$(ddb-cfiles))
vpath %.c $(srcdir)/ddb

# Version number
objfiles += version.o
vpath version.c $(srcdir)


# Header files installed for user use
device-headers= $(addprefix device/,audio_status.h bpf.h device.defs \
		device_reply.defs device_request.defs device_types.defs \
		device_types.h disk_status.h net_status.h tape_status.h \
		tty_status.h)
mach-headers= $(addprefix mach/, bootstrap.defs default_pager.defs \
		default_pager_helper.defs default_pager_types.defs \
		exc.defs mach.defs mach4.defs mach_host.defs mach_norma.defs \
		mach_port.defs mach_types.defs memory_object.defs \
		memory_object_default.defs norma_task.defs notify.defs \
		std_types.defs \
		alert.h boolean.h boot.h default_pager_types.h exception.h \
		host_info.h kern_return.h mach_param.h mach_types.h \
		machine.h macro_help.h memory_object.h message.h mig_errors.h \
		msg_type.h multiboot.h norma_special_ports.h notify.h \
		pc_sample.h policy.h port.h processor_info.h \
		profil.h profilparam.h rpc.h std_types.h syscall_sw.h \
		task_info.h task_special_ports.h thread_info.h \
		thread_special_ports.h thread_status.h thread_switch.h \
		time_value.h version.h vm_attributes.h vm_inherit.h \
		vm_param.h vm_prot.h vm_statistics.h inline.h)
mach-exec-headers= $(addprefix mach/exec/, a.out.h elf.h exec.h)
mach-debug-headers:= $(addprefix mach_debug/, hash_info.h ipc_info.h \
		mach_debug.defs mach_debug_types.defs mach_debug_types.h \
		pc_info.h vm_info.h zone_info.h)

installed-headers:= $(device-headers) $(mach-headers) $(mach-exec-headers)

# Other headers for the distribution.  We don't install these, because the
# GNU C library has correct versions for users to use.
other-sys-headers := types.h time.h reboot.h ioctl.h
other-mach-headers := mig_support.h mach_traps.h error.h
other-headers := alloca.h


# Automatically generated source

# User stubs
objfiles += memory_object_user_user.o memory_object_default_user.o \
	device_reply_user.o memory_object_reply_user.o

# Server stubs
objfiles += device_server.o device_pager_server.o mach_port_server.o \
	mach_server.o mach4_server.o mach_debug_server.o mach_host_server.o

# Where to find the relevant Mig source files
vpath %.cli $(srcdir)/vm $(srcdir)/device
vpath %.srv $(srcdir)/device $(srcdir)/ipc $(srcdir)/kern


# We need this symlink in place before we start compiling,
# so <mach/machine/foo.h> headers can be found.
before-compile = mach/machine
mach/machine: mach_machine
	test -d $(@D) || mkdir $(@D)
	rm -f $@
	ln -s ../mach_machine mach/machine
mach_machine:
	rm -f $@
	ln -s $(srcdir)/$(systype)/include/mach/$(systype) mach_machine



#
# Compilation flags
#

DEFINES += -DMACH -DCMU -DMACH_KERNEL -DKERNEL @DEFS@
INCLUDES += -I. -I$(srcdir) -I$(srcdir)/include \
	-I$(srcdir)/bogus -I$(srcdir)/util -I$(srcdir)/kern -I$(srcdir)/device


include $(sysdep)/Makefrag

CPPFLAGS += -nostdinc $(DEFINES) $(INCLUDES)

MIGFLAGS += $(CPPFLAGS)


# Standard targets

all: kernel

clean:
	rm -f *.o *.d kernel
	rm -f *.symc *.symc.o *_user.c *_server.c *.h
	rm -f *.migs_d *.migsh_d *.migu_d *.miguh_d

distclean: clean
	rm -f config.status config.cache config.log Makefile driverlist

mostlyclean: distclean

maintainer-clean: mostlyclean
	rm -f $(srcdir)/configure $(all-archs-configures)

check:


#
# Kernel Image
#

# This is the list of routines we decide is OK to steal from the C library.
clib-routines := memcpy memmove memset bcopy bzero \
		 strchr strstr \
		 htonl htons ntohl ntohs \
		 etext edata end # actually ld magic, not libc

#kernel.a: $(objfiles)
#	@rm -f $@
#	$(AR) cq $@ $^
kernel.o: $(objfiles) # kernel.a
	$(LD) -r -o $@ $^
kernel-undef: kernel.o
	$(NM) -u $< | sed 's/^_*//' | sort -u > $@
kernel-undef-bad: kernel-undef Makefile
	sed '$(foreach r,$(clib-routines),/^$r$$/d;)' $< > $@
clib-routines.o: kernel-undef kernel-undef-bad
	if test -s kernel-undef-bad; \
	then cat kernel-undef-bad; exit 2; else true; fi
	$(CC) -nostdlib -nostartfiles -r -static \
	      -o $@ \
	      `sed 's/^/-Wl,-u,/' $<` -x c /dev/null -lc
kernel: kernel.o clib-routines.o
	$(LD) $(LDFLAGS) -o $@ $^



#
# Installation
#
installed-headers-names = $(addprefix $(includedir)/,$(installed-headers))
installed-sysdep-headers-names = $(addprefix $(includedir)/,$($(systype)-installed-headers))
install: install-headers install-kernel

$(installed-headers-names): $(includedir)/%: $(srcdir)/include/%
	$(INSTALL_DATA) $< $@

$(installed-sysdep-headers-names): $(includedir)/%: $(sysdep)/include/%
	$(INSTALL_DATA) $< $@

install-headers: mkheaderdirs $(installed-headers-names) $(installed-sysdep-headers-names)
	ln -sf $(systype) $(includedir)/mach/machine

install-kernel: kernel mkkerneldirs
	$(INSTALL_PROGRAM) kernel $(bootdir)/gnumach

mkheaderdirs:
	mkdir -p $(includedir) $(includedir)/device $(includedir)/mach \
		$(includedir)/mach/$(systype) $(includedir)/mach/exec

mkkerneldirs:
	mkdir -p $(bootdir)


#
# Building the distribution
#

dist:
	rm -rf gnumach-$(version)
	mkdir gnumach-$(version)
	# Directories
	mkdir gnumach-$(version)/{bogus,chips,ddb,device,ipc,kern,scsi,util,vm,include}
	mkdir gnumach-$(version)/include/{mach,device,mach_debug,sys}
	mkdir gnumach-$(version)/include/mach/exec
	for dir in `cat $(all-archs-subdirs)`; do \
		mkdir -p gnumach-$(version)/$$dir; \
	done
	# Files
	cp $(addprefix $(srcdir)/,$(topfiles)) gnumach-$(version)
	cp $(addprefix $(srcdir)/bogus/,$(bogus-files)) gnumach-$(version)/bogus
	cp $(addprefix $(srcdir)/chips/,$(chips-files)) gnumach-$(version)/chips
	cp $(addprefix $(srcdir)/ddb/,$(ddb-files)) gnumach-$(version)/ddb
	cp $(addprefix $(srcdir)/device/,$(device-files)) gnumach-$(version)/device
	cp $(addprefix $(srcdir)/ipc/,$(ipc-files)) gnumach-$(version)/ipc
	cp $(addprefix $(srcdir)/kern/,$(kern-files)) gnumach-$(version)/kern
	cp $(addprefix $(srcdir)/scsi/,$(scsi-files)) gnumach-$(version)/scsi
	cp $(addprefix $(srcdir)/util/,$(util-files)) gnumach-$(version)/util
	cp $(addprefix $(srcdir)/vm/,$(vm-files)) gnumach-$(version)/vm
	cp $(addprefix $(srcdir)/include/,$(mach-headers)) gnumach-$(version)/include/mach
	cp $(addprefix $(srcdir)/include/,$(device-headers)) gnumach-$(version)/include/device
	cp $(addprefix $(srcdir)/include/,$(mach-debug-headers)) gnumach-$(version)/include/mach_debug
	cp $(addprefix $(srcdir)/include/,$(mach-exec-headers)) gnumach-$(version)/include/mach/exec
	cp $(addprefix $(srcdir)/include/,$(other-headers)) gnumach-$(version)/include
	cp $(addprefix $(srcdir)/include/sys/,$(other-sys-headers)) gnumach-$(version)/include/sys
	cp $(addprefix $(srcdir)/include/mach/,$(other-mach-headers)) gnumach-$(version)/include/mach
	# Files in arch dirs
	for file in `cat $(all-archs-files)`; do \
		cp $(srcdir)/$$file gnumach-$(version)/`dirname $$file`; \
	done
	chmod -R u=rwX,og=rX gnumach-$(version)
	tar cfz gnumach-$(version).tar.gz gnumach-$(version)
	rm -rf gnumach-$(version)



#
# Autoconf support
#
$(srcdir)/configure: $(srcdir)/configure.in
	cd $(srcdir) && autoconf
$(srcdir)/config.h.in: $(srcdir)/acconfig.h
	cd $(srcdir) && autoheader

Makefile: $(srcdir)/Makefile.in config.status
	./config.status
config.h: stamp-configh ;
stamp-configh: $(srcdir)/config.h.in config.status
	./config.status
	touch $@

config.status: $(srcdir)/configure
	./config.status --recheck

vpath %.in $(srcdir)
vpath configure $(srcdir)



#
# How to do some things
#

# Building foo.h from foo.sym:
%.symc: %.sym
	$(AWK) -f $(srcdir)/gensym.awk $< >$*.symc
%.symc.o: %.symc
	$(CC) -S $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS-$@) -x c -o $@ $<
%.h: %.symc.o
	sed <$< -e 's/^[^*].*$$//' | \
		sed -e 's/^[*]/#define/' -e 's/mAgIc[^-0-9]*//' >$@

# Building from foo.cli
%.h %_user.c: %.cli
	$(MIG) $(MIGFLAGS) -header $*.h -user $*_user.c -server /dev/null $<

# Building from foo.srv
%_interface.h %_server.c: %.srv
	$(MIG) $(MIGFLAGS) -header $*_interface.h -server $*_server.c -user /dev/null $<

#
# Dependency generation
#

# Include dependency files
ifneq ($(no_deps),t)

# For each file generated by MiG we need a .d file.
servers = $(filter %_server.o,$(objfiles))
-include $(subst _server.o,.migs_d,$(servers)) /dev/null
-include $(subst _server.o,.migsh_d,$(servers)) /dev/null

# vm_user.o fits the pattern, but is not actually a MiG-related file.
users = $(filter-out vm_user.o,$(filter %_user.o,$(objfiles)))
-include $(subst _user.o,.migu_d,$(users)) /dev/null
-include $(subst _user.o,.miguh_d,$(users)) /dev/null

# For each .o file we need a .d file.
-include $(subst .o,.d,$(filter %.o,$(objfiles))) /dev/null

endif

# Here is how to make those dependency files

%.migs_d: %.srv
	(set -e; $(CPP) $(MIGFLAGS) -M -MG -x c $< | \
	sed -e 's/\.srv\.o:/_server.c $@:/' > $@)

%.migu_d: %.cli
	(set -e; $(CPP) $(MIGFLAGS) -M -MG -x c $< | \
	sed -e 's/\.cli\.o:/_user.c $@:/' > $@)

%.migsh_d: %.migs_d
	sed -e 's/_server\.c /_interface.h /' -e 's/migs_d/migsh_d/' < $< > $@

%.miguh_d: %.migu_d
	sed -e 's/_user\.c /.h /' -e 's/migu_d/miguh_d/' < $< > $@

# Generic rule for $(CC) based compilation for making dependencies
define make-deps
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \
	sed > $@.new -e 's/$*\.o:/$*.o $@:/'
mv -f $@.new $@
endef

%.d: %.c $(before-compile); $(make-deps)
%.d: %.S $(before-compile); $(make-deps)

# .s files don't go through the preprocessor, so we do this
# This rule must come *after* the genuine ones above, so that
# make doesn't build a .s file and then make an empty dependency
# list.
%.d: %.s
	echo '$*.o: $<' > $@