]>
Commit | Line | Data |
---|---|---|
fb190a04 RM |
1 | # Copyright (C) 1991,92,93,94,95,96,97,98,2001,02 |
2 | # Free Software Foundation, Inc. | |
28f540f4 RM |
3 | # This file is part of the GNU C Library. |
4 | ||
5 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
28f540f4 RM |
9 | |
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 | |
41bdb6e2 | 13 | # Lesser General Public License for more details. |
28f540f4 | 14 | |
41bdb6e2 AJ |
15 | # You should have received a copy of the GNU Lesser General Public |
16 | # License along with the GNU C Library; if not, write to the Free | |
17 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | # 02111-1307 USA. | |
28f540f4 RM |
19 | |
20 | subdir := mach | |
21 | ||
22 | all: | |
23 | ||
24 | # Some things below (but before including Rules) use configuration variables. | |
25 | include ../Makeconfig | |
26 | ||
27 | ||
c316b486 | 28 | headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \ |
28f540f4 RM |
29 | $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \ |
30 | $(lock-headers) machine-sp.h | |
31 | distribute = thread_state.h | |
2f8033d6 | 32 | lock = spin-solid spin-lock mutex-init mutex-solid |
28f540f4 RM |
33 | lock-headers = lock-intern.h machine-lock.h spin-lock.h |
34 | routines = $(mach-syscalls) $(mach-shortcuts) \ | |
35 | mach_init mig_strncpy msg \ | |
36 | mig-alloc mig-dealloc mig-reply \ | |
37 | msg-destroy msgserver \ | |
38 | mach_error errstring error_compat errsystems \ | |
c12bc232 RM |
39 | devstream setup-thread $(lock) |
40 | ||
28f540f4 | 41 | # The RPC interfaces go in a separate library. |
f0bf9cb9 | 42 | interface-library := libmachuser |
c12bc232 | 43 | |
aa592a63 RM |
44 | # We produce mach_interface.h from mach.defs because there is already a |
45 | # <mach/mach.h> that is not the interface header (thanks CMU). | |
c12bc232 | 46 | mach-interface-list := $(patsubst mach,mach_interface,$(mach-interface-list)) |
c2bf8a5a | 47 | mach/mach_interface.defs = mach/mach.defs |
c12bc232 | 48 | |
c2bf8a5a | 49 | # Similarly for memory_object_user vs. memory_object |
c12bc232 RM |
50 | mach-interface-list := $(patsubst memory_object,memory_object_user,\ |
51 | $(mach-interface-list)) | |
c2bf8a5a | 52 | mach/memory_object_user.defs = mach/memory_object.defs |
c12bc232 RM |
53 | |
54 | user-interfaces := $(addprefix mach/,$(mach-interface-list) \ | |
55 | mach_port mach_host exc \ | |
56 | )\ | |
57 | $(addprefix device/,device device_request) | |
58 | ||
a1c46301 | 59 | server-interfaces := mach/exc |
c12bc232 | 60 | |
28f540f4 RM |
61 | # It is important that we do not use the wildcard function to expand |
62 | # `err_*.sub'. Leaving the wildcard allows Make-dist to find all matching | |
63 | # files in all sysdep directories. | |
64 | distribute += Machrules syscalls.awk shortcut.awk \ | |
158ff48e | 65 | errorlib.h err_*.sub errsystems.awk |
28f540f4 | 66 | |
28f540f4 RM |
67 | # Clear any environment value. |
68 | generated = | |
69 | \f | |
3a2832a0 RM |
70 | # Translate GNU names for CPUs into the names used in Mach header files. |
71 | mach-machine = $(patsubst powerpc,ppc,$(base-machine)) | |
72 | ||
28f540f4 RM |
73 | # Define mach-syscalls and sysno-*. |
74 | ifndef inhibit_mach_syscalls | |
f50a53cb | 75 | -include $(objpfx)mach-syscalls.mk |
28f540f4 | 76 | endif |
aa1075ea | 77 | $(objpfx)mach-syscalls.mk: syscalls.awk Makefile |
28f540f4 | 78 | # Go kludges!!! |
19cc96bf | 79 | $(make-target-directory) |
c337dc4c | 80 | # We must use $(CFLAGS) to get -O flags that affect #if's in header files. |
aa1075ea | 81 | echo '#include <mach/syscall_sw.h>' | \ |
7cd72ad3 RM |
82 | $(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \ |
83 | -x c-header - \ | |
3a2832a0 | 84 | -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \ |
aa1075ea | 85 | sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\ |
5aa8ff62 | 86 | | $(AWK) -f $< > $@-new |
7cd72ad3 RM |
87 | ifneq (,$(objpfx)) |
88 | sed $(sed-remove-objpfx) $@-dep >> $@-new | |
89 | else | |
90 | cat $@-dep >> $@-new | |
91 | endif | |
92 | rm -f $@-dep | |
a53bad16 | 93 | mv -f $@-new $@ |
28f540f4 RM |
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 | |
ab7dd85b RM |
102 | (echo '#include <sysdep.h>'; \ |
103 | echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \ | |
28f540f4 | 104 | echo 'weak_alias (__$*, $*)') > $@-new |
a53bad16 | 105 | mv -f $@-new $@ |
28f540f4 RM |
106 | generated += $(mach-syscalls:=.S) |
107 | endif # mach-syscalls | |
108 | ||
3a2832a0 RM |
109 | # These syscalls that look like RPCs actually have no RPC equivalents. |
110 | mach-shortcuts := $(filter-out device_writev_request \ | |
111 | device_read_overwrite_request \ | |
112 | device_read_overwrite \ | |
113 | vm_read_overwrite \ | |
114 | thread_switch \ | |
115 | ,\ | |
28f540f4 RM |
116 | $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))) |
117 | ||
118 | ifndef mach-shortcuts | |
119 | # Forget about mach_interface.defs for this run. On the next run, | |
120 | # $(mach-shortcuts) will be set, and that will change how | |
121 | # mach_interface.defs is processed: it will get the -D flags below. | |
c12bc232 | 122 | user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \ |
28f540f4 RM |
123 | mach/mach_port mach/mach_host mach/mach4 \ |
124 | device/device_request,\ | |
125 | $(user-interfaces)) | |
126 | endif | |
127 | ||
bfb82622 TBB |
128 | # For some reason, the calls in this file are `protected' by an ifdef. |
129 | MIGFLAGS-mach/mach4=-DMACH_PCSAMPLE | |
130 | ||
28f540f4 RM |
131 | # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc. |
132 | migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc) | |
c12bc232 RM |
133 | $(mach-interface-list:%=mach/%.uh) \ |
134 | mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk | |
28f540f4 RM |
135 | |
136 | ifdef mach-shortcuts | |
137 | $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \ | |
138 | $(objpfx)RPC_%_rpc.c | |
5aa8ff62 UD |
139 | $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \ |
140 | -v syscall=__syscall_$* -f $^ > $@-new | |
a53bad16 | 141 | mv -f $@-new $@ |
28f540f4 RM |
142 | generated += $(mach-shortcuts:%=%.c) |
143 | endif # mach-shortcuts | |
144 | ||
145 | # Generate mach-shortcuts.h, which will contain the prototypes for the | |
146 | # shortcutted kernel RPC functions. | |
c12bc232 | 147 | $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \ |
acba7f19 | 148 | $(objpfx)mach/mach_host.h \ |
28f540f4 RM |
149 | $(objpfx)mach/mach_port.h |
150 | # The first line gets us one paragraph per line, with @s separating real lines. | |
151 | # The second line selects paragraphs for the shortcutted functions. | |
6d52618b | 152 | # The third line removes `_rpc' from the names and reconstitutes the lines. |
28f540f4 RM |
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) |