[PATCH 2/4] Add subdir-objects automake option

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Andreas Rottmann mail at rotty.xx.vu
Tue Jun 16 21:23:29 UTC 2015


From: Andreas Rottmann <a.rottmann at gmx.at>

Having subdir-objects enabled is recommended by automake 1.14, to avoid
future incompatibilities.

However, adding that option breaks out-of-tree builds, and also seems to
break "make distclean" for in-tree builds. The reason is that
apparently, automake with subdir-objects enabled cannot cope with source
files in a different, non-child directory. To avoid that, we simply
compile the files referenced in this way into a static library in their
own source directory, and instead of referencing the source files, we
link against that library.

Besides making the build system a bit more future proof, this change
also potentially enhances build times, as it reduces the number of
compiler invocations, in exchange a slight increase of "ar" invocations.
---
 openbsc/configure.ac                   |  2 +-
 openbsc/src/gprs/Makefile.am           | 20 ++++++++++++--------
 openbsc/src/osmo-bsc_nat/Makefile.am   |  7 +++++--
 openbsc/tests/bsc-nat-trie/Makefile.am |  6 +++---
 openbsc/tests/bsc-nat/Makefile.am      | 11 +++--------
 openbsc/tests/bsc/Makefile.am          |  6 +++---
 openbsc/tests/gprs/Makefile.am         |  6 +++---
 openbsc/tests/smpp/Makefile.am         |  7 ++++---
 8 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index fb6feb9..e022393 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -3,7 +3,7 @@ AC_INIT([openbsc],
 	m4_esyscmd([./git-version-gen .tarball-version]),
 	[openbsc at lists.osmocom.org])
 
-AM_INIT_AUTOMAKE([dist-bzip2])
+AM_INIT_AUTOMAKE([subdir-objects dist-bzip2])
 AC_CONFIG_TESTDIR(tests)
 
 dnl kernel style compile messages
diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index f46a402..9765cdd 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -16,18 +16,22 @@ bin_PROGRAMS += osmo-sgsn
 endif
 endif
 
+noinst_LIBRARIES = libgprs.a
+
+libgprs_a_SOURCES =     gprs_gb_parse.c crc24.c gprs_utils.c \
+			gprs_llc.c gprs_llc_parse.c gprs_llc_vty.c \
+			gprs_subscriber.c \
+			gprs_gsup_messages.c gprs_gsup_client.c
+
 osmo_gbproxy_SOURCES =  gb_proxy.c gb_proxy_main.c gb_proxy_vty.c \
-			gb_proxy_patch.c gb_proxy_tlli.c gb_proxy_peer.c \
-			gprs_gb_parse.c gprs_llc_parse.c crc24.c gprs_utils.c
-osmo_gbproxy_LDADD = 	$(top_builddir)/src/libcommon/libcommon.a \
+			gb_proxy_patch.c gb_proxy_tlli.c gb_proxy_peer.c
+osmo_gbproxy_LDADD = 	libgprs.a $(top_builddir)/src/libcommon/libcommon.a \
 			$(OSMO_LIBS) -lrt
 
 osmo_sgsn_SOURCES =	gprs_gmm.c gprs_sgsn.c gprs_sndcp.c gprs_sndcp_vty.c \
 			sgsn_main.c sgsn_vty.c sgsn_libgtp.c \
-			gprs_llc.c gprs_llc_parse.c gprs_llc_vty.c crc24.c \
-			sgsn_ctrl.c sgsn_auth.c gprs_subscriber.c \
-			gprs_gsup_messages.c gprs_utils.c gprs_gsup_client.c \
-			gsm_04_08_gprs.c sgsn_cdr.c sgsn_ares.c
-osmo_sgsn_LDADD = 	\
+			sgsn_ctrl.c sgsn_auth.c \
+			gsm_04_08_gprs.c sgsn_cdr.c
+osmo_sgsn_LDADD = 	libgprs.a \
 			$(top_builddir)/src/libcommon/libcommon.a \
 			-lgtp $(OSMO_LIBS) $(LIBOSMOABIS_LIBS) $(LIBCARES_LIBS) -lrt
diff --git a/openbsc/src/osmo-bsc_nat/Makefile.am b/openbsc/src/osmo-bsc_nat/Makefile.am
index d96a391..a38d68a 100644
--- a/openbsc/src/osmo-bsc_nat/Makefile.am
+++ b/openbsc/src/osmo-bsc_nat/Makefile.am
@@ -3,12 +3,15 @@ AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS)
 AM_LDFLAGS = $(COVERAGE_LDFLAGS)
 
 bin_PROGRAMS = osmo-bsc_nat
+noinst_LIBRARIES = libbsc_nat.a
 
-
-osmo_bsc_nat_SOURCES = bsc_filter.c bsc_mgcp_utils.c bsc_nat.c bsc_nat_utils.c \
+libbsc_nat_a_SOURCES = \
+		  bsc_filter.c bsc_mgcp_utils.c bsc_nat_utils.c \
 		  bsc_nat_vty.c bsc_sccp.c bsc_ussd.c bsc_nat_ctrl.c \
 		  bsc_nat_rewrite.c bsc_nat_rewrite_trie.c bsc_nat_filter.c
+osmo_bsc_nat_SOURCES = bsc_nat.c 
 osmo_bsc_nat_LDADD = \
+	        libbsc_nat.a \
 		$(top_builddir)/src/libmgcp/libmgcp.a \
 		$(top_builddir)/src/libbsc/libbsc.a \
 		$(top_builddir)/src/libtrau/libtrau.a \
diff --git a/openbsc/tests/bsc-nat-trie/Makefile.am b/openbsc/tests/bsc-nat-trie/Makefile.am
index cf8ebaf..64c71ba 100644
--- a/openbsc/tests/bsc-nat-trie/Makefile.am
+++ b/openbsc/tests/bsc-nat-trie/Makefile.am
@@ -6,9 +6,9 @@ EXTRA_DIST = bsc_nat_trie_test.ok prefixes.csv
 
 noinst_PROGRAMS = bsc_nat_trie_test
 
-bsc_nat_trie_test_SOURCES = bsc_nat_trie_test.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c
-bsc_nat_trie_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
+bsc_nat_trie_test_SOURCES = bsc_nat_trie_test.c
+bsc_nat_trie_test_LDADD = $(top_builddir)/src/osmo-bsc_nat/libbsc_nat.a \
+			$(top_builddir)/src/libbsc/libbsc.a \
 			$(top_builddir)/src/libmgcp/libmgcp.a \
 			$(top_builddir)/src/libtrau/libtrau.a \
 			$(top_builddir)/src/libcommon/libcommon.a \
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index 26e5500..c1a5b1a 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -6,15 +6,10 @@ EXTRA_DIST = bsc_nat_test.ok bsc_data.c barr.cfg barr_dup.cfg prefixes.csv
 
 noinst_PROGRAMS = bsc_nat_test
 
-bsc_nat_test_SOURCES = bsc_nat_test.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_filter.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_sccp.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_utils.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite_trie.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_mgcp_utils.c \
-			$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_filter.c
+bsc_nat_test_SOURCES = bsc_nat_test.c
+
 bsc_nat_test_LDADD = \
+			$(top_builddir)/src/osmo-bsc_nat/libbsc_nat.a \
 			$(top_builddir)/src/libfilter/libfilter.a \
 			$(top_builddir)/src/libbsc/libbsc.a \
 			$(top_builddir)/src/libmgcp/libmgcp.a \
diff --git a/openbsc/tests/bsc/Makefile.am b/openbsc/tests/bsc/Makefile.am
index 8b786ff..7c3a219 100644
--- a/openbsc/tests/bsc/Makefile.am
+++ b/openbsc/tests/bsc/Makefile.am
@@ -6,9 +6,9 @@ EXTRA_DIST = bsc_test.ok
 
 noinst_PROGRAMS = bsc_test
 
-bsc_test_SOURCES = bsc_test.c \
-			$(top_srcdir)/src/osmo-bsc/osmo_bsc_filter.c
-bsc_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
+bsc_test_SOURCES = bsc_test.c
+bsc_test_LDADD = $(top_builddir)/src/osmo-bsc/libbsc.a \
+			$(top_builddir)/src/libbsc/libbsc.a \
 			$(top_builddir)/src/libmsc/libmsc.a \
 			$(top_builddir)/src/libmgcp/libmgcp.a \
 			$(top_builddir)/src/libtrau/libtrau.a \
diff --git a/openbsc/tests/gprs/Makefile.am b/openbsc/tests/gprs/Makefile.am
index 633c362..44d9965 100644
--- a/openbsc/tests/gprs/Makefile.am
+++ b/openbsc/tests/gprs/Makefile.am
@@ -5,7 +5,7 @@ EXTRA_DIST = gprs_test.ok
 
 noinst_PROGRAMS = gprs_test
 
-gprs_test_SOURCES = gprs_test.c $(top_srcdir)/src/gprs/gprs_utils.c \
-		$(top_srcdir)/src/gprs/gprs_gsup_messages.c
+gprs_test_SOURCES = gprs_test.c
 
-gprs_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
+gprs_test_LDADD = $(top_builddir)/src/gprs/libgprs.a	\
+		  $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/openbsc/tests/smpp/Makefile.am b/openbsc/tests/smpp/Makefile.am
index b3d4568..d36266d 100644
--- a/openbsc/tests/smpp/Makefile.am
+++ b/openbsc/tests/smpp/Makefile.am
@@ -6,7 +6,8 @@ EXTRA_DIST = smpp_test.ok smpp_test.err
 
 noinst_PROGRAMS = smpp_test
 
-smpp_test_SOURCES = smpp_test.c \
-	$(top_builddir)/src/libmsc/smpp_utils.c
-smpp_test_LDADD = $(LIBOSMOCORE_LIBS) \
+smpp_test_SOURCES = smpp_test.c
+smpp_test_LDADD = \
+	$(top_builddir)/src/libmsc/libmsc.a
+	$(LIBOSMOCORE_LIBS) \
 	$(top_builddir)/src/libcommon/libcommon.a
-- 
2.1.4




More information about the OpenBSC mailing list