1 # Copyright (C) 1991, 1992, 1993, 1994 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_error.h mach-shortcuts.h \
28 $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h
29 distribute = thread_state.h
30 routines = $(interface-routines) \
31 $(filter-out syscall_%,$(mach-syscalls)) \
32 $(addprefix __,$(mach-syscalls)) \
33 $(mach-shortcuts) $(addprefix __,$(mach-shortcuts)) \
34 mach_init vm_page_size \
35 mig_strncpy __msg msg \
36 mig_support mig_syms \
37 msg_destroy msgserver msgserver_t \
38 __msg_dest __msgserver \
39 mach_error mach_error_string error_compat errsystems \
40 devstream bootprivport setup-thread thread-sym
41 user-interfaces := $(addprefix mach/,mach_interface mach_port mach_host \
43 memory_object_default \
46 $(addprefix device/,device device_request)
47 server-interfaces := device/device_reply mach/exc mach/notify
49 # It is important that we do not use the wildcard function to expand
50 # `err_*.sub'. Leaving the wildcard allows Make-dist to find all matching
51 # files in all sysdep directories.
52 distribute += Machrules syscalls.awk shortcut.awk \
56 # XXX currently these files have been copied into mach/. They will
57 # supposedly disappear in the future.
58 headers += $(addprefix mach/default_pager_types.,h defs)
59 user-interfaces += mach/default_pager
60 server-interfaces += mach/default_pager_helper
62 # Clear any environment value.
65 # Get the proper definition of `mach-srcdir'.
66 include ../sysdeps/mach/Makefile
68 # Use and install the Mach header files directly out of the Mach kernel source.
70 # Find the MiG defs files in the kernel source.
71 vpath %.defs $(mach-srcdir)
73 # Install all .h and .defs files we find in some of the kernel's source
74 # directories and their subdirectories (in MK82, max one level deep).
75 mach-src-headers := $(wildcard $(foreach dir,mach device mach_debug \
77 $(addprefix $(mach-srcdir)/$(dir)/,\
80 # Exclude mach/machine/*. A symlink will be installed for mach/machine.
81 # Exclude $(headers) for Mach files we have our own versions of.
82 mach-headers = $(filter-out mach/machine/% $(headers),\
83 $(mach-src-headers:$(mach-srcdir)/%=%))
85 # Don't distribute the Mach headers; they are in the Mach distribution.
86 dont_distribute = $(mach-headers)
88 # DO NOT try to remake these in any way!!!
89 $(addprefix $(mach-srcdir)/,$(mach-headers)) : ;
90 install-others += $(addprefix $(includedir)/,$(mach-headers))
91 $(includedir)/%: $(mach-srcdir)/%; $(do-install)
93 # Make symlinks for machine and mach/machine in the include directory.
94 install-others += $(includedir)/mach/machine $(includedir)/machine
95 $(includedir)/mach/machine $(includedir)/machine: $(common-objpfx)config.make
97 cd $(@D); ln -s $(config-machine) $(@F)
99 # Install Mach's <sys/version.h> as <mach/version.h>.
100 install-others += $(includedir)/mach/version.h
101 $(includedir)/mach/version.h: $(mach-srcdir)/sys/version.h; $(do-install)
103 # Define mach-syscalls and sysno-*.
104 ifndef inhibit_mach_syscalls
105 include $(objpfx)mach-syscalls.mk
107 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
109 sed -n -e '/Unix server implement them/,$$d' \
110 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \
111 < $< | awk -f $(word 2,$^) > $@-new
113 generated += $(objpfx)mach-syscalls.mk
116 # We cannot make the deps properly until we know how to make the system
117 # call functions, and for that we must know what they all are.
120 $(mach-syscalls:%=$(objpfx)__%.S): $(objpfx)__%.S: $(objpfx)mach-syscalls.mk
121 (echo '#include <sysdep.h>'; \
122 echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@-new
124 $(mach-syscalls:%=$(objpfx)%.c): $(objpfx)%.c: Makefile
125 (echo '#include <gnu-stabs.h>'; \
126 echo 'symbol_alias (__$*, $*);') > $@-new
128 generated += $(mach-syscalls:%=$(objpfx)__%.S) \
129 $(mach-syscalls:%=$(objpfx)%.c)
130 endif # mach-syscalls
132 mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))
134 ifndef mach-shortcuts
135 # Forget about mach_interface.defs for this run. On the next run,
136 # $(mach-shortcuts) will be set, and that will change how
137 # mach_interface.defs is processed: it will get the -D flags below.
138 user-interfaces := $(filter-out mach/mach_interface \
139 mach/mach_port mach/mach_host,\
143 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
144 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
145 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
148 $(mach-shortcuts:%=$(objpfx)__%.c): $(objpfx)__%.c: shortcut.awk \
150 gawk -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
154 # The shortcut calls have had their names changed to CALL_rpc, so
155 # CALL_rpc.c is being generated with a symbol alias to __CALL_rpc.
156 # We also want CALL.c with an alias to __CALL.
157 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: # Makefile
158 (echo '#include <gnu-stabs.h>'; \
159 echo 'symbol_alias (__$*, $*);') > $@-new
161 generated += $(mach-shortcuts:%=$(objpfx)%.c)
162 endif # mach-shortcuts
164 # Generate mach-shortcuts.h, which will contain the prototypes for the
165 # shortcutted kernel RPC functions.
166 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
167 $(objpfx)mach/mach_port.h
168 # The first line gets us one paragraph per line, with @s separating real lines.
169 # The second line selects paragraphs for the shortcutted functions.
170 # The third line removes `_rpc' from the names and rerealifies the lines.
171 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
172 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
173 | sed 's/_rpc//g' | tr @ \\012 > $@-new
175 generated += $(objpfx)mach-shortcuts.h
177 before-compile += $(objpfx)mach-shortcuts.h
183 # There is already a mach.h, so mach.defs generates mach_interface.h.
184 $(objpfx)mach/mach_interface.defs: $(mach-srcdir)/mach/mach.defs
186 # There is already a memory_object.h,
187 # so memory_object.defs generates memory_object_user.h.
188 $(objpfx)mach/memory_object_user.defs: $(mach-srcdir)/mach/memory_object.defs
192 vpath mach/mach_interface.defs $(objdir)
193 vpath mach/memory_object_user.defs $(objdir)
196 # Be sure not to make these with implicit rules from foo.defs.
197 mach.h mach/memory_object.h: ;
200 # XXX we have an errsystems.c here because a gcc bug makes the generated
203 generated += $(objpfx)errsystems.c
204 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
205 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
206 gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n