update from main archive 960911
[glibc/history.git] / elf / Makefile
blobcbb9c11f4282a1b05e2a2ec07e70c8d0ac47db82
1 # Makefile for elf subdirectory of GNU C Library.
3 # Copyright (C) 1995, 1996 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
18 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 # Cambridge, MA 02139, 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 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 eval.c
40 extra-libs = libdl
41 extra-libs-others = $(extra-libs)
42 libdl-routines := dlopen dlclose dlsym dlerror dladdr
45 all: # Make this the default target; it will be defined in Rules.
47 include ../Makeconfig
49 ifeq (yes,$(build-shared))
50 extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so
51 generated = librtld.so dl-allobjs.so
52 install-others = $(slibdir)/$(rtld-installed-name)
53 install-bin = ldd
54 endif
56 include ../Rules
59 ifeq (yes, $(build-shared))
60 # Make sure these things are built in the `make lib' pass so they can be used
61 # to run programs during the `make others' pass.
62 lib-noranlib: $(objpfx)$(rtld-installed-name) \
63 $(addprefix $(objpfx),$(extra-objs))
64 endif
66 # Command to link into a larger single relocatable object.
67 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
69 $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so)
70 $(reloc-link) $^
72 # Link together the dynamic linker into a single relocatable object.
73 $(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a
74 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
76 $(objpfx)ld.so: $(objpfx)librtld.so
77 $(rtld-link) -Wl,-soname=$(rtld-installed-name)
79 define rtld-link
80 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
81 -Wl,-rpath=$(default-rpath) $^
82 endef
84 # The dl code in the static libc needs a default library path.
85 CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
87 ifneq (ld.so, $(rtld-installed-name))
88 # Make sure ld-gnu.so.1 exists in the build directory so we can link
89 # against it.
90 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
91 rm -f $@
92 ln -s $(<F) $@
93 endif
96 # Specify the dependencies of libdl.so; its commands come from the generic
97 # rule to build a shared library.
98 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
100 $(slibdir)/$(rtld-installed-name): $(objpfx)ld.so; $(do-install-program)
102 $(objpfx)ldd: ldd.sh.in Makefile
103 sed 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' < $< > $@.new
104 chmod 555 $@.new
105 mv -f $@.new $@
107 # muwahaha
109 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
110 $(objpfx)libdl.so: $(objpfx)eval.so