1 # Copyright (C) 1993,94,95,96,97,98,99,2000,2001,2002,2003,2004,2009,2011
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
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.
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
56 # Hurd profil.c includes this file, so give a rule to make it.
58 $(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c:
59 $(MAKE) -C $(..)mach before-compile no_deps=t
63 # Generate bits/errno.h from the section of the manual that lists all the errno
66 errno.texinfo = $(..)manual/errno.texi
68 hurd = $(..)sysdeps/mach/hurd
71 ($(foreach h,mach/message.h \
74 device/device_types.h,\
75 echo '#include <$h>';\
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)
85 $(CC) $(CFLAGS) $(CPPFLAGS) -M -x c - | \
86 sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \
87 -e 's, \.\./, $(..),g' > $@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
99 common-generated += errnos.d stamp-errnos
101 # We install the real libc.a as libcrt.a and as libc.a we install a linker
102 # script which does -( -lcrt -lmachuser -lhurduser -).
107 install-others += $(inst_libdir)/libc.a
108 $(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install)
109 ifeq (yes,$(build-profile))
110 install-others += $(inst_libdir)/libc_p.a
111 $(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install)
115 # Make sure these are used to build the libc.so shared object too. There
116 # is a circular dependency between each of these shared objects and libc
117 # (many high-level libc functions call stubs, stubs call low-level libc
118 # functions like memcpy and mach_msg). This works out fine at run time
119 # (all the objects are loaded before resolving their symbols, so these
120 # interdependencies are fine). But to create the shared objects we must
121 # link them one at a time; since each needs one or both of the others to
122 # produce its DT_NEEDED entries and to assign its undefined symbols the
123 # right symbol versions, we can't do any of them before the others! To
124 # get around this, we link each lib*user.so shared object twice. First,
125 # we link an object without reference to libc.so (since we haven't linked
126 # libc.so yet), so it lacks a DT_NEEDED record for the libc soname it
127 # depends on, and its undefined symbol references lack the symbol version
128 # assignments they should have. We will use this shared object solely to
129 # link libc.so against it; that gives libc.so the proper DT_NEEDED record,
130 # and symbol versions assignments (if the lib*user.so object is using them).
131 # Finally we link a second version of the same lib*user.so shared object,
132 # this time linked normally against libc so it gets a proper DT_NEEDED
133 # record and symbol version set; this one can be installed for run-time use.
134 rpcuserlibs := $(common-objpfx)mach/libmachuser.so \
135 $(common-objpfx)hurd/libhurduser.so
136 link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so)
137 $(common-objpfx)libc.so: $(link-rpcuserlibs)
138 rpath-dirs += mach hurd
140 # Make sure the `lib' pass builds the dummy shared objects so
141 # we can link libc against them.
142 ifeq (mach,$(subdir))
143 lib-noranlib: $(common-objpfx)mach/libmachuser-link.so
145 ifeq (hurd,$(subdir))
146 lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so
149 $(link-rpcuserlibs): %-link.so: %_pic.a
150 # These shared objects are just for the purpose of linking libc,
151 # so they don't need abi-note.o linked into them.
152 $(build-shlib-helper) \
154 -Wl,-soname=$(*F).so$($(*F).so-version) \
155 $(build-shlib-objlist)
156 libmachuser-link.so-no-z-defs = yes
157 libhurduser-link.so-no-z-defs = yes
159 # And get them into the libc.so ldscript.
160 $(inst_libdir)/libc.so: $(rpcuserlibs)
162 # The RPC stubs from these libraries are needed in building the dynamic
163 # linker, too. It must be self-contained, so we link the needed PIC
164 # objects directly into the shared object.
166 $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
168 CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
171 # We need these libs to link static programs in the libc source tree, too.
172 ifeq (yes,$(build-static))
173 link-libc-static := -Wl,-\( \
174 $(patsubst %,$(common-objpfx)%.a,\
175 libc mach/libmachuser hurd/libhurduser) \
176 $(static-gnulib) -Wl,-\)
178 ifeq (yes,$(build-shared))
179 # We can try to link the programs with lib*_pic.a...
180 link-libc-static := $(link-libc) -Wl,-\( \
181 $(patsubst %,$(common-objpfx)%_pic.a,\
182 libc mach/libmachuser hurd/libhurduser) \
183 $(static-gnulib) -Wl,-\)
189 extra-objs += static-start.o
191 # We need special startup code for statically linked binaries.
192 $(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
197 ifeq (hurd, $(subdir))
198 sysdep_routines += cthreads
201 ifeq ($(subdir),sunrpc)
202 sysdep_headers += nfs/nfs.h
205 ifeq ($(subdir),socket)
206 sysdep_headers += net/ethernet.h net/if_arp.h net/if_ether.h net/if_ppp.h \