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