split assume pipe2/dup3/sock_cloexec knobs
[glibc.git] / mach / Makefile
blob00de7a505e5e9f5e3fe9c8ce3473046865df311c
1 # Copyright (C) 1991,92,93,94,95,96,97,98,2001,02,12
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/>.
19 subdir := mach
21 all:
23 # Some things below (but before including Rules) use configuration variables.
24 include ../Makeconfig
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 lock = spin-solid spin-lock mutex-init mutex-solid
31 lock-headers = lock-intern.h machine-lock.h spin-lock.h
32 routines = $(mach-syscalls) $(mach-shortcuts) \
33 mach_init mig_strncpy msg \
34 mig-alloc mig-dealloc mig-reply \
35 msg-destroy msgserver \
36 mach_error errstring error_compat errsystems \
37 devstream setup-thread $(lock)
39 # The RPC interfaces go in a separate library.
40 interface-library := libmachuser
42 # We produce mach_interface.h from mach.defs because there is already a
43 # <mach/mach.h> that is not the interface header (thanks CMU).
44 mach-interface-list := $(patsubst mach,mach_interface,$(mach-interface-list))
45 mach/mach_interface.defs = mach/mach.defs
47 # Similarly for memory_object_user vs. memory_object
48 mach-interface-list := $(patsubst memory_object,memory_object_user,\
49 $(mach-interface-list))
50 mach/memory_object_user.defs = mach/memory_object.defs
52 user-interfaces := $(addprefix mach/,$(mach-interface-list) \
53 mach_port mach_host exc \
55 $(addprefix device/,device device_request)
57 server-interfaces := mach/exc
59 # Clear any environment value.
60 generated =
62 # Translate GNU names for CPUs into the names used in Mach header files.
63 mach-machine = $(patsubst powerpc,ppc,$(base-machine))
65 # Define mach-syscalls and sysno-*.
66 ifndef inhibit_mach_syscalls
67 -include $(objpfx)mach-syscalls.mk
68 endif
69 $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
70 # Go kludges!!!
71 $(make-target-directory)
72 # We must use $(CFLAGS) to get -O flags that affect #if's in header files.
73 echo '#include <mach/syscall_sw.h>' | \
74 $(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \
75 -x c-header - \
76 -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
77 sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
78 | $(AWK) -f $< > $@-new
79 ifneq (,$(objpfx))
80 sed $(sed-remove-objpfx) $@-dep >> $@-new
81 else
82 cat $@-dep >> $@-new
83 endif
84 rm -f $@-dep
85 mv -f $@-new $@
86 generated += mach-syscalls.mk
88 ifndef mach-syscalls
89 # We cannot make the deps properly until we know how to make the system
90 # call functions, and for that we must know what they all are.
91 no_deps=t
92 else
93 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
94 (echo '#include <sysdep.h>'; \
95 echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
96 echo 'weak_alias (__$*, $*)') > $@-new
97 mv -f $@-new $@
98 generated += $(mach-syscalls:=.S)
99 endif # mach-syscalls
101 # These syscalls that look like RPCs actually have no RPC equivalents.
102 mach-shortcuts := $(filter-out device_writev_request \
103 device_read_overwrite_request \
104 device_read_overwrite \
105 vm_read_overwrite \
106 thread_switch \
108 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
110 ifndef mach-shortcuts
111 # Forget about mach_interface.defs for this run. On the next run,
112 # $(mach-shortcuts) will be set, and that will change how
113 # mach_interface.defs is processed: it will get the -D flags below.
114 user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \
115 mach/mach_port mach/mach_host mach/mach4 \
116 device/device_request,\
117 $(user-interfaces))
118 endif
120 # For some reason, the calls in this file are `protected' by an ifdef.
121 MIGFLAGS-mach/mach4=-DMACH_PCSAMPLE
123 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
124 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
125 $(mach-interface-list:%=mach/%.uh) \
126 mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
128 ifdef mach-shortcuts
129 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
130 $(objpfx)RPC_%_rpc.c
131 $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
132 -v syscall=__syscall_$* -f $^ > $@-new
133 mv -f $@-new $@
134 generated += $(mach-shortcuts:%=%.c)
135 endif # mach-shortcuts
137 # Generate mach-shortcuts.h, which will contain the prototypes for the
138 # shortcutted kernel RPC functions.
139 $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
140 $(objpfx)mach/mach_host.h \
141 $(objpfx)mach/mach_port.h
142 # The first line gets us one paragraph per line, with @s separating real lines.
143 # The second line selects paragraphs for the shortcutted functions.
144 # The third line removes `_rpc' from the names and reconstitutes the lines.
145 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
146 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
147 | sed 's/_rpc//g' | tr @ \\012 > $@-new
148 mv -f $@-new $@
149 generated += mach-shortcuts.h
151 before-compile += $(objpfx)mach-shortcuts.h
153 include Machrules
154 include ../Rules
157 # A gcc bug prevents the generated file from working properly,
158 # so we have one in the distribution for the time being.
159 generated += errsystems.c
160 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
161 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
162 $(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
163 mv -f $@.n $@
166 # Convenient target to update all the generated source files.
167 .PHONY: generated
168 generated: $(addprefix $(common-objpfx),$(common-generated)) \
169 $(addprefix $(objpfx),$(generated))
171 .PHONY: mach-before-compile
172 mach-before-compile: $(mach-before-compile)