]> sourceware.org Git - glibc.git/blob - elf/Makefile
update from main archive 970120
[glibc.git] / elf / Makefile
1 # Makefile for elf subdirectory of GNU C Library.
2
3 # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
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.
10
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.
15
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.
20
21 subdir := elf
22
23 headers = elf.h elfclass.h link.h dlfcn.h
24 routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
25 enbl-secure
26
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
33
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
39
40 extra-libs = libdl
41 extra-libs-others = $(extra-libs)
42 libdl-routines := dlopen dlclose dlsym dlerror dladdr
43
44 before-compile = $(objpfx)trusted-dirs.h
45
46
47 all: # Make this the default target; it will be defined in Rules.
48
49 include ../Makeconfig
50
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 = $(slibdir)/$(rtld-installed-name)
55 install-bin = ldd
56 endif
57
58 include ../Rules
59
60
61 ifeq (yes, $(build-shared))
62 # Make sure these things are built in the `make lib' pass so they can be used
63 # to run programs during the `make others' pass.
64 lib-noranlib: $(objpfx)$(rtld-installed-name) \
65 $(addprefix $(objpfx),$(extra-objs))
66 endif
67
68 # Command to link into a larger single relocatable object.
69 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
70
71 $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so)
72 $(reloc-link) $^
73
74 # Link together the dynamic linker into a single relocatable object.
75 $(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a
76 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
77
78 $(objpfx)ld.so: $(objpfx)librtld.so
79 $(rtld-link) -Wl,-soname=$(rtld-installed-name)
80
81 define rtld-link
82 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
83 -Wl,-rpath=$(default-rpath) $^
84 endef
85
86 # The dl code in the static libc needs a default library path.
87 CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
88
89 ifneq (ld.so, $(rtld-installed-name))
90 # Make sure ld.so.1 exists in the build directory so we can link
91 # against it.
92 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
93 rm -f $@
94 ln -s $(<F) $@
95 endif
96
97 # Build a file mentioning all trustworthy directories to look for shared
98 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
99 # add directories to the list by defining $(user-defined-trusted-dirs)
100 # before starting make.
101 $(objpfx)trusted-dirs.h: Makefile
102 (for dir in `echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
103 sed 's/:/ /g'`; do \
104 echo " \"$$dir\","; \
105 done;) > $@T
106 mv -f $@T $@
107 CFLAGS-dl-load.c = -I$(objdir)/$(subdir)
108
109 # Specify the dependencies of libdl.so; its commands come from the generic
110 # rule to build a shared library.
111 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
112
113 $(slibdir)/$(rtld-installed-name): $(objpfx)ld.so; $(do-install-program)
114
115 ifneq ($(have-bash2),yes)
116 $(objpfx)ldd: ldd.sh.in $(common-objpfx)version.mk \
117 $(common-objpfx)soversions.mk $(common-objpfx)config.make
118 sed -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
119 -e 's%@VERSION@%$(version)%g' < $< > $@.new
120 chmod 555 $@.new
121 mv -f $@.new $@
122 else
123 $(objpfx)ldd: ldd.bash.in $(common-objpfx)version.mk \
124 $(common-objpfx)soversions.mk $(common-objpfx)config.make
125 sed -e 's%@BASH@%$(BASH)%g' \
126 -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
127 -e 's%@VERSION@%$(version)%g' \
128 -e 's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
129 chmod 555 $@.new
130 mv -f $@.new $@
131 endif
132 \f
133 # muwahaha
134
135 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
136 $(objpfx)libdl.so: $(objpfx)eval.so
This page took 0.042098 seconds and 5 git commands to generate.