1 # Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Library General Public License
6 # as published by the Free Software Foundation; either version 2 of
7 # the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, USA.
23 # Some things below (but before including Rules) use configuration variables.
27 headers = mach_init.h mach.h mach-shortcuts.h \
29 routines = $(interface-routines) \
30 $(filter-out syscall_%,$(mach-syscalls)) \
31 $(addprefix __,$(mach-syscalls)) \
32 $(mach-shortcuts) $(addprefix __,$(mach-shortcuts)) \
33 mach_init vm_page_size \
34 mig_strncpy __msg msg \
35 mig_support mig_syms \
36 msg_destroy msg_server msg_server_t \
37 __msg_dest __msg_server \
39 user-interfaces := $(addprefix mach/,mach_interface mach_port mach_host \
41 memory_object_default \
43 $(addprefix device/,device device_request)
44 # device_reply is giving me headaches because of userprefix
45 server-interfaces := # mach/__exc mach/exc
47 distribute = Machrules syscalls.awk shortcut.awk
49 # Use and install the Mach header files directly out of the Mach kernel source.
52 # If we were configured with `--with-mach=DIR', then config.make sets
53 # mach-srcdir to DIR. Otherwise guess we are in a big source tree.
55 mach-srcdir = ../../mach
58 # When compiling, use the Mach header files directly from the kernel sources.
59 includes += -I$(mach-srcdir)
61 # Find the MiG defs files in the kernel source.
62 vpath %.defs $(mach-srcdir)
63 vpath mach/%.h $(mach-srcdir)
65 # Install all .h and .defs files we find in the kernel's mach/ and device/
66 # directories and their subdirectories (in MK82, max one level deep).
67 # XXX really want all from device?
68 mach-src-headers := $(wildcard $(foreach dir,mach device,\
69 $(addprefix $(mach-srcdir)/$(dir)/,\
72 # Exclude mach/machine/*. A symlink will be installed for mach/machine.
73 mach-headers = $(filter-out mach/machine/%,\
74 $(mach-src-headers:$(mach-srcdir)/%=%))
75 install-others += $(addprefix $(includedir),$(mach-headers))
76 $(includedir)/mach/%: $(mach-srcdir)/mach/%; $(do-install)
77 $(includedir)/device/%: $(mach-srcdir)/device/%; $(do-install)
79 # Make a symlink for mach/machine in the installed include directory.
80 install-others += $(includedir)/mach/machine
81 $(includedir)/mach/machine: $(common-objpfx)config.make
82 # XXX Ask mib about what best to do for this.
83 cd $(@D); ln -s $(config-machine) $(@F)
85 # Define mach-syscalls and sysno-*.
87 include $(objpfx)mach-syscalls.mk
89 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
91 sed -n -e '/Unix server implement them/,$$d' \
92 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \
93 < $< | awk -f $(word 2,$^) > $@-new
95 generated += mach-syscalls.mk
98 # We cannot make the deps properly until we know how to make the system
99 # call functions, and for that we must know what they all are.
102 $(mach-syscalls:%=$(objpfx)__%.S): $(objpfx)__%.S: $(objpfx)mach-syscalls.mk
103 (echo '#include <sysdep.h>'; \
104 echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@-new
106 $(mach-syscalls:%=$(objpfx)%.c): $(objpfx)%.c:
107 (echo '#include <gnu-stabs.h>'; \
108 echo 'symbol_alias (__$*, $*)') > $@-new
110 generated += $(mach-syscalls:%=__%.S) \
111 $(mach-syscalls:%=%.c)
112 endif # mach-syscalls
114 mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))
116 ifndef mach-shortcuts
117 # Forget about mach_interface.defs for this run. On the next run,
118 # $(mach-shortcuts) will be set, and that will change how
119 # mach_interface.defs is processed: it will get the -D flags below.
120 user-interfaces := $(filter-out mach/mach_interface \
121 mach/mach_port mach/mach_host,\
125 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
126 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
127 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
130 $(mach-shortcuts:%=$(objpfx)__%.c): $(objpfx)__%.c: shortcut.awk \
132 gawk -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
136 # The shortcut calls have had their names changed to CALL_rpc, so
137 # CALL_rpc.c is being generated with a symbol alias to __CALL_rpc.
138 # We also want CALL.c with an alias to __CALL.
139 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c:
140 (echo '#include <gnu-stabs.h>'; \
141 echo 'symbol_alias (__$*, $*)') > $@-new
143 generated += $(mach-shortcuts:%=%.c)
144 endif # mach-shortcuts
146 # Generate mach-shortcuts.h, which will contain the prototypes for the
147 # shortcutted kernel RPC functions.
148 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
149 $(objpfx)mach/mach_port.h
150 # The first line gets us one paragraph per line, with @s separating real lines.
151 # The second line selects paragraphs for the shortcutted functions.
152 # The third line removes `_rpc' from the names and rerealifies the lines.
153 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
154 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
155 | sed 's/_rpc//g' | tr @ \\012 > $@-new
157 generated += mach-shortcuts.h
159 before-compile += $(objpfx)mach-shortcuts.h
165 # There is already a mach.h, so mach.defs generates mach_interface.h.
166 $(objpfx)mach/mach_interface.uh: mach/mach.defs; $(mig.uh)
167 $(objpfx)mach/mach_interface.__h: mach/mach.defs; $(mig.__h)
168 # There is already a memory_object.h,
169 # so memory_object.defs generates memory_object_user.h.
170 $(objpfx)mach/memory_object_user.uh: mach/memory_object.defs; $(mig.uh)
171 $(objpfx)mach/memory_object_user.__h: mach/memory_object.defs; $(mig.__h)
173 # Be sure not to make these with implicit rules from foo.defs.
174 mach.h mach/memory_object.h: ;