pespin submitted this change.
Makefile:am: Improve formatting and order of CFLAGS and LIBS
Place osmocom libraries in proper dependency order.
It seems in general the linker searches from left to right, and notes
unresolved symbols as it goes.
So libs should be placed so that the library that needs symbols must be
first, then the library that resolves the symbol.
This is actually more important for static libraries than shared libraries, see:
https://praveenv253.github.io/logs/2014/03/15/log-message-1.html
https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc
Some distros like debian and ubuntu started passing -Wl,--as-needed by default,
which then require the object files to be passed before the libraries.
According to https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
"Importance of linking order" this is not much of a problem with autoamke since we
properly use LDADD instead of LDFLAGS.
See also:
https://wiki.ubuntu.com/OneiricOcelot/ReleaseNotes#GCC_4.6_Toolchain
https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--as-needed
https://wiki.debian.org/ToolChain/DSOLinking#Only_link_with_needed_libraries
The problem is actually those places where we pass .o objects in LDADD. There, we
need to put the .o files first, and then the libraries in the order mentioned above.
Nevertheless, it's good to always follow the same order always everywhere to avoid
potential problems though.
Change-Id: Ia766a09103d2216258a83cc98899e6cae4b0351d
---
M src/Makefile.am
M src/bankd/Makefile.am
M src/client/Makefile.am
M src/server/Makefile.am
4 files changed, 74 insertions(+), 27 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index b305ce2..7c00395 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,9 +7,14 @@
endif
SUBDIRS += client
-AM_CFLAGS = -Wall -I$(top_srcdir)/include -I$(top_builddir)/include \
- $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMOABIS_CFLAGS) \
- -I$(top_srcdir)/include/osmocom/rspro
+AM_CFLAGS = -Wall \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include/osmocom/rspro \
+ $(OSMOABIS_CFLAGS) \
+ $(OSMOGSM_CFLAGS) \
+ $(OSMOCORE_CFLAGS) \
+ $(NULL)
RSPRO_LIBVERSION=2:0:0
lib_LTLIBRARIES = libosmo-rspro.la
diff --git a/src/bankd/Makefile.am b/src/bankd/Makefile.am
index 4899aef..98edf8e 100644
--- a/src/bankd/Makefile.am
+++ b/src/bankd/Makefile.am
@@ -1,7 +1,13 @@
-AM_CFLAGS = -Wall -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src \
+AM_CFLAGS = -Wall \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/include/osmocom/rspro \
- $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMOABIS_CFLAGS) \
- $(PCSC_CFLAGS)
+ $(OSMOABIS_CFLAGS) \
+ $(OSMOGSM_CFLAGS) \
+ $(OSMOCORE_CFLAGS) \
+ $(PCSC_CFLAGS) \
+ $(NULL)
noinst_HEADERS = bankd.h internal.h gsmtap.h
@@ -9,13 +15,20 @@
noinst_PROGRAMS = pcsc_test
pcsc_test_SOURCES = driver_core.c driver_pcsc.c main.c
-pcsc_test_LDADD = $(OSMOCORE_LIBS) \
- $(PCSC_LIBS) $(top_builddir)/src/libosmo-rspro.la
+pcsc_test_LDADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOCORE_LIBS) \
+ $(PCSC_LIBS) \
+ $(NULL)
osmo_remsim_bankd_SOURCES = ../slotmap.c ../rspro_client_fsm.c ../debug.c \
bankd_main.c bankd_pcsc.c gsmtap.c
-osmo_remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
- $(PCSC_LIBS) $(CSV_LIBS) $(top_builddir)/src/libosmo-rspro.la
+osmo_remsim_bankd_LDADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOABIS_LIBS) \
+ $(OSMOGSM_LIBS) \
+ $(OSMOCORE_LIBS) \
+ $(PCSC_LIBS) \
+ $(CSV_LIBS) \
+ $(NULL)
# as suggested in http://lists.gnu.org/archive/html/automake/2009-03/msg00011.html
FORCE:
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index f158424..d5c263f 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -1,16 +1,25 @@
-AM_CFLAGS = -Wall -I$(top_srcdir)/include -I/$(top_builddir)/include -I$(top_srcdir)/src \
- $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMOABIS_CFLAGS) \
+AM_CFLAGS = -Wall \
+ -I$(top_srcdir)/include \
+ -I/$(top_builddir)/include \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/include/osmocom/rspro \
+ $(OSMOABIS_CFLAGS) \
+ $(OSMOGSM_CFLAGS) \
+ $(OSMOCORE_CFLAGS) \
$(PCSC_CFLAGS) $(USB_CFLAGS) \
$(OSMOSIMTRACE2_CFLAGS) \
- -I$(top_srcdir)/include/osmocom/rspro
+ $(NULL)
bin_PROGRAMS = osmo-remsim-client-shell
osmo_remsim_client_shell_SOURCES = user_shell.c remsim_client_main.c \
remsim_client.c main_fsm.c ../rspro_client_fsm.c ../debug.c
osmo_remsim_client_shell_CFLAGS = $(AM_CFLAGS)
-osmo_remsim_client_shell_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
- $(top_builddir)/src/libosmo-rspro.la
+osmo_remsim_client_shell_LDADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOABIS_LIBS) \
+ $(OSMOGSM_LIBS) \
+ $(OSMOCORE_LIBS) \
+ $(NULL)
if BUILD_CLIENT_IFDHANDLER
EXTRA_DIST=PkgInfo osmo-remsim-client-reader_conf.in
@@ -24,8 +33,11 @@
libifd_remsim_client_la_CFLAGS = $(AM_CFLAGS)
libifd_remsim_client_la_CPPFLAGS = $(PCSC_CFLAGS)
libifd_remsim_client_la_LDFLAGS = -no-undefined
-libifd_remsim_client_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
- $(top_builddir)/src/libosmo-rspro.la
+libifd_remsim_client_la_LIBADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOABIS_LIBS) \
+ $(OSMOGSM_LIBS) \
+ $(OSMOCORE_LIBS) \
+ $(NULL)
endif
if BUILD_CLIENT_ST2
@@ -34,10 +46,14 @@
remsim_client.c main_fsm.c ../rspro_client_fsm.c ../debug.c
osmo_remsim_client_st2_CPPFLAGS = -DUSB_SUPPORT -DSIMTRACE_SUPPORT
osmo_remsim_client_st2_CFLAGS = $(AM_CFLAGS)
-osmo_remsim_client_st2_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
- $(OSMOUSB_LIBS) $(OSMOSIMTRACE2_LIBS) \
+osmo_remsim_client_st2_LDADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOABIS_LIBS) \
+ $(OSMOSIMTRACE2_LIBS) \
+ $(OSMOGSM_LIBS) \
+ $(OSMOCORE_LIBS) \
+ $(OSMOUSB_LIBS) \
$(USB_LIBS) \
- $(top_builddir)/src/libosmo-rspro.la
+ $(NULL)
endif
-noinst_HEADERS = client.h
+noinst_HEADERS = client.h
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index f6278a3..15ae31b 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -1,8 +1,16 @@
-AM_CFLAGS = -Wall -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src \
+AM_CFLAGS = -Wall \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/include/osmocom/rspro \
- $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMOABIS_CFLAGS) \
- $(ULFIUS_CFLAGS) $(JANSSON_CFLAGS) $(ORCANIA_CFLAGS)
+ $(OSMOABIS_CFLAGS) \
+ $(OSMOGSM_CFLAGS) \
+ $(OSMOCORE_CFLAGS) \
+ $(ULFIUS_CFLAGS) \
+ $(JANSSON_CFLAGS) \
+ $(ORCANIA_CFLAGS) \
+ $(NULL)
noinst_HEADERS = rspro_server.h rest_api.h
@@ -10,9 +18,14 @@
osmo_remsim_server_SOURCES = remsim_server.c rspro_server.c rest_api.c \
../rspro_util.c ../slotmap.c ../debug.c
-osmo_remsim_server_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
- $(ULFIUS_LIBS) $(JANSSON_LIBS) $(ORCANIA_LIBS) \
- $(top_builddir)/src/libosmo-rspro.la
+osmo_remsim_server_LDADD = $(top_builddir)/src/libosmo-rspro.la \
+ $(OSMOABIS_LIBS) \
+ $(OSMOGSM_LIBS) \
+ $(OSMOCORE_LIBS) \
+ $(ULFIUS_LIBS) \
+ $(JANSSON_LIBS) \
+ $(ORCANIA_LIBS) \
+ $(NULL)
# as suggested in http://lists.gnu.org/archive/html/automake/2009-03/msg00011.html
FORCE:
To view, visit change 39020. To unsubscribe, or for help writing mail filters, visit settings.