* Makerules (distinfo-vars): Add sysdep_routines.
[platform/upstream/glibc.git] / mach / Makefile
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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.
18
19 subdir := mach
20
21 all:
22
23 # Some things below (but before including Rules) use configuration variables.
24 include ../Makeconfig
25
26
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 \
46                     )\
47                    $(addprefix device/,device device_request)
48 # We produce mach_interface.h from mach.defs because there is already a
49 # <mach/mach.h> that is not the interface header (thanks CMU).
50 mach_interface.defs = mach.defs
51 server-interfaces := mach/exc
52 tests := hello
53 # It is important that we do not use the wildcard function to expand
54 # `err_*.sub'.  Leaving the wildcard allows Make-dist to find all matching
55 # files in all sysdep directories.
56 distribute += Machrules syscalls.awk shortcut.awk \
57               errorlib.h err_*.sub
58
59
60 # Clear any environment value.
61 generated =
62 \f
63 # Define mach-syscalls and sysno-*.
64 ifndef no_deps
65 ifndef inhibit_mach_syscalls
66 include $(objpfx)mach-syscalls.mk
67 endif
68 endif
69 $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
70 # Go kludges!!!
71         echo '#include <mach/syscall_sw.h>' | \
72         DEPENDENCIES_OUTPUT='$@-dep $@' \
73         $(CC) $(CPPFLAGS) -E -x c-header - \
74               -D_MACH_`echo $(base-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
75         sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
76         | awk -f $< > $@-new
77         cat $@-dep >> $@-new; rm -f $@-dep
78         mv $@-new $@
79 generated += mach-syscalls.mk
80
81 ifndef mach-syscalls
82 # We cannot make the deps properly until we know how to make the system
83 # call functions, and for that we must know what they all are.
84 no_deps=t
85 else
86 $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
87         (echo '#include <sysdep.h>'; \
88          echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))'; \
89          echo 'weak_alias (__$*, $*)') > $@-new
90          mv $@-new $@
91 generated += $(mach-syscalls:=.S)
92 endif   # mach-syscalls
93
94 # syscall_device_writev_request has no RPC equivalent.
95 mach-shortcuts := $(filter-out device_writev_request,\
96                   $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))))
97
98 ifndef mach-shortcuts
99 # Forget about mach_interface.defs for this run.  On the next run,
100 # $(mach-shortcuts) will be set, and that will change how
101 # mach_interface.defs is processed: it will get the -D flags below.
102 user-interfaces := $(filter-out mach/mach_interface \
103                                 mach/mach_port mach/mach_host mach/mach4 \
104                                 device/device_request,\
105                                 $(user-interfaces))
106 endif
107
108 # Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
109 migdefines += $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
110 mach/mach_interface.uh mach/mach_port.uh: $(objpfx)mach-syscalls.mk
111
112 ifdef mach-shortcuts
113 $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
114                                                 $(objpfx)RPC_%_rpc.c
115         gawk -v alias=$* -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
116              -f $^ > $@-new
117         mv $@-new $@
118 generated += $(mach-shortcuts:%=%.c)
119 endif   # mach-shortcuts
120
121 # Generate mach-shortcuts.h, which will contain the prototypes for the
122 # shortcutted kernel RPC functions.
123 $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
124                            $(objpfx)mach/mach_port.h
125 # The first line gets us one paragraph per line, with @s separating real lines.
126 # The second line selects paragraphs for the shortcutted functions.
127 # The third line removes `_rpc' from the names and rerealifies the lines.
128         cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
129         | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
130         | sed 's/_rpc//g' | tr @ \\012 > $@-new
131         mv $@-new $@
132 generated += mach-shortcuts.h
133
134 before-compile += $(objpfx)mach-shortcuts.h
135 \f
136 include Machrules
137 include ../Rules
138
139
140 # A gcc bug prevents the generated file from working properly,
141 # so we have one in the distribution for the time being.
142 generated += errsystems.c
143 $(objpfx)errsystems.c: errsystems.awk err_*.sub \
144                        $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
145         gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
146         mv $@.n $@