1## Process this file with automake to create Makefile.in
2##
3## Copyright (C) 1996-2014, 2016 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
28bin_PROGRAMS = readelf nm size strip elflint findtextrel addr2line \
29	       elfcmp objdump ranlib strings ar unstrip stack elfcompress \
30	       elfclassify
31
32noinst_LIBRARIES = libar.a
33
34libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c
35
36EXTRA_DIST = arlib.h debugpred.h
37
38bin_SCRIPTS = make-debug-archive
39EXTRA_DIST += make-debug-archive.in
40CLEANFILES += make-debug-archive
41
42if BUILD_STATIC
43libasm = ../libasm/libasm.a
44libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) -ldl -lpthread
45libelf = ../libelf/libelf.a -lz
46else
47libasm = ../libasm/libasm.so
48libdw = ../libdw/libdw.so
49libelf = ../libelf/libelf.so
50endif
51libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a
52libeu = ../lib/libeu.a
53
54if DEMANGLE
55demanglelib = -lstdc++
56endif
57
58# Bad, bad stack usage...
59readelf_no_Wstack_usage = yes
60nm_no_Wstack_usage = yes
61size_no_Wstack_usage = yes
62strip_no_Wstack_usage = yes
63elflint_no_Wstack_usage = yes
64findtextrel_no_Wstack_usage = yes
65elfcmp_no_Wstack_usage = yes
66objdump_no_Wstack_usage = yes
67ranlib_no_Wstack_usage = yes
68ar_no_Wstack_usage = yes
69unstrip_no_Wstack_usage = yes
70
71readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
72nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) \
73	   $(demanglelib)
74size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
75strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
76elflint_LDADD  = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
77findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
78addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
79elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
80objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
81ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
82strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
83ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
84unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
85stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
86elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
87elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
88
89installcheck-binPROGRAMS: $(bin_PROGRAMS)
90	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
91	  case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
92	   *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
93	  esac; \
94	  f=`echo "$$p" | \
95	     sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
96	  for opt in --help --version; do \
97	    if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
98	       $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
99		 && test -n "`cat c$${pid}_.out`" \
100		 && test -z "`cat c$${pid}_.err`"; then :; \
101	    else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
102	  done; \
103	done; rm -f c$${pid}_.???; exit $$bad
104
105CLEANFILES += *.gconv
106
107make-debug-archive: $(srcdir)/make-debug-archive.in
108	$(AM_V_GEN)UNSTRIP=$(bindir)/`echo unstrip | sed '$(transform)'`; \
109	AR=$(bindir)/`echo ar | sed '$(transform)'`; \
110	sed -e "s,[@]UNSTRIP[@],$$UNSTRIP,g" -e "s,[@]AR[@],$$AR,g" \
111	    -e "s%[@]PACKAGE_NAME[@]%$(PACKAGE_NAME)%g" \
112	    -e "s%[@]PACKAGE_VERSION[@]%$(PACKAGE_VERSION)%g" \
113	    $(srcdir)/make-debug-archive.in > $@.new
114	$(AM_V_at)chmod +x $@.new
115	$(AM_V_at)mv -f $@.new $@
116