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 \
28 $(interface-headers) mach/exc.h mach/mach.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 server-interfaces := device/device_reply mach/exc # mach/__exc
46 distribute = Machrules syscalls.awk shortcut.awk
49 # XXX currently these files have been copied into mach/ (which should not
50 # otherwise exist). Eventually should snarf them from sysutils/bootstrap.
51 headers += $(addprefix mach/default_pager_types.,h defs)
52 user-interfaces += mach/default_pager
53 server-interfaces += mach/default_pager_helper
55 # Get the proper definition of `mach-srcdir'.
56 include ../sysdeps/mach/Makefile
58 # Use and install the Mach header files directly out of the Mach kernel source.
60 # Find the MiG defs files in the kernel source.
61 vpath %.defs $(mach-srcdir)
63 # Install all .h and .defs files we find in some of the kernel's source
64 # directories and their subdirectories (in MK82, max one level deep).
65 mach-src-headers := $(wildcard $(foreach dir,mach device mach_debug \
67 $(addprefix $(mach-srcdir)/$(dir)/,\
70 # Exclude mach/machine/*. A symlink will be installed for mach/machine.
71 mach-headers = $(filter-out mach/machine/%,\
72 $(mach-src-headers:$(mach-srcdir)/%=%))
73 install-others += $(addprefix $(includedir)/,$(mach-headers))
74 $(includedir)/%: $(mach-srcdir)/%; $(do-install)
76 # Make a symlink for mach/machine in the installed include directory.
77 install-others += $(includedir)/mach/machine
78 $(includedir)/mach/machine: $(common-objpfx)config.make
80 cd $(@D); ln -s $(config-machine) $(@F)
82 # Install Mach's <sys/version.h> as <mach/version.h>.
83 install-others += $(includedir)/mach/version.h
84 $(includedir)/mach/version.h: $(mach-srcdir)/sys/version.h; $(do-install)
86 # Define mach-syscalls and sysno-*.
87 ifndef inhibit_mach_syscalls
88 include $(objpfx)mach-syscalls.mk
90 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
92 sed -n -e '/Unix server implement them/,$$d' \
93 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \
94 < $< | awk -f $(word 2,$^) > $@-new
96 generated += mach-syscalls.mk
99 # We cannot make the deps properly until we know how to make the system
100 # call functions, and for that we must know what they all are.
103 $(mach-syscalls:%=$(objpfx)__%.S): $(objpfx)__%.S: $(objpfx)mach-syscalls.mk
104 (echo '#include <sysdep.h>'; \
105 echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@-new
107 $(mach-syscalls:%=$(objpfx)%.c): $(objpfx)%.c:
108 (echo '#include <gnu-stabs.h>'; \
109 echo 'symbol_alias (__$*, $*)') > $@-new
111 generated += $(mach-syscalls:%=__%.S) \
112 $(mach-syscalls:%=%.c)
113 endif # mach-syscalls
115 mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))
117 ifndef mach-shortcuts
118 # Forget about mach_interface.defs for this run. On the next run,
119 # $(mach-shortcuts) will be set, and that will change how
120 # mach_interface.defs is processed: it will get the -D flags below.
121 user-interfaces := $(filter-out mach/mach_interface \
122 mach/mach_port mach/mach_host,\
126 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
127 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
128 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
131 $(mach-shortcuts:%=$(objpfx)__%.c): $(objpfx)__%.c: shortcut.awk \
133 gawk -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
137 # The shortcut calls have had their names changed to CALL_rpc, so
138 # CALL_rpc.c is being generated with a symbol alias to __CALL_rpc.
139 # We also want CALL.c with an alias to __CALL.
140 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c:
141 (echo '#include <gnu-stabs.h>'; \
142 echo 'symbol_alias (__$*, $*)') > $@-new
144 generated += $(mach-shortcuts:%=%.c)
145 endif # mach-shortcuts
147 # Generate mach-shortcuts.h, which will contain the prototypes for the
148 # shortcutted kernel RPC functions.
149 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
150 $(objpfx)mach/mach_port.h
151 # The first line gets us one paragraph per line, with @s separating real lines.
152 # The second line selects paragraphs for the shortcutted functions.
153 # The third line removes `_rpc' from the names and rerealifies the lines.
154 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
155 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
156 | sed 's/_rpc//g' | tr @ \\012 > $@-new
158 generated += mach-shortcuts.h
160 before-compile += $(objpfx)mach-shortcuts.h
166 # There is already a mach.h, so mach.defs generates mach_interface.h.
167 $(objpfx)mach/mach_interface.uh: mach/mach.defs; $(mig.uh)
168 $(objpfx)mach/mach_interface.__h: mach/mach.defs; $(mig.__h)
169 # There is already a memory_object.h,
170 # so memory_object.defs generates memory_object_user.h.
171 $(objpfx)mach/memory_object_user.uh: mach/memory_object.defs; $(mig.uh)
172 $(objpfx)mach/memory_object_user.__h: mach/memory_object.defs; $(mig.__h)
174 # Be sure not to make these with implicit rules from foo.defs.
175 mach.h mach/memory_object.h: ;