Fix dlfcn/failtestmod.c warning.
[glibc.git] / mach / Makefile
blobc316e7a942087ff082e5595736adfa068ef2546f
1 # Copyright (C) 1991-2014 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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 # <http://www.gnu.org/licenses/>.
18 subdir := mach
20 include ../Makeconfig
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
25 lock = spin-solid spin-lock mutex-init mutex-solid
26 lock-headers = lock-intern.h machine-lock.h spin-lock.h
27 routines = $(mach-syscalls) $(mach-shortcuts) \
28 mach_init mig_strncpy msg \
29 mig-alloc mig-dealloc mig-reply \
30 msg-destroy msgserver \
31 mach_error errstring error_compat errsystems \
32 devstream setup-thread $(lock)
34 # The RPC interfaces go in a separate library.
35 interface-library := libmachuser
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
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
47 user-interfaces := $(addprefix mach/,$(mach-interface-list) \
48 mach_port mach_host exc \
50 $(addprefix device/,device device_request)
52 server-interfaces := mach/exc
54 # Clear any environment value.
55 generated =
57 # Translate GNU names for CPUs into the names used in Mach header files.
58 mach-machine = $(patsubst powerpc,ppc,$(base-machine))
60 # Define mach-syscalls and sysno-*.
61 ifndef inhibit_mach_syscalls
62 -include $(objpfx)mach-syscalls.mk
63 endif
64 $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
65 # Go kludges!!!
66 $(make-target-directory)
67 # We must use $(CFLAGS) to get -O flags that affect #if's in header files.
68 echo '#include <mach/syscall_sw.h>' | \
69 $(CC) $(CFLAGS) $(CPPFLAGS) -E -MD -MP -MF $@-dep -MT $@ \
70 -x c-header - \
71 -D_MACH_`echo $(mach-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
72 sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
73 | $(AWK) -f $< > $@-new
74 ifneq (,$(objpfx))
75 sed $(sed-remove-objpfx) $@-dep >> $@-new
76 else
77 cat $@-dep >> $@-new
78 endif
79 rm -f $@-dep
80 mv -f $@-new $@
81 generated += mach-syscalls.mk
83 ifndef mach-syscalls
84 # We cannot make the deps properly until we know how to make the system
85 # call functions, and for that we must know what they all are.
86 no_deps=t
87 else
88 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
89 (echo '#include <sysdep.h>'; \
90 echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
91 echo 'weak_alias (__$*, $*)') > $@-new
92 mv -f $@-new $@
93 generated += $(mach-syscalls:=.S)
94 endif # mach-syscalls
96 # These syscalls that look like RPCs actually have no RPC equivalents.
97 mach-shortcuts := $(filter-out device_writev_request \
98 device_read_overwrite_request \
99 device_read_overwrite \
100 vm_read_overwrite \
101 thread_switch \
103 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
105 ifndef mach-shortcuts
106 # Forget about mach_interface.defs for this run. On the next run,
107 # $(mach-shortcuts) will be set, and that will change how
108 # mach_interface.defs is processed: it will get the -D flags below.
109 user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \
110 mach/mach_port mach/mach_host mach/mach4 \
111 device/device_request,\
112 $(user-interfaces))
113 endif
115 # For some reason, the calls in this file are `protected' by an ifdef.
116 MIGFLAGS-mach/mach4=-DMACH_PCSAMPLE
118 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
119 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
120 $(mach-interface-list:%=mach/%.uh) \
121 mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
123 ifdef mach-shortcuts
124 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
125 $(objpfx)RPC_%_rpc.c
126 $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
127 -v syscall=__syscall_$* -f $^ > $@-new
128 mv -f $@-new $@
129 generated += $(mach-shortcuts:%=%.c)
130 endif # mach-shortcuts
132 # Generate mach-shortcuts.h, which will contain the prototypes for the
133 # shortcutted kernel RPC functions.
134 $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
135 $(objpfx)mach/mach_host.h \
136 $(objpfx)mach/mach_port.h
137 # The first line gets us one paragraph per line, with @s separating real lines.
138 # The second line selects paragraphs for the shortcutted functions.
139 # The third line removes `_rpc' from the names and reconstitutes the lines.
140 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
141 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
142 | sed 's/_rpc//g' | tr @ \\012 > $@-new
143 mv -f $@-new $@
144 generated += mach-shortcuts.h
146 before-compile += $(objpfx)mach-shortcuts.h
148 include Machrules
149 include ../Rules
152 # A gcc bug prevents the generated file from working properly,
153 # so we have one in the distribution for the time being.
154 generated += errsystems.c
155 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
156 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
157 $(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
158 mv -f $@.n $@
161 # Convenient target to update all the generated source files.
162 .PHONY: generated
163 generated: $(addprefix $(common-objpfx),$(common-generated)) \
164 $(addprefix $(objpfx),$(generated))
166 .PHONY: mach-before-compile
167 mach-before-compile: $(mach-before-compile)