Update.
[glibc.git] / elf / Makefile
blobb69b8a075469a9a5031e565474285594ba29e71d
1 # Makefile for elf subdirectory of GNU C Library.
3 # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB. If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
21 subdir := elf
23 headers = elf.h elfclass.h link.h dlfcn.h
24 routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
25 dl-version enbl-secure
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)
31 # But they are absent from the shared libc, because that code is in ld.so.
32 elide-routines.so = $(dl-routines) dl-support enbl-secure
34 # ld.so uses those routines, plus some special stuff for being the program
35 # interpreter and operating independent of libc.
36 rtld-routines := rtld $(dl-routines) dl-sysdep dl-minimal
37 distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
38 soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c
40 extra-libs = libdl
41 extra-libs-others = $(extra-libs)
42 libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
44 before-compile = $(objpfx)trusted-dirs.h
47 all: # Make this the default target; it will be defined in Rules.
49 include ../Makeconfig
51 ifeq (yes,$(build-shared))
52 extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so
53 generated = librtld.so dl-allobjs.so
54 install-others = $(inst_slibdir)/$(rtld-installed-name)
55 install-bin = ldd
56 endif
58 ifeq (yes,$(has-ldconfig))
59 extra-objs += ldconfig.o
60 install-rootsbin = ldconfig
62 $(objpfx)ldconfig: $(objpfx)ldconfig.o
63 $(CC) -nostdlib -nostartfiles -o $@ $(sysdep-LDFLAGS) -static \
64 $(addprefix $(csu-objpfx),start.o) $(+preinit) \
65 $(filter-out $(addprefix $(csu-objpfx),start.o) $(+preinit) \
66 $(link-extra-libs) $(common-objpfx)libc% $(+postinit),$^) \
67 $(link-extra-libs) $(common-objpfx)libc.a $(gnulib) $(+postinit)
68 endif
70 include ../Rules
73 ifeq (yes,$(build-shared))
74 # Make sure these things are built in the `make lib' pass so they can be used
75 # to run programs during the `make others' pass.
76 lib-noranlib: $(objpfx)$(rtld-installed-name) \
77 $(addprefix $(objpfx),$(extra-objs))
78 endif
80 # Command to link into a larger single relocatable object.
81 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
83 $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so)
84 $(reloc-link) $^
86 # Link together the dynamic linker into a single relocatable object.
87 $(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a
88 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
90 $(objpfx)ld.so: $(objpfx)librtld.so
91 $(rtld-link) -Wl,-soname=$(rtld-installed-name)
93 define rtld-link
94 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
95 -Wl,-rpath=$(default-rpath) $^
96 endef
98 # The dl code in the static libc needs a default library path.
99 CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
101 ifneq (ld.so,$(rtld-installed-name))
102 # Make sure ld.so.1 exists in the build directory so we can link
103 # against it.
104 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
105 rm -f $@
106 ln -s $(<F) $@
107 endif
109 # Build a file mentioning all trustworthy directories to look for shared
110 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
111 # add directories to the list by defining $(user-defined-trusted-dirs)
112 # before starting make.
113 $(objpfx)trusted-dirs.h: Makefile
114 $(make-target-directory)
115 (for dir in `echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
116 sed 's/:/ /g'`; do \
117 echo " \"$$dir\","; \
118 done;) > $@T
119 mv -f $@T $@
120 CPPFLAGS-dl-load.c = -I$(objdir)/$(subdir)
121 CFLAGS-dl-load.c += -Wno-uninitialized
123 # Specify the dependencies of libdl.so; its commands come from the generic
124 # rule to build a shared library.
125 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
127 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so
128 $(do-install-program)
130 $(inst_slibdir)/$(rtld-installed-name): \
131 $(inst_slibdir)/$(rtld-version-installed-name)
132 $(make-shlib-link)
134 ifneq ($(have-bash2),yes)
135 $(objpfx)ldd: ldd.sh.in $(common-objpfx)version.mk \
136 $(common-objpfx)soversions.mk $(common-objpfx)config.make
137 sed -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
138 -e 's%@VERSION@%$(version)%g' < $< > $@.new
139 chmod 555 $@.new
140 mv -f $@.new $@
141 else
142 $(objpfx)ldd: ldd.bash.in $(common-objpfx)version.mk \
143 $(common-objpfx)soversions.mk $(common-objpfx)config.make
144 sed -e 's%@BASH@%$(BASH)%g' \
145 -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
146 -e 's%@VERSION@%$(version)%g' \
147 -e 's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
148 chmod 555 $@.new
149 mv -f $@.new $@
150 endif
152 # muwahaha
154 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
155 $(objpfx)libdl.so: $(objpfx)eval.so