]>
Commit | Line | Data |
---|---|---|
2119dcfa | 1 | # Copyright (C) 1993-2004,2009,2011,2012 Free Software Foundation, Inc. |
28f540f4 RM |
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 | |
41bdb6e2 AJ |
5 | # modify it under the terms of the GNU Lesser General Public |
6 | # License as published by the Free Software Foundation; either | |
7 | # version 2.1 of the License, or (at your option) any later version. | |
28f540f4 RM |
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 | |
41bdb6e2 | 12 | # Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 AJ |
14 | # You should have received a copy of the GNU Lesser General Public |
15 | # License along with the GNU C Library; if not, write to the Free | |
16 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | # 02111-1307 USA. | |
28f540f4 | 18 | |
28f540f4 RM |
19 | ifdef in-Makerules |
20 | ||
28f540f4 | 21 | # Look for header files in hurd/ under the top-level library source directory. |
757dc096 TBB |
22 | # Look for generated header files where they get created. |
23 | includes += -I$(..)hurd -I$(common-objpfx)hurd/ | |
28f540f4 | 24 | |
7d25696a RM |
25 | # We use the style `if (err = call(...))' a lot in the Hurd code, |
26 | # where we have a lot of functions that return zero or an errno code. | |
27 | +cflags += -Wno-parentheses | |
28 | ||
28f540f4 RM |
29 | # Do not use any assembly code from sysdeps/unix (and subdirectories). |
30 | # This bypasses all the system call stubs and uses any existing posix or | |
31 | # generic C files instead. | |
32 | inhibit-sysdep-asm += unix* | |
4ca84cff | 33 | inhibit-unix-syscalls = yes |
28f540f4 RM |
34 | |
35 | # Don't try to generate anything from the installed Unix system and its | |
36 | # libraries. That is only of use when building for a Unix system, so as to | |
37 | # be compatible with some existing binaries for that system. | |
38 | inhibit-glue = yes | |
39 | ||
28f540f4 RM |
40 | ifeq (,$(filter mach hurd,$(subdir))) |
41 | # Subdirectories other than hurd/ might use the generated Hurd headers. | |
42 | # So make sure we get a chance to run in hurd/ to make them before all else. | |
43 | # (But we don't want to do this in mach/, because hurd/ needs some things | |
44 | # there, and we know mach/ doesn't need anything from hurd/.) | |
45 | ||
6e953631 | 46 | hurd-objpfx = $(common-objpfx)hurd/ |
28f540f4 RM |
47 | |
48 | # These are all the generated headers that <hurd.h> includes. | |
924840c5 | 49 | before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process) |
c06b8d60 RM |
50 | $(patsubst %,$(hurd-objpfx)hurd/%.%,auth io fs process): \ |
51 | $(common-objpfx)mach/mach-shortcuts.h | |
bd78530f | 52 | $(MAKE) -C $(..)hurd before-compile no_deps=t |
28f540f4 | 53 | endif |
924840c5 | 54 | |
0413b54c UD |
55 | # Hurd profil.c includes this file, so give a rule to make it. |
56 | ifeq ($(subdir),gmon) | |
57 | $(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c: | |
bd78530f | 58 | $(MAKE) -C $(..)mach before-compile no_deps=t |
0413b54c UD |
59 | endif |
60 | ||
28f540f4 | 61 | \f |
75d0cab2 | 62 | # Generate bits/errno.h from the section of the manual that lists all the errno |
b25ae9c6 | 63 | # codes. |
28f540f4 RM |
64 | |
65 | errno.texinfo = $(..)manual/errno.texi | |
66 | ||
67 | hurd = $(..)sysdeps/mach/hurd | |
68 | ||
aa1075ea RM |
69 | define mach-errno-h |
70 | ($(foreach h,mach/message.h \ | |
71 | mach/kern_return.h \ | |
72 | mach/mig_errors.h \ | |
73 | device/device_types.h,\ | |
74 | echo '#include <$h>';\ | |
75 | )) | |
76 | endef | |
77 | ||
78 | # We use the compiler to generate a list of absolute file names for | |
79 | # the headers we want to search for Mach error codes, listed above (and | |
80 | # incidentally, all other headers those include). | |
81 | -include $(common-objpfx)errnos.d | |
82 | $(common-objpfx)errnos.d: $(mach-errnos-deps) | |
83 | $(mach-errno-h) | \ | |
0dc87bc6 | 84 | $(CC) $(CFLAGS) $(CPPFLAGS) -M -x c - | \ |
d7bca0d3 | 85 | sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \ |
224a12bc | 86 | -e 's, \.\./, $(..),g' > $@t |
aa1075ea RM |
87 | mv -f $@t $@ |
88 | ||
75d0cab2 | 89 | $(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ; |
aa1075ea | 90 | $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \ |
46db1cb0 | 91 | $(mach-errnos-deps) $(common-objpfx)errnos.d |
75d0cab2 | 92 | $(AWK) -f $^ > $(hurd)/bits/errno.h-tmp |
28f540f4 | 93 | # Make it unwritable so noone will edit it by mistake. |
75d0cab2 RM |
94 | -chmod a-w $(hurd)/bits/errno.h-tmp |
95 | $(move-if-change) $(hurd)/bits/errno.h-tmp $(hurd)/bits/errno.h | |
28f540f4 | 96 | touch $@ |
924840c5 TBB |
97 | |
98 | common-generated += errnos.d stamp-errnos | |
28f540f4 RM |
99 | \f |
100 | # We install the real libc.a as libcrt.a and as libc.a we install a linker | |
101 | # script which does -( -lcrt -lmachuser -lhurduser -). | |
102 | ||
103 | libc-name = crt | |
104 | ||
105 | ifeq (,$(subdir)) | |
3635e76a | 106 | install-others += $(inst_libdir)/libc.a |
73237de3 | 107 | $(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install) |
3635e76a RM |
108 | ifeq (yes,$(build-profile)) |
109 | install-others += $(inst_libdir)/libc_p.a | |
73237de3 | 110 | $(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install) |
28f540f4 | 111 | endif |
3635e76a | 112 | endif |
11872325 | 113 | |
0702b5f4 RM |
114 | # Make sure these are used to build the libc.so shared object too. There |
115 | # is a circular dependency between each of these shared objects and libc | |
116 | # (many high-level libc functions call stubs, stubs call low-level libc | |
117 | # functions like memcpy and mach_msg). This works out fine at run time | |
118 | # (all the objects are loaded before resolving their symbols, so these | |
119 | # interdependencies are fine). But to create the shared objects we must | |
120 | # link them one at a time; since each needs one or both of the others to | |
121 | # produce its DT_NEEDED entries and to assign its undefined symbols the | |
122 | # right symbol versions, we can't do any of them before the others! To | |
123 | # get around this, we link each lib*user.so shared object twice. First, | |
124 | # we link an object without reference to libc.so (since we haven't linked | |
125 | # libc.so yet), so it lacks a DT_NEEDED record for the libc soname it | |
126 | # depends on, and its undefined symbol references lack the symbol version | |
127 | # assignments they should have. We will use this shared object solely to | |
128 | # link libc.so against it; that gives libc.so the proper DT_NEEDED record, | |
129 | # and symbol versions assignments (if the lib*user.so object is using them). | |
130 | # Finally we link a second version of the same lib*user.so shared object, | |
131 | # this time linked normally against libc so it gets a proper DT_NEEDED | |
132 | # record and symbol version set; this one can be installed for run-time use. | |
6e953631 UD |
133 | rpcuserlibs := $(common-objpfx)mach/libmachuser.so \ |
134 | $(common-objpfx)hurd/libhurduser.so | |
0702b5f4 | 135 | link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so) |
5407f442 | 136 | $(common-objpfx)libc.so: $(link-rpcuserlibs) |
6598ac30 | 137 | rpath-dirs += mach hurd |
c7fd2f47 | 138 | |
5407f442 RM |
139 | # Make sure the `lib' pass builds the dummy shared objects so |
140 | # we can link libc against them. | |
141 | ifeq (mach,$(subdir)) | |
142 | lib-noranlib: $(common-objpfx)mach/libmachuser-link.so | |
143 | endif | |
144 | ifeq (hurd,$(subdir)) | |
145 | lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so | |
146 | endif | |
147 | ||
0702b5f4 | 148 | $(link-rpcuserlibs): %-link.so: %_pic.a |
ba2c68f1 RM |
149 | # These shared objects are just for the purpose of linking libc, |
150 | # so they don't need abi-note.o linked into them. | |
c7414a8e RM |
151 | $(build-shlib-helper) \ |
152 | -nostdlib -o $@ \ | |
e17f3859 | 153 | -Wl,-soname=$(*F).so$($(*F).so-version) \ |
c7414a8e | 154 | $(build-shlib-objlist) |
f1c5213d RM |
155 | libmachuser-link.so-no-z-defs = yes |
156 | libhurduser-link.so-no-z-defs = yes | |
0702b5f4 | 157 | |
8a523922 | 158 | # And get them into the libc.so ldscript. |
8d57beea | 159 | $(inst_libdir)/libc.so: $(rpcuserlibs) |
8a523922 | 160 | |
c7fd2f47 RM |
161 | # The RPC stubs from these libraries are needed in building the dynamic |
162 | # linker, too. It must be self-contained, so we link the needed PIC | |
163 | # objects directly into the shared object. | |
164 | ifeq (elf,$(subdir)) | |
f1c5213d | 165 | $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a) |
f787edde UD |
166 | |
167 | CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD | |
c7fd2f47 | 168 | endif |
c82e6116 RM |
169 | |
170 | # We need these libs to link static programs in the libc source tree, too. | |
c82e6116 RM |
171 | link-libc-static := -Wl,-\( \ |
172 | $(patsubst %,$(common-objpfx)%.a,\ | |
173 | libc mach/libmachuser hurd/libhurduser) \ | |
9d24cfb3 | 174 | $(static-gnulib) -Wl,-\) |
d3b82fcc RM |
175 | \f |
176 | ifeq ($(subdir),csu) | |
177 | ||
178 | extra-objs += static-start.o | |
179 | ||
180 | # We need special startup code for statically linked binaries. | |
181 | $(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o | |
182 | $(link-relocatable) | |
183 | ||
c82e6116 | 184 | endif |
28f540f4 | 185 | \f |
a7ab2023 UD |
186 | ifeq (hurd, $(subdir)) |
187 | sysdep_routines += cthreads | |
188 | endif | |
28f540f4 | 189 | |
50a25edf RM |
190 | ifeq ($(subdir),sunrpc) |
191 | sysdep_headers += nfs/nfs.h | |
192 | endif | |
193 | ||
c90c1e1c RM |
194 | ifeq ($(subdir),socket) |
195 | sysdep_headers += net/ethernet.h net/if_arp.h net/if_ether.h net/if_ppp.h \ | |
196 | net/route.h | |
197 | endif | |
198 | ||
28f540f4 | 199 | endif # in-Makerules |