* sysdeps/m68k/fpu/bits/fenv.h (fenv_t): Prepend __ to member
[glibc/pb-stable.git] / elf / Makefile
blob6c526437e256453bc7fb73011811f2b5010460cb
1 # Copyright (C) 1995, 1996, 1997, 1998, 1999 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 as
6 # published by the Free Software Foundation; either version 2 of the
7 # 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.
19 # Makefile for elf subdirectory of GNU C Library.
21 subdir := elf
23 headers = elf.h bits/elfclass.h bits/dlfcn.h link.h dlfcn.h
24 routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
25 dl-addr enbl-secure dl-profstub dl-origin
27 # The core dynamic linking functions are in libc for the static and
28 # profiled libraries.
29 dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
30 runtime error init fini debug misc \
31 version profile)
32 # But they are absent from the shared libc, because that code is in ld.so.
33 elide-routines.os = $(dl-routines) dl-support enbl-secure
35 # ld.so uses those routines, plus some special stuff for being the program
36 # interpreter and operating independent of libc.
37 rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
38 distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
39 dl-hash.h soinit.c sofini.c ldd.bash.in eval.c \
40 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
41 dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
42 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
43 testobj6.c testobj1_1.c failobj.c do-lookup.h \
44 gen-trusted-dirs.awk
46 include ../Makeconfig
48 extra-libs = libdl
49 extra-libs-others = $(extra-libs)
50 libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
51 ifeq ($(versioning),yes)
52 libdl-routines += dlopenold
53 libdl-shared-only-routines := dlopenold
54 endif
56 before-compile = $(objpfx)trusted-dirs.h
58 ifeq ($(versioning),yes)
59 ld-map = $(common-objpfx)ld.so.map
60 endif
62 ifeq (yes,$(build-shared))
63 extra-objs = $(rtld-routines:=.os) soinit.os sofini.os eval.os interp.os
64 generated = librtld.os dl-allobjs.os ld.so trusted-dirs.h trusted-dirs.st
65 install-others = $(inst_slibdir)/$(rtld-installed-name)
66 install-bin = ldd
67 generated += ldd
68 endif
70 others = sprof sln
71 install-bin += sprof
72 others-static = sln
73 install-rootsbin = sln
75 ifeq (yes,$(has-ldconfig))
76 others-static += ldconfig
77 others += ldconfig
78 install-rootsbin += ldconfig
79 endif
81 ifeq (yes,$(build-shared))
82 tests = loadtest restest1 preloadtest loadfail multiload origtest
83 endif
84 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
85 testobj1_1 failobj
86 extra-objs += $(modules-names:=.os)
88 ifeq ($(build-shared),yes)
89 libdl = $(objpfx)libdl.so$(libdl.so-version)
90 else
91 libdl = $(objpfx)libdl.a
92 endif
94 include ../Rules
97 ifeq (yes,$(build-shared))
98 # Make sure these things are built in the `make lib' pass so they can be used
99 # to run programs during the `make others' pass.
100 lib-noranlib: $(objpfx)$(rtld-installed-name) \
101 $(addprefix $(objpfx),$(extra-objs))
102 endif
104 # Command to link into a larger single relocatable object.
105 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
107 $(objpfx)dl-allobjs.os: $(rtld-routines:%=$(objpfx)%.os)
108 $(reloc-link) $^
110 # Link together the dynamic linker into a single relocatable object.
111 $(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
112 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
114 # Do we need a linker script?
115 rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
117 ifneq (,$(rtld-ldscript-in))
118 rtld-ldscript = $(objpfx)rtld-ldscript
119 generated += rtld-ldscript
121 LDFLAGS-rtld = -T $(rtld-ldscript)
122 before-compile += $(rtld-ldscript)
124 rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
125 include $(rtld-parms)
127 $(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
128 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
129 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
130 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
131 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
132 endif
134 $(objpfx)ld.so: $(objpfx)librtld.os $(addprefix $(objpfx),$(rtld-ldscript)) \
135 $(ld-map)
136 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld) \
137 $(filter-out $(rtld-ldscript) $(map-file),$^) \
138 $(load-map-file) -Wl,-soname=$(rtld-installed-name)
140 # interp.c exists just to get this string into the libraries.
141 CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
143 ifneq (ld.so,$(rtld-installed-name))
144 # Make sure ld.so.1 exists in the build directory so we can link
145 # against it.
146 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
147 rm -f $@
148 ln -s $(<F) $@
149 generated += $(rtld-installed-name)
150 endif
152 # Build a file mentioning all trustworthy directories to look for shared
153 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
154 # add directories to the list by defining $(user-defined-trusted-dirs)
155 # before starting make.
156 $(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
157 $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
158 $(make-target-directory)
159 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
160 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
161 $(move-if-change) ${@:st=T} ${@:st=h}
162 touch $@
163 CPPFLAGS-dl-load.c = -I$(objpfx).
164 CFLAGS-dl-load.c += -Wno-uninitialized
166 # Specify the dependencies of libdl.so; its commands come from the generic
167 # rule to build a shared library.
168 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
170 ifeq (yes,$(build-shared))
171 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
172 $(do-install-program)
174 $(inst_slibdir)/$(rtld-installed-name): \
175 $(inst_slibdir)/$(rtld-version-installed-name)
176 $(make-shlib-link)
178 # Special target called by parent to install just the dynamic linker.
179 .PHONY: ldso_install
180 ldso_install: $(inst_slibdir)/$(rtld-installed-name)
181 endif
184 common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
185 -e 's%@VERSION@%$(version)%g'
186 sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
187 bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
188 -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
190 ifneq ($(have-bash2),yes)
191 ldd-shell = sh
192 else
193 ldd-shell = bash
194 endif
196 ifeq ($(ldd-rewrite-script),no)
197 define gen-ldd
198 sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
199 endef
200 else
201 define gen-ldd
202 sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
203 endef
204 endif
206 $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
207 $(common-objpfx)config.make
208 $(gen-ldd)
209 chmod 555 $@.new
210 mv -f $@.new $@
213 $(objpfx)sprof: $(libdl)
215 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
216 generated += $(addsuffix .so,$(modules-names))
218 $(objpfx)testobj1.so: $(libdl)
219 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
220 $(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
221 $(objpfx)testobj3.so: $(libdl)
222 $(objpfx)testobj4.so: $(libdl)
223 $(objpfx)testobj5.so: $(libdl)
224 $(objpfx)testobj6.so: $(libdl)
225 $(objpfx)failobj.so: $(objpfx)testobj6.so
227 $(test-modules): $(objpfx)%.so: $(objpfx)%.os
228 $(build-module)
230 $(objpfx)loadtest: $(libdl)
231 LDFLAGS-loadtest = -rdynamic
233 $(objpfx)loadtest.out: $(test-modules)
235 $(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
236 LDFLAGS-restest1 = -rdynamic
238 $(objpfx)restest1.out: $(test-modules)
240 preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
241 $(objpfx)preloadtest: $(objpfx)testobj6.so
242 LDFLAGS-preloadtest = -rdynamic
243 $(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
244 preloadtest-ENV = \
245 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
247 $(objpfx)loadfail: $(libdl)
248 LDFLAGS-loadfail = -rdynamic
250 $(objpfx)loadfail.out: $(objpfx)failobj.so
252 $(objpfx)multiload: $(libdl)
253 LDFLAGS-multiload = -rdynamic
254 CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
256 $(objpfx)multiload.out: $(objpfx)testobj1.so
258 $(objpfx)origtest: $(libdl)
259 $(objpfx)origtest.out: $(objpfx)testobj1.so
261 # muwahaha
263 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
264 $(objpfx)libdl.so: $(objpfx)eval.os