1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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 mach/mach_traps.h \
28 $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \
29 $(lock-headers) machine-sp.h
30 distribute = thread_state.h
31 lock = spin-solid spin-lock mutex-init mutex-solid
32 lock-headers = lock-intern.h machine-lock.h spin-lock.h
33 routines = $(mach-syscalls) $(mach-shortcuts) \
34 mach_init mig_strncpy msg \
35 mig-alloc mig-dealloc mig-reply \
36 msg-destroy msgserver \
37 mach_error errstring error_compat errsystems \
38 devstream bootprivport setup-thread $(lock)
39 # The RPC interfaces go in a separate library.
40 interface-library := libmachuser
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 # Clear any environment value.
59 # Get the proper definition of `mach-srcdir'.
60 include ../sysdeps/mach/Makefile
62 # Use and install the Mach header files directly out of the Mach kernel source.
64 # Find the MiG defs files in the kernel source.
65 vpath %.defs $(mach-srcdir)
67 # Install all .h and .defs files we find in some of the kernel's source
68 # directories and their subdirectories (in MK82, max one level deep).
69 mach-src-headers := $(wildcard $(foreach dir,mach device mach_debug \
71 $(addprefix $(mach-srcdir)/$(dir)/,\
74 # Exclude mach/machine/*. A symlink will be installed for mach/machine.
75 # Exclude $(headers) for Mach files we have our own versions of.
76 mach-headers = $(filter-out mach/machine/% $(headers),\
77 $(mach-src-headers:$(mach-srcdir)/%=%))
78 # Rename Mach's sys/version.h to mach/version.h.
79 mach-headers := $(patsubst sys/version.h,mach/version.h,$(mach-headers))
81 # Don't distribute the Mach headers; they are in the Mach distribution.
82 dont_distribute = $(mach-headers)
84 # DO NOT try to remake these in any way!!!
85 $(addprefix $(mach-srcdir)/,$(mach-headers)) : ;
86 install-others += $(addprefix $(includedir)/,$(mach-headers))
87 $(includedir)/%: $(mach-srcdir)/%; $(do-install)
89 # Make symlinks for machine and mach/machine in the include directory.
90 install-others += $(includedir)/mach/machine $(includedir)/machine
91 $(includedir)/mach/machine $(includedir)/machine: $(common-objpfx)config.make
93 cd $(@D); ln -s $(config-machine) $(@F)
95 # Install Mach's <sys/version.h> as <mach/version.h>.
96 install-others += $(includedir)/mach/version.h
97 $(includedir)/mach/version.h: $(mach-srcdir)/sys/version.h; $(do-install)
99 # Define mach-syscalls and sysno-*.
100 ifndef inhibit_mach_syscalls
101 include $(objpfx)mach-syscalls.mk
103 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
105 sed -n -e '/Unix server implement them/,$$d' \
106 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
107 < $< | awk -f $(word 2,$^) > $@-new
109 generated += mach-syscalls.mk
112 # We cannot make the deps properly until we know how to make the system
113 # call functions, and for that we must know what they all are.
116 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
117 (echo '#include <sysdep.h>'; \
118 echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))'; \
119 echo 'weak_alias (__$*, $*)') > $@-new
121 generated += $(mach-syscalls:=.S)
122 endif # mach-syscalls
124 # syscall_device_writev_request has no RPC equivalent.
125 mach-shortcuts := $(filter-out device_writev_request,\
126 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
128 ifndef mach-shortcuts
129 # Forget about mach_interface.defs for this run. On the next run,
130 # $(mach-shortcuts) will be set, and that will change how
131 # mach_interface.defs is processed: it will get the -D flags below.
132 user-interfaces := $(filter-out mach/mach_interface \
133 mach/mach_port mach/mach_host mach/mach4 \
134 device/device_request,\
138 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
139 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
140 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
143 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
145 gawk -v alias=$* -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
148 generated += $(mach-shortcuts:%=%.c)
149 endif # mach-shortcuts
151 # Generate mach-shortcuts.h, which will contain the prototypes for the
152 # shortcutted kernel RPC functions.
153 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
154 $(objpfx)mach/mach_port.h
155 # The first line gets us one paragraph per line, with @s separating real lines.
156 # The second line selects paragraphs for the shortcutted functions.
157 # The third line removes `_rpc' from the names and rerealifies the lines.
158 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
159 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
160 | sed 's/_rpc//g' | tr @ \\012 > $@-new
162 generated += mach-shortcuts.h
164 before-compile += $(objpfx)mach-shortcuts.h
170 # There is already a mach.h, so mach.defs generates mach_interface.h.
171 $(objpfx)mach/mach_interface.defs: $(mach-srcdir)/mach/mach.defs
173 # There is already a memory_object.h,
174 # so memory_object.defs generates memory_object_user.h.
175 $(objpfx)mach/memory_object_user.defs: $(mach-srcdir)/mach/memory_object.defs
179 vpath mach/mach_interface.defs $(objdir)
180 vpath mach/memory_object_user.defs $(objdir)
183 # Be sure not to make these with implicit rules from foo.defs.
184 mach.h mach/memory_object.h: ;
187 # A gcc bug prevents the generated file from working properly,
188 # so we have one in the distribution for the time being.
189 generated += errsystems.c
190 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
191 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
192 gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n