1## Process this file with automake to create Makefile.in
2##
3## Copyright (C) 1996-2012 Red Hat, Inc.
4## This file is part of Red Hat elfutils.
5##
6## Red Hat elfutils is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by the
8## Free Software Foundation; version 2 of the License.
9##
10## Red Hat elfutils is distributed in the hope that it will be useful, but
11## WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13## General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License along
16## with Red Hat elfutils; if not, write to the Free Software Foundation,
17## Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18##
19## Red Hat elfutils is an included package of the Open Invention Network.
20## An included package of the Open Invention Network is a package for which
21## Open Invention Network licensees cross-license their patents.  No patent
22## license is granted, either expressly or impliedly, by designation as an
23## included package.  Should you wish to participate in the Open Invention
24## Network licensing program, please visit www.openinventionnetwork.com
25## <http://www.openinventionnetwork.com>.
26##
27include $(top_srcdir)/config/eu.am
28DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
29	-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
30INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
31	    -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
32	    -I$(srcdir)/../libasm
33
34AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw
35
36no_mudflap.os = -fmudflap
37
38YACC = @YACC@ -d
39AM_YFLAGS = -pld
40AM_LFLAGS = -Pld -olex.yy.c
41## Uncomment to enable debugging of linker script parser
42##YYDEBUG = -DYYDEBUG=1
43
44native_ld = @native_ld@
45base_cpu = @base_cpu@
46
47bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
48	       elfcmp objdump ranlib strings ar unstrip
49
50
51ld_dsos = libld_elf_i386_pic.a
52if NATIVE_LD
53noinst_LIBRARIES = libld_elf.a libar.a
54native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu)
55else
56noinst_LIBRARIES = libld_elf.a libar.a $(ld_dsos)
57noinst_PROGRAMS = $(ld_dsos:_pic.a=.so)
58endif
59if NEVER
60# We never build this library but we need to get the dependency files
61# of all the linker backends that might be used in a non-generic linker.
62noinst_LIBRARIES += libdummy.a
63libdummy_a_SOURCES = i386_ld.c
64endif
65
66
67ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \
68	     versionhash.c
69
70libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c
71
72noinst_HEADERS = ld.h symbolhash.h sectionhash.h versionhash.h \
73		 ldscript.h xelf.h unaligned.h
74
75EXTRA_DIST = elf32-i386.script libld_elf_i386.map $(ld_modules) arlib.h \
76	     debugpred.h
77ld_modules = i386_ld.c
78
79bin_SCRIPTS = make-debug-archive
80EXTRA_DIST += make-debug-archive.in
81CLEANFILES += make-debug-archive
82
83if BUILD_STATIC
84libasm = ../libasm/libasm.a
85libdw = ../libdw/libdw.a $(zip_LIBS) $(libelf) $(libebl) -ldl
86libelf = ../libelf/libelf.a
87else
88libasm = ../libasm/libasm.so
89libdw = ../libdw/libdw.so
90libelf = ../libelf/libelf.so
91endif
92libebl = ../libebl/libebl.a
93libeu = ../lib/libeu.a
94
95if DEMANGLE
96demanglelib = -lstdc++
97endif
98
99nm_no_Wformat = yes
100size_no_Wformat = yes
101strings_no_Wformat = yes
102addr2line_no_Wformat = yes
103# XXX While the file is not finished, don't warn about this
104ldgeneric_no_Wunused = yes
105
106readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
107nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \
108	   $(demanglelib)
109size_LDADD = $(libelf) $(libeu) $(libmudflap)
110strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
111ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
112if NATIVE_LD
113# -ldl is always needed for libebl.
114ld_LDADD += libld_elf.a
115endif
116ld_LDFLAGS = -rdynamic
117elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
118findtextrel_LDADD = $(libdw) $(libelf) $(libmudflap)
119addr2line_LDADD = $(libdw) $(libelf) $(libmudflap)
120elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl
121objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
122ranlib_LDADD = libar.a $(libelf) $(libeu) $(libmudflap)
123strings_LDADD = $(libelf) $(libeu) $(libmudflap)
124ar_LDADD = libar.a $(libelf) $(libeu) $(libmudflap)
125unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libmudflap) -ldl
126
127ldlex.o: ldscript.c
128ldlex_no_Werror = yes
129ldscript.h: ldscript.c
130
131if NATIVE_LD
132# Machine-specific linker code.
133libld_elf_a_SOURCES := $(base_cpu)_ld.c
134else
135libld_elf_i386_pic_a_SOURCES =
136am_libld_elf_i386_pic_a_OBJECTS = i386_ld.os
137
138libld_elf_i386_so_SOURCES =
139libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map
140	$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
141		$(libelf) $(libeu) \
142		-Wl,--version-script,$(srcdir)/libld_elf_i386.map
143	$(textrel_check)
144endif
145
146# Special rule to make it possible to define libld_elf_a_SOURCES as we do.
147# Otherwise make would complain.
148.deps/none_ld.Po: none_ld.os
149	-:
150
151
152installcheck-binPROGRAMS: $(bin_PROGRAMS)
153	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
154	  case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
155	   *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
156	  esac; \
157	  f=`echo "$$p" | \
158	     sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
159	  for opt in --help --version; do \
160	    if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
161	       $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
162		 && test -n "`cat c$${pid}_.out`" \
163		 && test -z "`cat c$${pid}_.err`"; then :; \
164	    else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
165	  done; \
166	done; rm -f c$${pid}_.???; exit $$bad
167
168CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gconv
169
170MAINTAINERCLEANFILES = ldlex.c ldscript.c ldscript.h
171
172
173make-debug-archive: $(srcdir)/make-debug-archive.in
174	UNSTRIP=$(bindir)/`echo unstrip | sed '$(transform)'`; \
175	AR=$(bindir)/`echo ar | sed '$(transform)'`; \
176	sed -e "s,@UNSTRIP@,$$UNSTRIP,g" -e "s,@AR@,$$AR,g" \
177	    -e "s%[@]PACKAGE_NAME[@]%$(PACKAGE_NAME)%g" \
178	    -e "s%[@]PACKAGE_VERSION[@]%$(PACKAGE_VERSION)%g" \
179	    $(srcdir)/make-debug-archive.in > $@.new
180	chmod +x $@.new
181	mv -f $@.new $@
182