Test for hton/ntoh functions.
[glibc/history.git] / elf / Makefile
blob269a87296918fcfa194d152c0d5259860c090196
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 bits/elfclass.h bits/dlfcn.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 misc)
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 dl-hash.h 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
43 libdl-map := libdl.map
45 before-compile = $(objpfx)trusted-dirs.h
48 all: # Make this the default target; it will be defined in Rules.
50 include ../Makeconfig
52 ifeq (yes,$(build-shared))
53 extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so
54 generated = librtld.so dl-allobjs.so
55 install-others = $(inst_slibdir)/$(rtld-installed-name)
56 install-bin = ldd
57 endif
59 ifeq (yes,$(has-ldconfig))
60 extra-objs += ldconfig.o
61 install-rootsbin = ldconfig
63 $(objpfx)ldconfig: $(objpfx)ldconfig.o
64 $(CC) -nostdlib -nostartfiles -o $@ $(sysdep-LDFLAGS) -static \
65 $(addprefix $(csu-objpfx),start.o) $(+preinit) \
66 $(filter-out $(addprefix $(csu-objpfx),start.o) $(+preinit) \
67 $(link-extra-libs) $(common-objpfx)libc% $(+postinit),$^) \
68 $(link-extra-libs) $(common-objpfx)libc.a $(gnulib) $(+postinit)
69 endif
71 include ../Rules
74 ifeq (yes,$(build-shared))
75 # Make sure these things are built in the `make lib' pass so they can be used
76 # to run programs during the `make others' pass.
77 lib-noranlib: $(objpfx)$(rtld-installed-name) \
78 $(addprefix $(objpfx),$(extra-objs))
79 endif
81 # Command to link into a larger single relocatable object.
82 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
84 $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so)
85 $(reloc-link) $^
87 # Link together the dynamic linker into a single relocatable object.
88 $(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a
89 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
91 # Do we need a linker script?
92 rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
93 ifneq (,$(rtld-ldscript-in))
94 LDFLAGS-rtld = -T $(objpfx)rtld-ldscript
96 before-compile += $(objpfx)rtld-ldscript
97 rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
98 include $(rtld-parms)
99 generated += rtld-ldscript
100 $(objpfx)rtld-ldscript: $(rtld-ldscript-in) $(rtld-parms)
101 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
102 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
103 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
104 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
106 $(objpfx)ld.so: $(objpfx)librtld.so $(objpfx)rtld-ldscript
107 $(rtld-link) -Wl,-soname=$(rtld-installed-name)
109 define rtld-link
110 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
111 -Wl,-rpath=$(default-rpath) $(LDFLAGS-rtld) \
112 $(filter-out $(objpfx)rtld-ldscript,$^)
113 endef
114 else
115 $(objpfx)ld.so: $(objpfx)librtld.so
116 $(rtld-link) -Wl,-soname=$(rtld-installed-name)
118 define rtld-link
119 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
120 -Wl,-rpath=$(default-rpath) $^
121 endef
122 endif
124 # The dl code in the static libc needs a default library path.
125 CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
127 ifneq (ld.so,$(rtld-installed-name))
128 # Make sure ld.so.1 exists in the build directory so we can link
129 # against it.
130 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
131 rm -f $@
132 ln -s $(<F) $@
133 endif
135 # Build a file mentioning all trustworthy directories to look for shared
136 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
137 # add directories to the list by defining $(user-defined-trusted-dirs)
138 # before starting make.
139 $(objpfx)trusted-dirs.h: Makefile
140 $(make-target-directory)
141 (for dir in `echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
142 sed 's/:/ /g'`; do \
143 echo " \"$$dir\","; \
144 done;) > $@T
145 mv -f $@T $@
146 CPPFLAGS-dl-load.c = -I$(objdir)/$(subdir)
147 CFLAGS-dl-load.c += -Wno-uninitialized
149 # Specify the dependencies of libdl.so; its commands come from the generic
150 # rule to build a shared library.
151 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
153 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so
154 $(do-install-program)
156 $(inst_slibdir)/$(rtld-installed-name): \
157 $(inst_slibdir)/$(rtld-version-installed-name)
158 $(make-shlib-link)
160 ifneq ($(have-bash2),yes)
161 $(objpfx)ldd: ldd.sh.in $(common-objpfx)version.mk \
162 $(common-objpfx)soversions.mk $(common-objpfx)config.make
163 sed -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
164 -e 's%@VERSION@%$(version)%g' < $< > $@.new
165 chmod 555 $@.new
166 mv -f $@.new $@
167 else
168 $(objpfx)ldd: ldd.bash.in $(common-objpfx)version.mk \
169 $(common-objpfx)soversions.mk $(common-objpfx)config.make
170 sed -e 's%@BASH@%$(BASH)%g' \
171 -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
172 -e 's%@VERSION@%$(version)%g' \
173 -e 's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
174 chmod 555 $@.new
175 mv -f $@.new $@
176 endif
178 # muwahaha
180 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
181 $(objpfx)libdl.so: $(objpfx)eval.so