diff mbox series

build: Improve linking

Message ID 20220531074030.8151-1-ivan.hu@canonical.com
State Accepted
Headers show
Series build: Improve linking | expand

Commit Message

ivanhu May 31, 2022, 7:40 a.m. UTC
This improves the linking enough to get the build to complete
with slibtool and GNU libtool.

Signed-off-by: orbea <orbea@riseup.net>
---
 configure.ac                  |  6 ++++++
 src/Makefile.am               | 21 +++++++++++----------
 src/lib/src/Makefile.am       | 18 ++++++++++--------
 src/libfwtsacpica/Makefile.am |  6 ++----
 src/libfwtsiasl/Makefile.am   |  4 ++--
 5 files changed, 31 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index f40c3678..ca2f54e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,12 @@ 
 	  AC_CHECK_HEADERS([asm/opal-prd.h])
 	  AC_CHECK_HEADERS([mtd/mtd-abi.h])
 	  AC_CHECK_HEADERS([pci/pci.h])
+	  PKG_CHECK_MODULES([GIO], [gio-2.0])
+	  PKG_CHECK_MODULES([GLIB], [glib-2.0])
+	  AC_SUBST([GIO_CFLAGS])
+	  AC_SUBST([GIO_LIBS])
+	  AC_SUBST([GLIB_CFLAGS])
+	  AC_SUBST([GLIB_LIBS])
 	  AM_CONDITIONAL([HAVE_ASM_OPAL_PRD_H],
 	    [test "x$ac_cv_header_asm_opal_prd_h" = "xyes"])
 	  AM_CONDITIONAL([HAVE_MTD_ABI_H],
diff --git a/src/Makefile.am b/src/Makefile.am
index 9a26af86..a8c60b79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/acpica/source/compiler	\
 	-I$(top_srcdir)/efi_runtime			\
 	-I$(top_srcdir)/smccc_test			\
-	-pthread `pkg-config --cflags glib-2.0 gio-2.0` \
+	-pthread					\
 	-Wall -Werror -Wextra				\
 	-Wno-address-of-packed-member			\
 	-Wfloat-equal -Wmissing-declarations		\
@@ -23,7 +23,11 @@  AM_CPPFLAGS = \
 
 bin_PROGRAMS = fwts
 
-fwts_CPPFLAGS = $(AM_CPPFLAGS) -DACPI_DEBUG_OUTPUT
+fwts_CPPFLAGS = 					\
+	$(AM_CPPFLAGS)					\
+	@GIO_CFLAGS@					\
+	@GLIB_CFLAGS@					\
+	-DACPI_DEBUG_OUTPUT
 
 if HAVE_LIBFDT
 dt_tests = \
@@ -207,16 +211,13 @@  fwts_SOURCES = main.c 				\
 	$(power_mgmt_tests)			\
 	$(dt_tests)
 
-fwts_LDFLAGS = -lm -lbsd `pkg-config --libs glib-2.0 gio-2.0`
+fwts_LDFLAGS = -no-undefined
 
 fwts_LDADD = \
-	-lfwts					\
-	-L$(top_builddir)/src			\
-	-L$(top_builddir)/src/acpica		\
-	-L$(top_builddir)/src/libfwtsiasl	\
-	-L$(top_builddir)/src/libfwtsacpica	\
-	-L$(top_builddir)/src/lib/src		\
-	-lfwtsacpica
+	-lbsd \
+	$(top_builddir)/src/lib/src/libfwts.la \
+	$(top_builddir)/src/libfwtsiasl/libfwtsiasl.la \
+	$(top_builddir)/src/libfwtsacpica/libfwtsacpica.la
 
 man_MANS = ../doc/fwts.1 ../doc/fwts-collect.1 ../doc/fwts-frontend-text.1
 
diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
index a4fd23e9..d5d53dd7 100644
--- a/src/lib/src/Makefile.am
+++ b/src/lib/src/Makefile.am
@@ -21,22 +21,24 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/libfwtsiasl			\
 	-I$(top_srcdir)/src/acpica/source/include	\
 	-I$(top_srcdir)/src/acpica/source/compiler	\
-	`pkg-config --silence-errors --cflags json`	\
-	`pkg-config --silence-errors --cflags json-c`	\
-	`pkg-config --cflags glib-2.0 gio-2.0` 		\
 	-DDATAROOTDIR=\"$(datarootdir)\"		\
 	-Wall -Werror -Wextra				\
 	-Wno-address-of-packed-member
 
 pkglib_LTLIBRARIES = libfwts.la
 
-libfwts_la_LDFLAGS = 					\
+libfwts_la_LDFLAGS = -version-info 1:0:0
+
+libfwts_la_LIBADD = 				\
 	-lm -lpthread -lbsd				\
-	-version-info 1:0:0 				\
-	-L$(top_builddir)/src/libfwtsiasl		\
-	-lfwtsiasl `pkg-config --libs glib-2.0 gio-2.0`
+	@GIO_LIBS@					\
+	@GLIB_LIBS@
 
-libfwts_la_CPPFLAGS = $(AM_CPPFLAGS) -DACPI_DEBUG_OUTPUT
+libfwts_la_CPPFLAGS =					\
+	$(AM_CPPFLAGS)					\
+	@GIO_CFLAGS@					\
+	@GLIB_CFLAGS@					\
+	-DACPI_DEBUG_OUTPUT
 
 if HAVE_LIBFDT
 dt_sources = \
diff --git a/src/libfwtsacpica/Makefile.am b/src/libfwtsacpica/Makefile.am
index 65554b8e..57cd7b82 100644
--- a/src/libfwtsacpica/Makefile.am
+++ b/src/libfwtsacpica/Makefile.am
@@ -74,7 +74,8 @@  CLEANFILES = osunixxf_munged.c					\
 
 pkglib_LTLIBRARIES = libfwtsacpica.la
 
-libfwtsacpica_la_LDFLAGS = -lpthread -version-info 1:0:0
+libfwtsacpica_la_LDFLAGS = -version-info 1:0:0
+libfwtsacpica_la_LIBADD = -lpthread
 libfwtsacpica_la_CPPFLAGS = $(AM_CPPFLAGS)
 
 #
@@ -280,8 +281,5 @@  libfwtsacpica_la_SOURCES =						\
 	../../src/acpica/source/tools/acpiexec/aeinstall.c		\
 	../../src/acpica/source/os_specific/service_layers/osgendbg.c
 
-libfwtsacpica_la_LIBADD = \
-	-L../../src/lib/src -lfwts -lrt
-
 
 -include ../../git.mk
diff --git a/src/libfwtsiasl/Makefile.am b/src/libfwtsiasl/Makefile.am
index 1be586f3..2bb32271 100644
--- a/src/libfwtsiasl/Makefile.am
+++ b/src/libfwtsiasl/Makefile.am
@@ -104,8 +104,8 @@  BUILT_SOURCES = aslcompiler.y		\
 #
 # Just export fwts specific API so we don't clash with core ACPICA library
 #
-libfwtsiasl_la_LDFLAGS = -export-symbols-regex "fwts_.*" -lpthread -version-info 1:0:0
-
+libfwtsiasl_la_LDFLAGS = -export-symbols-regex "fwts_.*" -version-info 1:0:0
+libfwtsiasl_la_LIBADD = -lpthread
 CLEANFILES = $(BUILT_SOURCES)
 
 libfwtsiasl_la_CPPFLAGS = $(AM_CPPFLAGS)