]>
Commit | Line | Data |
---|---|---|
1 | # Copyright (C) 1993-2019 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 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. | |
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 | # Lesser General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU Lesser General Public | |
15 | # License along with the GNU C Library; if not, see | |
16 | # <http://www.gnu.org/licenses/>. | |
17 | ||
18 | ifdef in-Makerules | |
19 | ||
20 | # Look for header files in hurd/ under the top-level library source directory. | |
21 | # Look for generated header files where they get created. | |
22 | includes += -I$(..)hurd -I$(common-objpfx)hurd/ | |
23 | ||
24 | # We use the style `if (err = call(...))' a lot in the Hurd code, | |
25 | # where we have a lot of functions that return zero or an errno code. | |
26 | +cflags += -Wno-parentheses | |
27 | ||
28 | # Do not use any assembly code from sysdeps/unix (and subdirectories). | |
29 | # This bypasses all the system call stubs and uses any existing posix or | |
30 | # generic C files instead. | |
31 | inhibit-sysdep-asm += unix.* | |
32 | inhibit-unix-syscalls = yes | |
33 | ||
34 | # Don't try to generate anything from the installed Unix system and its | |
35 | # libraries. That is only of use when building for a Unix system, so as to | |
36 | # be compatible with some existing binaries for that system. | |
37 | inhibit-glue = yes | |
38 | ||
39 | ifeq (,$(filter mach hurd,$(subdir))) | |
40 | # Subdirectories other than hurd/ might use the generated Hurd headers. | |
41 | # So make sure we get a chance to run in hurd/ to make them before all else. | |
42 | # (But we don't want to do this in mach/, because hurd/ needs some things | |
43 | # there, and we know mach/ doesn't need anything from hurd/.) | |
44 | ||
45 | hurd-objpfx = $(common-objpfx)hurd/ | |
46 | ||
47 | # These are all the generated headers that <hurd.h> includes. | |
48 | before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process) | |
49 | $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process): hurd-before-compile | |
50 | .PHONY: hurd-before-compile | |
51 | hurd-before-compile: $(common-objpfx)mach/mach-shortcuts.h | |
52 | $(MAKE) -C $(..)hurd subdir=hurd before-compile no_deps=t | |
53 | endif | |
54 | ||
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: | |
58 | $(MAKE) -C $(..)mach subdir=mach before-compile no_deps=t | |
59 | endif | |
60 | ||
61 | \f | |
62 | # Generate bits/errno.h from the section of the manual that lists all the errno | |
63 | # codes. | |
64 | ||
65 | errno.texinfo = $(..)manual/errno.texi | |
66 | ||
67 | hurd = $(..)sysdeps/mach/hurd | |
68 | ||
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) | \ | |
84 | $(CC) $(CFLAGS) \ | |
85 | $(subst -include $(common-objpfx)libc-modules.h,,$(CPPFLAGS)) \ | |
86 | -M -x c - | \ | |
87 | sed $(sed-remove-objpfx) -e 's,- *:,mach-errnos-deps :=,' \ | |
88 | -e 's, \.\./, $(..),g' > $@t | |
89 | mv -f $@t $@ | |
90 | ||
91 | $(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ; | |
92 | $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \ | |
93 | $(mach-errnos-deps) $(common-objpfx)errnos.d | |
94 | mkdir -p $(hurd-objpfx)bits | |
95 | $(AWK) -f $^ > $(hurd-objpfx)bits/errno.h-tmp | |
96 | # Make it unwritable so noone will edit it by mistake. | |
97 | -chmod a-w $(hurd-objpfx)bits/errno.h-tmp | |
98 | $(move-if-change) $(hurd-objpfx)bits/errno.h-tmp $(hurd)/bits/errno.h | |
99 | touch $@ | |
100 | ||
101 | common-generated += errnos.d stamp-errnos | |
102 | \f | |
103 | # We install the real libc.a as libcrt.a and as libc.a we install a linker | |
104 | # script which does -( -lcrt -lmachuser -lhurduser -). | |
105 | ||
106 | libc-name = crt | |
107 | ||
108 | ifeq (,$(subdir)) | |
109 | install-others += $(inst_libdir)/libc.a | |
110 | $(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install) | |
111 | ifeq (yes,$(build-profile)) | |
112 | install-others += $(inst_libdir)/libc_p.a | |
113 | $(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install) | |
114 | endif | |
115 | endif | |
116 | ||
117 | # Make sure these are used to build the libc.so shared object too. There | |
118 | # is a circular dependency between each of these shared objects and libc | |
119 | # (many high-level libc functions call stubs, stubs call low-level libc | |
120 | # functions like memcpy and mach_msg). This works out fine at run time | |
121 | # (all the objects are loaded before resolving their symbols, so these | |
122 | # interdependencies are fine). But to create the shared objects we must | |
123 | # link them one at a time; since each needs one or both of the others to | |
124 | # produce its DT_NEEDED entries and to assign its undefined symbols the | |
125 | # right symbol versions, we can't do any of them before the others! To | |
126 | # get around this, we link each lib*user.so shared object twice. First, | |
127 | # we link an object without reference to libc.so (since we haven't linked | |
128 | # libc.so yet), so it lacks a DT_NEEDED record for the libc soname it | |
129 | # depends on, and its undefined symbol references lack the symbol version | |
130 | # assignments they should have. We will use this shared object solely to | |
131 | # link libc.so against it; that gives libc.so the proper DT_NEEDED record, | |
132 | # and symbol versions assignments (if the lib*user.so object is using them). | |
133 | # Finally we link a second version of the same lib*user.so shared object, | |
134 | # this time linked normally against libc so it gets a proper DT_NEEDED | |
135 | # record and symbol version set; this one can be installed for run-time use. | |
136 | rpcuserlibs := $(common-objpfx)mach/libmachuser.so \ | |
137 | $(common-objpfx)hurd/libhurduser.so | |
138 | link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so) | |
139 | $(common-objpfx)libc.so: $(link-rpcuserlibs) | |
140 | $(common-objpfx)linkobj/libc.so: $(link-rpcuserlibs) | |
141 | rpath-dirs += mach hurd | |
142 | ||
143 | # Make sure the `lib' pass builds the dummy shared objects so | |
144 | # we can link libc against them. | |
145 | ifeq (mach,$(subdir)) | |
146 | lib-noranlib: $(common-objpfx)mach/libmachuser-link.so | |
147 | endif | |
148 | ifeq (hurd,$(subdir)) | |
149 | lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so | |
150 | endif | |
151 | ||
152 | $(link-rpcuserlibs): %-link.so: %_pic.a | |
153 | # These shared objects are just for the purpose of linking libc, | |
154 | # so they don't need abi-note.o linked into them. | |
155 | $(build-shlib-helper) \ | |
156 | -nostdlib -o $@ \ | |
157 | -Wl,-soname=$(*F).so$($(*F).so-version) \ | |
158 | $(build-shlib-objlist) | |
159 | libmachuser-link.so-no-z-defs = yes | |
160 | libhurduser-link.so-no-z-defs = yes | |
161 | ||
162 | # And get them into the libc.so ldscript. | |
163 | $(inst_libdir)/libc.so: $(rpcuserlibs) | |
164 | ||
165 | # The RPC stubs from these libraries are needed in building the dynamic | |
166 | # linker, too. It must be self-contained, so we link the needed PIC | |
167 | # objects directly into the shared object. | |
168 | ifeq (elf,$(subdir)) | |
169 | $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a) | |
170 | ||
171 | CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD | |
172 | endif | |
173 | ||
174 | # Override the generic Makeconfig values so we link against the RPC libs. | |
175 | link-libc-static := -Wl,--start-group \ | |
176 | $(patsubst %,$(common-objpfx)%.a,\ | |
177 | libc mach/libmachuser hurd/libhurduser) \ | |
178 | $(static-gnulib) -Wl,--end-group | |
179 | link-libc-static-tests := -Wl,--start-group \ | |
180 | $(patsubst %,$(common-objpfx)%.a,\ | |
181 | libc mach/libmachuser hurd/libhurduser) \ | |
182 | $(static-gnulib-tests) -Wl,--end-group | |
183 | \f | |
184 | ifeq ($(subdir),csu) | |
185 | ||
186 | extra-objs += static-start.o | |
187 | ||
188 | # We need special startup code for statically linked binaries. | |
189 | $(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o | |
190 | $(link-relocatable) | |
191 | ||
192 | endif | |
193 | \f | |
194 | ifeq (hurd, $(subdir)) | |
195 | sysdep_routines += cthreads | |
196 | endif | |
197 | ||
198 | ifeq (io, $(subdir)) | |
199 | sysdep_routines += f_setlk | |
200 | endif | |
201 | ||
202 | ifeq ($(subdir),sunrpc) | |
203 | sysdep_headers += nfs/nfs.h | |
204 | endif | |
205 | ||
206 | ifeq ($(subdir),socket) | |
207 | sysdep_headers += net/ethernet.h net/if_arp.h net/if_ether.h net/route.h | |
208 | endif | |
209 | ||
210 | ifeq ($(subdir),nis) | |
211 | CFLAGS-ypclnt.c += -DUSE_BINDINGDIR=1 | |
212 | endif | |
213 | ||
214 | endif # in-Makerules |