1 # Copyright (C) 1991,92,93,94,95,96,97,98,2001,02
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <http://www.gnu.org/licenses/>.
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 setup-thread $(lock)
40 # The RPC interfaces go in a separate library.
41 interface-library := libmachuser
43 # We produce mach_interface.h from mach.defs because there is already a
44 # <mach/mach.h> that is not the interface header (thanks CMU).
45 mach-interface-list := $(patsubst mach,mach_interface,$(mach-interface-list))
46 mach/mach_interface.defs = mach/mach.defs
48 # Similarly for memory_object_user vs. memory_object
49 mach-interface-list := $(patsubst memory_object,memory_object_user,\
50 $(mach-interface-list))
51 mach/memory_object_user.defs = mach/memory_object.defs
53 user-interfaces := $(addprefix mach/,$(mach-interface-list) \
54 mach_port mach_host exc \
56 $(addprefix device/,device device_request)
58 server-interfaces := mach/exc
60 # It is important that we do not use the wildcard function to expand
61 # `err_*.sub'. Leaving the wildcard allows Make-dist to find all matching
62 # files in all sysdep directories.
63 distribute += Machrules syscalls.awk shortcut.awk \
64 errorlib.h err_*.sub errsystems.awk
66 # Clear any environment value.
69 # Translate GNU names for CPUs into the names used in Mach header files.
70 mach-machine = $(patsubst powerpc,ppc,$(base-machine))
72 # Define mach-syscalls and sysno-*.
73 ifndef inhibit_mach_syscalls
74 -include $(objpfx)mach-syscalls.mk
76 $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
78 $(make-target-directory)
79 # We must use $(CFLAGS) to get -O flags that affect #if's in header files.
80 echo '#include <mach/syscall_sw.h>' | \
81 $(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \
83 -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
84 sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
85 | $(AWK) -f $< > $@-new
87 sed $(sed-remove-objpfx) $@-dep >> $@-new
93 generated += mach-syscalls.mk
96 # We cannot make the deps properly until we know how to make the system
97 # call functions, and for that we must know what they all are.
100 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
101 (echo '#include <sysdep.h>'; \
102 echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
103 echo 'weak_alias (__$*, $*)') > $@-new
105 generated += $(mach-syscalls:=.S)
106 endif # mach-syscalls
108 # These syscalls that look like RPCs actually have no RPC equivalents.
109 mach-shortcuts := $(filter-out device_writev_request \
110 device_read_overwrite_request \
111 device_read_overwrite \
115 $(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-interface-list:%=mach/%) \
122 mach/mach_port mach/mach_host mach/mach4 \
123 device/device_request,\
127 # For some reason, the calls in this file are `protected' by an ifdef.
128 MIGFLAGS-mach/mach4=-DMACH_PCSAMPLE
130 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
131 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
132 $(mach-interface-list:%=mach/%.uh) \
133 mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
136 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
138 $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
139 -v syscall=__syscall_$* -f $^ > $@-new
141 generated += $(mach-shortcuts:%=%.c)
142 endif # mach-shortcuts
144 # Generate mach-shortcuts.h, which will contain the prototypes for the
145 # shortcutted kernel RPC functions.
146 $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
147 $(objpfx)mach/mach_host.h \
148 $(objpfx)mach/mach_port.h
149 # The first line gets us one paragraph per line, with @s separating real lines.
150 # The second line selects paragraphs for the shortcutted functions.
151 # The third line removes `_rpc' from the names and reconstitutes the lines.
152 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
153 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
154 | sed 's/_rpc//g' | tr @ \\012 > $@-new
156 generated += mach-shortcuts.h
158 before-compile += $(objpfx)mach-shortcuts.h
164 # A gcc bug prevents the generated file from working properly,
165 # so we have one in the distribution for the time being.
166 generated += errsystems.c
167 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
168 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
169 $(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
173 # Convenient target to update all the generated source files.
175 generated: $(addprefix $(common-objpfx),$(common-generated)) \
176 $(addprefix $(objpfx),$(generated))
178 .PHONY: mach-before-compile
179 mach-before-compile: $(mach-before-compile)