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