1## Makefile.am for libdebuginfod library subdirectory in elfutils.
2##
3## Process this file with automake to create Makefile.in
4##
5## Copyright (C) 2019 Red Hat, Inc.
6## This file is part of elfutils.
7##
8## This file is free software; you can redistribute it and/or modify
9## it under the terms of either
10##
11##   * the GNU Lesser General Public License as published by the Free
12##     Software Foundation; either version 3 of the License, or (at
13##     your option) any later version
14##
15## or
16##
17##   * the GNU General Public License as published by the Free
18##     Software Foundation; either version 2 of the License, or (at
19##     your option) any later version
20##
21## or both in parallel, as here.
22##
23## elfutils is distributed in the hope that it will be useful, but
24## WITHOUT ANY WARRANTY; without even the implied warranty of
25## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26## General Public License for more details.
27##
28## You should have received copies of the GNU General Public License and
29## the GNU Lesser General Public License along with this program.  If
30## not, see <http://www.gnu.org/licenses/>.
31##
32include $(top_srcdir)/config/eu.am
33AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
34	   -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
35	   $(libmicrohttpd_CFLAGS) $(libcurl_CFLAGS) $(sqlite3_CFLAGS) \
36	   $(libarchive_CFLAGS)
37
38# Disable eu- prefixing for artifacts (binaries & man pages) in this
39# directory, since they do not conflict with binutils tools.
40program_prefix=
41program_transform_name = s,x,x,
42
43if BUILD_STATIC
44libasm = ../libasm/libasm.a
45libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl -lpthread
46libelf = ../libelf/libelf.a -lz
47if DUMMY_LIBDEBUGINFOD
48libdebuginfod = ./libdebuginfod.a
49else
50libdebuginfod = ./libdebuginfod.a $(libcurl_LIBS)
51endif
52else
53libasm = ../libasm/libasm.so
54libdw = ../libdw/libdw.so
55libelf = ../libelf/libelf.so
56libdebuginfod = ./libdebuginfod.so
57endif
58libebl = ../libebl/libebl.a
59libeu = ../lib/libeu.a
60
61AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw:.
62
63bin_PROGRAMS =
64if DEBUGINFOD
65bin_PROGRAMS += debuginfod
66endif
67
68if LIBDEBUGINFOD
69bin_PROGRAMS += debuginfod-find
70endif
71
72debuginfod_SOURCES = debuginfod.cxx
73debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
74
75debuginfod_find_SOURCES = debuginfod-find.c
76debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) $(argp_LDADD) $(fts_LIBS)
77
78if LIBDEBUGINFOD
79noinst_LIBRARIES = libdebuginfod.a
80noinst_LIBRARIES += libdebuginfod_pic.a
81endif
82
83libdebuginfod_a_SOURCES = debuginfod-client.c
84libdebuginfod_pic_a_SOURCES = debuginfod-client.c
85am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=.os)
86
87if DUMMY_LIBDEBUGINFOD
88AM_CPPFLAGS += -Wno-unused-parameter
89endif
90
91if LIBDEBUGINFOD
92pkginclude_HEADERS = debuginfod.h
93endif
94
95if LIBDEBUGINFOD
96libdebuginfod_so_LIBS = libdebuginfod_pic.a
97if DUMMY_LIBDEBUGINFOD
98libdebuginfod_so_LDLIBS =
99else
100libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)
101endif
102$(LIBDEBUGINFOD_SONAME): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS)
103	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
104		-Wl,--soname,$(LIBDEBUGINFOD_SONAME) \
105		-Wl,--version-script,$<,--no-undefined \
106		-Wl,--whole-archive $(libdebuginfod_so_LIBS) -Wl,--no-whole-archive \
107		$(libdebuginfod_so_LDLIBS)
108	@$(textrel_check)
109
110libdebuginfod.so: $(LIBDEBUGINFOD_SONAME)
111	ln -fs $< $@
112
113install: install-am libdebuginfod.so
114	$(mkinstalldirs) $(DESTDIR)$(libdir)
115	$(INSTALL_PROGRAM) $(LIBDEBUGINFOD_SONAME) \
116		$(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
117	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
118	ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
119
120uninstall: uninstall-am
121	rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
122	rm -f $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
123	rm -f $(DESTDIR)$(libdir)/libdebuginfod.so
124	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
125endif
126
127EXTRA_DIST = libdebuginfod.map
128MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) $(LIBDEBUGINFOD_SONAME)
129CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
130
131# automake std-options override: arrange to pass LD_LIBRARY_PATH
132installcheck-binPROGRAMS: $(bin_PROGRAMS)
133	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
134	  case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
135	   *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
136	  esac; \
137	  f=`echo "$$p" | \
138	     sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
139	  for opt in --help --version; do \
140	    if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
141	       $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
142		 && test -n "`cat c$${pid}_.out`" \
143		 && test -z "`cat c$${pid}_.err`"; then :; \
144	    else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
145	  done; \
146	done; rm -f c$${pid}_.???; exit $$bad
147