1 # Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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 not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
21 # Look for header files in hurd/ under the top-level library source directory.
22 # Look for generated header files where they get created.
23 includes
+= -I
$(..
)hurd
-I
$(common-objpfx
)hurd
/
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
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
*
33 inhibit-unix-syscalls
= yes
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.
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/.)
46 hurd-objpfx
= $(common-objpfx
)hurd
/
48 # These are all the generated headers that <hurd.h> includes.
49 before-compile
+= $(patsubst %,$(hurd-objpfx
)hurd
/%.h
,auth io fs process
)
50 $(patsubst %,$(hurd-objpfx
)hurd
/%.
%,auth io fs process
):
51 $(MAKE
) -C
$(..
)hurd before-compile no_deps
=t
54 # Hurd profil.c includes this file, so give a rule to make it.
56 $(common-objpfx
)hurd
/..
/mach
/RPC_task_get_sampled_pcs.c
:
57 $(MAKE
) -C
$(..
)mach before-compile no_deps
=t
61 # Generate bits/errno.h from the section of the manual that lists all the errno
64 errno.texinfo
= $(..
)manual
/errno.texi
66 hurd
= $(..
)sysdeps
/mach
/hurd
69 ($(foreach h
,mach
/message.h \
72 device
/device_types.h
,\
73 echo
'#include <$h>';\
77 # We use the compiler to generate a list of absolute file names for
78 # the headers we want to search for Mach error codes, listed above (and
79 # incidentally, all other headers those include).
80 -include $(common-objpfx
)errnos.d
81 $(common-objpfx
)errnos.d
: $(mach-errnos-deps
)
83 $(CC
) $(CPPFLAGS
) -M
-x c
- | \
84 sed
$(sed-remove-objpfx
) -e
's,- *:,mach-errnos-deps :=,' \
85 -e
's,\.\./,$(..),g' > $@t
88 $(hurd
)/bits
/errno.h
: $(common-objpfx
)stamp-errnos
;
89 $(common-objpfx
)stamp-errnos
: $(hurd
)/errnos.awk
$(errno.texinfo
) \
90 $(mach-errnos-deps
) $(common-objpfx
)errnos.d
91 $(AWK
) -f
$^
> $(hurd
)/bits
/errno.h-tmp
92 # Make it unwritable so noone will edit it by mistake.
93 -chmod a-w
$(hurd
)/bits
/errno.h-tmp
94 $(move-if-change
) $(hurd
)/bits
/errno.h-tmp
$(hurd
)/bits
/errno.h
95 ifeq ($(with-cvs
),yes
)
96 test ! -d
$(hurd
)/CVS || \
97 (cd
$(hurd
) && cvs commit
-m
'Regenerated from $^' bits
/errno.h
)
101 common-generated
+= errnos.d stamp-errnos
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 -).
109 install-others
+= $(inst_libdir
)/libc.a
$(inst_libdir
)/libc_p.a
110 $(inst_libdir
)/libc.a
: $(hurd
)/libc-ldscript
$(+force); $(do-install
)
111 $(inst_libdir
)/libc_p.a
: $(hurd
)/libc_p-ldscript
$(+force); $(do-install
)
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.
133 rpcuserlibs
:= $(common-objpfx
)mach
/libmachuser.so \
134 $(common-objpfx
)hurd
/libhurduser.so
135 link-rpcuserlibs
:= $(rpcuserlibs
:%user.so
=%user-link.so
)
136 $(common-objpfx
)libc.so
: $(link-rpcuserlibs
)
137 rpath-dirs
+= mach hurd
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
144 ifeq (hurd
,$(subdir
))
145 lib-noranlib
: $(common-objpfx
)hurd
/libhurduser-link.so
148 $(link-rpcuserlibs
): %-link.so
: %_pic.a
149 $(build-module
) -nostdlib
-Wl
,-soname
=$(*F
).so
$($(*F
).so-version
)
151 # And get them into the libc.so ldscript.
152 $(inst_libdir
)/libc.so
: $(rpcuserlibs
)
154 # The RPC stubs from these libraries are needed in building the dynamic
155 # linker, too. It must be self-contained, so we link the needed PIC
156 # objects directly into the shared object.
158 $(objpfx
)librtld.os
: $(rpcuserlibs
:.so
=_pic.a
)
160 CFLAGS-dl-load.c
= -DEXTERNAL_MAP_FROM_FD
163 # We need these libs to link static programs in the libc source tree, too.
164 ifeq (yes
,$(build-static
))
165 link-libc-static
:= -Wl
,-\
( \
166 $(patsubst %,$(common-objpfx
)%.a
,\
167 libc mach
/libmachuser hurd
/libhurduser
) \
170 ifeq (yes
,$(build-shared
))
171 # We can try to link the programs with lib*_pic.a...
172 link-libc-static
:= $(link-libc
) -Wl
,-\
( \
173 $(patsubst %,$(common-objpfx
)%_pic.a
,\
174 libc mach
/libmachuser hurd
/libhurduser
) \
179 ifeq (hurd
, $(subdir
))
180 sysdep_routines
+= cthreads