* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): If started by
[glibc.git] / mach / Makefile
blob4595628e8ad0d424097e127875df16ec327703b7
1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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 $(config-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 $(config-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 inhibit_mach_syscalls
102 include $(objpfx)mach-syscalls.mk
103 endif
104 $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk
105 # Go kludges!!!
106 sed -n -e '/Unix server implement them/,$$d' \
107 -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
108 < $< | awk -f $(word 2,$^) > $@-new
109 mv $@-new $@
110 generated += mach-syscalls.mk
112 ifndef mach-syscalls
113 # We cannot make the deps properly until we know how to make the system
114 # call functions, and for that we must know what they all are.
115 no_deps=t
116 else
117 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
118 (echo '#include <sysdep.h>'; \
119 echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))'; \
120 echo 'weak_alias (__$*, $*)') > $@-new
121 mv $@-new $@
122 generated += $(mach-syscalls:=.S)
123 endif # mach-syscalls
125 # syscall_device_writev_request has no RPC equivalent.
126 mach-shortcuts := $(filter-out device_writev_request,\
127 $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
129 ifndef mach-shortcuts
130 # Forget about mach_interface.defs for this run. On the next run,
131 # $(mach-shortcuts) will be set, and that will change how
132 # mach_interface.defs is processed: it will get the -D flags below.
133 user-interfaces := $(filter-out mach/mach_interface \
134 mach/mach_port mach/mach_host mach/mach4 \
135 device/device_request,\
136 $(user-interfaces))
137 endif
139 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
140 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
141 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
143 ifdef mach-shortcuts
144 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
145 $(objpfx)RPC_%_rpc.c
146 gawk -v alias=$* -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
147 -f $^ > $@-new
148 mv $@-new $@
149 generated += $(mach-shortcuts:%=%.c)
150 endif # mach-shortcuts
152 # Generate mach-shortcuts.h, which will contain the prototypes for the
153 # shortcutted kernel RPC functions.
154 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
155 $(objpfx)mach/mach_port.h
156 # The first line gets us one paragraph per line, with @s separating real lines.
157 # The second line selects paragraphs for the shortcutted functions.
158 # The third line removes `_rpc' from the names and rerealifies the lines.
159 cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
160 | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
161 | sed 's/_rpc//g' | tr @ \\012 > $@-new
162 mv $@-new $@
163 generated += mach-shortcuts.h
165 before-compile += $(objpfx)mach-shortcuts.h
167 include Machrules
168 include ../Rules
171 # There is already a mach.h, so mach.defs generates mach_interface.h.
172 $(objpfx)mach/mach_interface.defs: $(mach-srcdir)/mach/mach.defs
173 ln $< $@ || cp $< $@
174 # There is already a memory_object.h,
175 # so memory_object.defs generates memory_object_user.h.
176 $(objpfx)mach/memory_object_user.defs: $(mach-srcdir)/mach/memory_object.defs
177 ln $< $@ || cp $< $@
179 ifdef objdir
180 vpath mach/mach_interface.defs $(objdir)
181 vpath mach/memory_object_user.defs $(objdir)
182 endif
184 # Be sure not to make these with implicit rules from foo.defs.
185 mach.h mach/memory_object.h: ;
187 ifneq (,)
188 # A gcc bug prevents the generated file from working properly,
189 # so we have one in the distribution for the time being.
190 generated += errsystems.c
191 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
192 $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
193 gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
194 mv $@.n $@
195 endif