Debian Codegraph @

mach/Makefile

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 # Copyright (C) 1991-2026 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
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 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
17
18 subdir := mach
19
20 include ../Makeconfig
21
22 headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \
23 $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \
24 $(lock-headers) machine-sp.h bits/mach/param.h
25 lock = spin-solid spin-lock mutex-init
26 lock-headers = lock-intern.h spin-lock.h
27 routines = $(mach-syscalls) $(mach-shortcuts) \
28 mach_init mig_strncpy mig_strlen mig_memcpy msg \
29 mig-alloc mig-dealloc mig-reply \
30 msg-destroy msgserver \
31 mach_error errstring error_compat errsystems \
32 devstream setup-thread $(lock)
33
34 # The RPC interfaces go in a separate library.
35 interface-library := libmachuser
36
37 # We produce mach_interface.h from mach.defs because there is already a
38 # <mach/mach.h> that is not the interface header (thanks CMU).
39 mach-interface-list := $(patsubst mach,mach_interface,$(mach-interface-list))
40 mach/mach_interface.defs = mach/mach.defs
41
42 # Similarly for memory_object_user vs. memory_object
43 mach-interface-list := $(patsubst memory_object,memory_object_user,\
44 $(mach-interface-list))
45 mach/memory_object_user.defs = mach/memory_object.defs
46
47 user-interfaces := $(addprefix mach/,$(mach-interface-list) \
48 mach_port mach_host exc \
49 )\
50 $(addprefix device/,device device_request)
51
52 server-interfaces := mach/exc
53
54 # Clear any environment value.
55 generated =
56
57 # Avoid ssp before TLS is initialized.
58 CFLAGS-mach_init.o = $(no-stack-protector)
59 CFLAGS-RPC_vm_statistics.o = $(no-stack-protector)
60 CFLAGS-RPC_vm_map.o = $(no-stack-protector)
61 CFLAGS-RPC_vm_protect.o = $(no-stack-protector)
62 CFLAGS-RPC_i386_set_gdt.o = $(no-stack-protector)
63 CFLAGS-RPC_i386_set_ldt.o = $(no-stack-protector)
64 CFLAGS-RPC_task_get_special_port.o = $(no-stack-protector)
65 CFLAGS-RPC_thread_set_state.o = $(no-stack-protector)
•66 CFLAGS-RPC_host_get_time.c = -DTypeCheck=0
67 CFLAGS-RPC_host_get_time64.c = -DTypeCheck=0
68 CFLAGS-RPC_host_get_uptime64.c = -DTypeCheck=0
69
70 # Translate GNU names for CPUs into the names used in Mach header files.
71 mach-machine = $(patsubst powerpc,ppc,$(base-machine))
72
73 # Define mach-syscalls and sysno-*.
74 ifndef inhibit_mach_syscalls
75 -include $(objpfx)mach-syscalls.mk
76 endif
77 $(objpfx)mach-syscalls.mk: syscalls.awk Makefile libc-modules.h
78 # Go kludges!!!
79 $(make-target-directory)
80 # We must use $(CFLAGS) to get -O flags that affect #if's in header files.
81 echo '#include <mach/syscall_sw.h>' | \
82 $(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \
83 -x c-header - \
84 -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
85 sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
86 | $(AWK) -f $< > $@-new
87 ifneq (,$(objpfx))
88 sed $(sed-remove-objpfx) $@-dep >> $@-new
89 else
90 cat $@-dep >> $@-new
91 endif
92 rm -f $@-dep
93 mv -f $@-new $@
94 generated += mach-syscalls.mk
95
96 ifndef mach-syscalls
97 # We cannot make the deps properly until we know how to make the system
98 # call functions, and for that we must know what they all are.
99 no_deps=t
100 else
101 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
102 (echo '#include <sysdep.h>'; \
103 echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
104 echo 'weak_alias (__$*, $*)'; \
105 echo 'libc_hidden_def (__$*)') > $@-new
106 mv -f $@-new $@
107 generated += $(mach-syscalls:=.S)
108 endif # mach-syscalls
109
110 # These syscalls that look like RPCs actually have no RPC equivalents.
111 mach-shortcuts := $(filter-out device_writev_request \
112 device_read_overwrite_request \
113 device_read_overwrite \
114 vm_read_overwrite \
115 thread_switch \
116 ,\
117 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
118
119 ifndef mach-shortcuts
120 # Forget about mach_interface.defs for this run. On the next run,
121 # $(mach-shortcuts) will be set, and that will change how
122 # mach_interface.defs is processed: it will get the -D flags below.
123 user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \
124 mach/mach_port mach/mach_host mach/mach4 mach/gnumach \
125 device/device_request,\
126 $(user-interfaces))
127 endif
128
129 # For some reason, the calls in this file are `protected' by an ifdef.
130 MIGFLAGS-mach/mach4 = -DMACH_PCSAMPLE
131 MIGFLAGS-device/device = -DDEVICE_ENABLE_DEVICE_OPEN_NEW
132
133 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
134 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
135 $(mach-interface-list:%=mach/%.uh) \
136 mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
137
138 ifdef mach-shortcuts
139 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
140 $(objpfx)RPC_%_rpc.c
141 $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
142 -v syscall=__syscall_$* -f $^ > $@-new
143 mv -f $@-new $@
144 generated += $(mach-shortcuts:%=%.c)
145 endif # mach-shortcuts
146
147 # Generate mach-shortcuts.h, which will contain the prototypes for the
148 # shortcutted kernel RPC functions.
149 $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
150 $(objpfx)mach/mach_host.h \
151 $(objpfx)mach/mach_port.h
152 # The first line gets us one paragraph per line, with @s separating real lines.
153 # The second line selects paragraphs for the shortcutted functions.
154 # The third line removes `_rpc' from the names and reconstitutes the lines.
155 ( echo "#include <mach/mach_types.h>" ; \
156 echo "#include <mach/message.h>" ; \
157 echo ; \
158 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
159 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
160 | sed 's/_rpc//g' | tr @ \\012 ) > $@-new
161 mv -f $@-new $@
162 generated += mach-shortcuts.h
163
164 before-compile += $(objpfx)mach-shortcuts.h
165
166 include Machrules
167 include ../Rules
168
169
170 # A gcc bug prevents the generated file from working properly,
171 # so we have one in the distribution for the time being.
172 generated += errsystems.c
173 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
174 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
175 $(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > [email protected]
176 mv -f [email protected] $@
177
178
179 # Convenient target to update all the generated source files.
180 .PHONY: generated
181 generated: $(addprefix $(common-objpfx),$(common-generated)) \
182 $(addprefix $(objpfx),$(generated))
183
184 .PHONY: mach-before-compile
185 mach-before-compile: $(mach-before-compile)