2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / Makefile
blob8677515cd9a5eebec66d6417c5ee985b0822886b
1 # Copyright (C) 1993,94,95,96,97,98,99,2000,2001,2002, 2003, 2004
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, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
20 ifdef in-Makerules
22 # Look for header files in hurd/ under the top-level library source directory.
23 # Look for generated header files where they get created.
24 includes += -I$(..)hurd -I$(common-objpfx)hurd/
26 # We use the style `if (err = call(...))' a lot in the Hurd code,
27 # where we have a lot of functions that return zero or an errno code.
28 +cflags += -Wno-parentheses
30 # Do not use any assembly code from sysdeps/unix (and subdirectories).
31 # This bypasses all the system call stubs and uses any existing posix or
32 # generic C files instead.
33 inhibit-sysdep-asm += unix*
34 inhibit-unix-syscalls = yes
36 # Don't try to generate anything from the installed Unix system and its
37 # libraries. That is only of use when building for a Unix system, so as to
38 # be compatible with some existing binaries for that system.
39 inhibit-glue = yes
41 ifeq (,$(filter mach hurd,$(subdir)))
42 # Subdirectories other than hurd/ might use the generated Hurd headers.
43 # So make sure we get a chance to run in hurd/ to make them before all else.
44 # (But we don't want to do this in mach/, because hurd/ needs some things
45 # there, and we know mach/ doesn't need anything from hurd/.)
47 hurd-objpfx = $(common-objpfx)hurd/
49 # These are all the generated headers that <hurd.h> includes.
50 before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process)
51 $(patsubst %,$(hurd-objpfx)hurd/%.%,auth io fs process): \
52 $(common-objpfx)mach/mach-shortcuts.h
53 $(MAKE) -C $(..)hurd before-compile no_deps=t
54 endif
56 # Hurd profil.c includes this file, so give a rule to make it.
57 ifeq ($(subdir),gmon)
58 $(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c:
59 $(MAKE) -C $(..)mach before-compile no_deps=t
60 endif
63 # Generate bits/errno.h from the section of the manual that lists all the errno
64 # codes.
66 errno.texinfo = $(..)manual/errno.texi
68 hurd = $(..)sysdeps/mach/hurd
70 define mach-errno-h
71 ($(foreach h,mach/message.h \
72 mach/kern_return.h \
73 mach/mig_errors.h \
74 device/device_types.h,\
75 echo '#include <$h>';\
77 endef
79 # We use the compiler to generate a list of absolute file names for
80 # the headers we want to search for Mach error codes, listed above (and
81 # incidentally, all other headers those include).
82 -include $(common-objpfx)errnos.d
83 $(common-objpfx)errnos.d: $(mach-errnos-deps)
84 $(mach-errno-h) | \
85 $(CC) $(CFLAGS) $(CPPFLAGS) -M -x c - | \
86 sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \
87 -e 's, \.\./, $(..),g' > $@t
88 mv -f $@t $@
90 $(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ;
91 $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
92 $(mach-errnos-deps) $(common-objpfx)errnos.d
93 $(AWK) -f $^ > $(hurd)/bits/errno.h-tmp
94 # Make it unwritable so noone will edit it by mistake.
95 -chmod a-w $(hurd)/bits/errno.h-tmp
96 $(move-if-change) $(hurd)/bits/errno.h-tmp $(hurd)/bits/errno.h
97 ifeq ($(with-cvs),yes)
98 test ! -d $(hurd)/CVS || \
99 (cd $(hurd) && cvs commit -m'Regenerated from $^' bits/errno.h)
100 endif
101 touch $@
103 common-generated += errnos.d stamp-errnos
105 # We install the real libc.a as libcrt.a and as libc.a we install a linker
106 # script which does -( -lcrt -lmachuser -lhurduser -).
108 libc-name = crt
110 ifeq (,$(subdir))
111 install-others += $(inst_libdir)/libc.a
112 $(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install)
113 ifeq (yes,$(build-profile))
114 install-others += $(inst_libdir)/libc_p.a
115 $(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install)
116 endif
117 endif
119 # Make sure these are used to build the libc.so shared object too. There
120 # is a circular dependency between each of these shared objects and libc
121 # (many high-level libc functions call stubs, stubs call low-level libc
122 # functions like memcpy and mach_msg). This works out fine at run time
123 # (all the objects are loaded before resolving their symbols, so these
124 # interdependencies are fine). But to create the shared objects we must
125 # link them one at a time; since each needs one or both of the others to
126 # produce its DT_NEEDED entries and to assign its undefined symbols the
127 # right symbol versions, we can't do any of them before the others! To
128 # get around this, we link each lib*user.so shared object twice. First,
129 # we link an object without reference to libc.so (since we haven't linked
130 # libc.so yet), so it lacks a DT_NEEDED record for the libc soname it
131 # depends on, and its undefined symbol references lack the symbol version
132 # assignments they should have. We will use this shared object solely to
133 # link libc.so against it; that gives libc.so the proper DT_NEEDED record,
134 # and symbol versions assignments (if the lib*user.so object is using them).
135 # Finally we link a second version of the same lib*user.so shared object,
136 # this time linked normally against libc so it gets a proper DT_NEEDED
137 # record and symbol version set; this one can be installed for run-time use.
138 rpcuserlibs := $(common-objpfx)mach/libmachuser.so \
139 $(common-objpfx)hurd/libhurduser.so
140 link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so)
141 $(common-objpfx)libc.so: $(link-rpcuserlibs)
142 rpath-dirs += mach hurd
144 # Make sure the `lib' pass builds the dummy shared objects so
145 # we can link libc against them.
146 ifeq (mach,$(subdir))
147 lib-noranlib: $(common-objpfx)mach/libmachuser-link.so
148 endif
149 ifeq (hurd,$(subdir))
150 lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so
151 endif
153 $(link-rpcuserlibs): %-link.so: %_pic.a
154 # These shared objects are just for the purpose of linking libc,
155 # so they don't need abi-note.o linked into them.
156 $(build-shlib-helper) \
157 -nostdlib -o $@ \
158 -Wl,-soname=$(*F).so$($(*F).so-version) \
159 $(build-shlib-objlist)
160 libmachuser-link.so-no-z-defs = yes
161 libhurduser-link.so-no-z-defs = yes
163 # And get them into the libc.so ldscript.
164 $(inst_libdir)/libc.so: $(rpcuserlibs)
166 # The RPC stubs from these libraries are needed in building the dynamic
167 # linker, too. It must be self-contained, so we link the needed PIC
168 # objects directly into the shared object.
169 ifeq (elf,$(subdir))
170 $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
172 CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
173 endif
175 # We need these libs to link static programs in the libc source tree, too.
176 ifeq (yes,$(build-static))
177 link-libc-static := -Wl,-\( \
178 $(patsubst %,$(common-objpfx)%.a,\
179 libc mach/libmachuser hurd/libhurduser) \
180 $(static-gnulib) -Wl,-\)
181 else
182 ifeq (yes,$(build-shared))
183 # We can try to link the programs with lib*_pic.a...
184 link-libc-static := $(link-libc) -Wl,-\( \
185 $(patsubst %,$(common-objpfx)%_pic.a,\
186 libc mach/libmachuser hurd/libhurduser) \
187 $(static-gnulib) -Wl,-\)
188 endif
189 endif
191 ifeq ($(subdir),csu)
193 extra-objs += static-start.o
195 # We need special startup code for statically linked binaries.
196 $(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
197 $(link-relocatable)
199 endif
201 ifeq (hurd, $(subdir))
202 sysdep_routines += cthreads
203 endif
205 ifeq ($(subdir),sunrpc)
206 sysdep_headers += nfs/nfs.h
207 endif
209 endif # in-Makerules