* Makerules (install-lib.so rules): Undouble $s in target and dep
[glibc.git] / mach / Makefile
blob747a6bfead5d8a926495f5df65b2efabe3f51d1a
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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 Library General Public License
6 # as published by the Free Software Foundation; either version 2 of
7 # 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 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, USA.
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 distribute = thread_state.h
31 lock = spin-solid spin-lock mutex-init mutex-solid
32 lock-headers = lock-intern.h machine-lock.h spin-lock.h
33 routines = $(mach-syscalls) $(mach-shortcuts) \
34 mach_init mig_strncpy msg \
35 mig-alloc mig-dealloc mig-reply \
36 msg-destroy msgserver \
37 mach_error errstring error_compat errsystems \
38 devstream bootprivport setup-thread $(lock)
39 # The RPC interfaces go in a separate library.
40 interface-library := libmachuser
41 user-interfaces := $(addprefix mach/,mach_interface mach_port mach_host \
42 memory_object_user \
43 memory_object_default \
44 exc mach4 \
45 default_pager default_pager_helper \
47 $(addprefix device/,device device_request)
48 server-interfaces := mach/exc
49 tests := hello
50 # It is important that we do not use the wildcard function to expand
51 # `err_*.sub'. Leaving the wildcard allows Make-dist to find all matching
52 # files in all sysdep directories.
53 distribute += Machrules syscalls.awk shortcut.awk \
54 errorlib.h err_*.sub
57 # Clear any environment value.
58 generated =
60 # Get the proper definition of `mach-srcdir'.
61 include ../sysdeps/mach/Makefile
63 # Use and install the Mach header files directly out of the Mach kernel source.
65 # Find the MiG defs files in the kernel source.
66 vpath %.defs $(mach-srcdir)
68 # Install all .h and .defs files we find in some of the kernel's source
69 # directories and their subdirectories (in MK82, max one level deep).
70 mach-src-headers := $(wildcard $(foreach dir,mach device mach_debug \
71 $(base-machine),\
72 $(addprefix $(mach-srcdir)/$(dir)/,\
73 *.defs *.h \
74 */*.defs */*.h)))
75 # Exclude mach/machine/*. A symlink will be installed for mach/machine.
76 # Exclude $(headers) for Mach files we have our own versions of.
77 mach-headers = $(filter-out mach/machine/% $(headers),\
78 $(mach-src-headers:$(mach-srcdir)/%=%))
79 # Rename Mach's sys/version.h to mach/version.h.
80 mach-headers := $(patsubst sys/version.h,mach/version.h,$(mach-headers))
82 # Don't distribute the Mach headers; they are in the Mach distribution.
83 dont_distribute = $(mach-headers)
85 # DO NOT try to remake these in any way!!!
86 $(addprefix $(mach-srcdir)/,$(mach-headers)) : ;
87 install-others += $(addprefix $(includedir)/,$(mach-headers))
88 $(includedir)/%: $(mach-srcdir)/%; $(do-install)
90 # Make symlinks for machine and mach/machine in the include directory.
91 install-others += $(includedir)/mach/machine $(includedir)/machine
92 $(includedir)/mach/machine $(includedir)/machine: $(common-objpfx)config.make
93 -rm -f $@
94 cd $(@D); ln -s $(base-machine) $(@F)
96 # Install Mach's <sys/version.h> as <mach/version.h>.
97 install-others += $(includedir)/mach/version.h
98 $(includedir)/mach/version.h: $(mach-srcdir)/sys/version.h; $(do-install)
100 # Define mach-syscalls and sysno-*.
101 ifndef no_deps
102 ifndef inhibit_mach_syscalls
103 include $(objpfx)mach-syscalls.mk
104 endif
105 endif
106 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
107 # Go kludges!!!
108 sed -n -e '/Unix server implement them/,$$d' \
109 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
110 < $< | awk -f $(word 2,$^) > $@-new
111 mv $@-new $@
112 generated += mach-syscalls.mk
114 ifndef mach-syscalls
115 # We cannot make the deps properly until we know how to make the system
116 # call functions, and for that we must know what they all are.
117 no_deps=t
118 else
119 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
120 (echo '#include <sysdep.h>'; \
121 echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))'; \
122 echo 'weak_alias (__$*, $*)') > $@-new
123 mv $@-new $@
124 generated += $(mach-syscalls:=.S)
125 endif # mach-syscalls
127 # syscall_device_writev_request has no RPC equivalent.
128 mach-shortcuts := $(filter-out device_writev_request,\
129 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
131 ifndef mach-shortcuts
132 # Forget about mach_interface.defs for this run. On the next run,
133 # $(mach-shortcuts) will be set, and that will change how
134 # mach_interface.defs is processed: it will get the -D flags below.
135 user-interfaces := $(filter-out mach/mach_interface \
136 mach/mach_port mach/mach_host mach/mach4 \
137 device/device_request,\
138 $(user-interfaces))
139 endif
141 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
142 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
143 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
145 ifdef mach-shortcuts
146 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
147 $(objpfx)RPC_%_rpc.c
148 gawk -v alias=$* -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
149 -f $^ > $@-new
150 mv $@-new $@
151 generated += $(mach-shortcuts:%=%.c)
152 endif # mach-shortcuts
154 # Generate mach-shortcuts.h, which will contain the prototypes for the
155 # shortcutted kernel RPC functions.
156 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
157 $(objpfx)mach/mach_port.h
158 # The first line gets us one paragraph per line, with @s separating real lines.
159 # The second line selects paragraphs for the shortcutted functions.
160 # The third line removes `_rpc' from the names and rerealifies the lines.
161 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
162 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
163 | sed 's/_rpc//g' | tr @ \\012 > $@-new
164 mv $@-new $@
165 generated += mach-shortcuts.h
167 before-compile += $(objpfx)mach-shortcuts.h
169 include Machrules
170 include ../Rules
173 # There is already a mach.h, so mach.defs generates mach_interface.h.
174 $(objpfx)mach/mach_interface.defs: $(mach-srcdir)/mach/mach.defs
175 ln $< $@ || cp $< $@
176 # There is already a memory_object.h,
177 # so memory_object.defs generates memory_object_user.h.
178 $(objpfx)mach/memory_object_user.defs: $(mach-srcdir)/mach/memory_object.defs
179 ln $< $@ || cp $< $@
181 ifdef objdir
182 vpath mach/mach_interface.defs $(objdir)
183 vpath mach/memory_object_user.defs $(objdir)
184 endif
186 # Be sure not to make these with implicit rules from foo.defs.
187 mach.h mach/memory_object.h: ;
189 # A gcc bug prevents the generated file from working properly,
190 # so we have one in the distribution for the time being.
191 generated += errsystems.c
192 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
193 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
194 gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
195 mv $@.n $@