diff mbox

[2/4] Add subdir-objects automake option

Message ID 1434489811-10097-3-git-send-email-mail@rotty.xx.vu
State Superseded
Headers show

Commit Message

mail@rotty.xx.vu June 16, 2015, 9:23 p.m. UTC
From: Andreas Rottmann <a.rottmann@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(-)

Comments

Holger Freyther June 17, 2015, 5:47 a.m. UTC | #1
> On 16 Jun 2015, at 23:23, Andreas Rottmann <mail@rotty.xx.vu> wrote:
> 
> From: Andreas Rottmann <a.rottmann@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.

That automake behavior is shameful. What would be the effort to get rid
off the recursive make?
Alexander Huemer June 17, 2015, 8:04 a.m. UTC | #2
On Wed, Jun 17, 2015 at 07:47:45AM +0200, Holger Freyther wrote:
> > On 16 Jun 2015, at 23:23, Andreas Rottmann <mail@rotty.xx.vu> wrote:
> > 
> > From: Andreas Rottmann <a.rottmann@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.
> 
> That automake behavior is shameful. What would be the effort to get rid
> off the recursive make?

AFAIR there was a patch series a few years ago from Diego Elio Pettenò 
(flameeyes) that changed the build system behavior of several osmo* 
subprojects to use non recursive make. There were objections against 
them, so they were not merged.

Kind regards,
-Alex
Holger Freyther June 17, 2015, 11:36 a.m. UTC | #3
> On 17 Jun 2015, at 10:04, Alexander Huemer <alexander.huemer@xx.vu> wrote:
> 
> 
> AFAIR there was a patch series a few years ago from Diego Elio Pettenò 
> (flameeyes) that changed the build system behavior of several osmo* 
> subprojects to use non recursive make. There were objections against 
> them, so they were not merged.

hehe, but we did merge parts of libosmocore? E.g. all test directories are
non-recursive there?
Alexander Huemer June 17, 2015, 12:04 p.m. UTC | #4
Hi!

On Wed, Jun 17, 2015 at 01:36:05PM +0200, Holger Freyther wrote:
> 
> > On 17 Jun 2015, at 10:04, Alexander Huemer <alexander.huemer@xx.vu> wrote:
> > 
> > 
> > AFAIR there was a patch series a few years ago from Diego Elio Pettenò 
> > (flameeyes) that changed the build system behavior of several osmo* 
> > subprojects to use non recursive make. There were objections against 
> > them, so they were not merged.
> 
> hehe, but we did merge parts of libosmocore? E.g. all test directories are
> non-recursive there?

The relevant commits with build system changes that were merged seem to 
be these:

7e007e0f87c4a06396ef46081ef1d69a4bdc11ae
build: avoid multi-level recursion for src/ directory.

d471a2192015440ec9b8c409268ba6433511f421
build: simplify headers management and remove recursion

ea0e1eca2bc32b531242a3b0a3c471e492a6f493
build: simplify test handling and speed up build.

I can dig up the unmerged ones from the old ML if that's of any value.

Kind regards,
-Alex
Alexander Huemer June 17, 2015, 12:30 p.m. UTC | #5
Hi!

On Wed, Jun 17, 2015 at 02:04:45PM +0200, Alexander Huemer wrote:
> On Wed, Jun 17, 2015 at 01:36:05PM +0200, Holger Freyther wrote:
> > 
> > > On 17 Jun 2015, at 10:04, Alexander Huemer <alexander.huemer@xx.vu> wrote:
> > > 
> > > 
> > > AFAIR there was a patch series a few years ago from Diego Elio Pettenò 
> > > (flameeyes) that changed the build system behavior of several osmo* 
> > > subprojects to use non recursive make. There were objections against 
> > > them, so they were not merged.
> > 
> > hehe, but we did merge parts of libosmocore? E.g. all test directories are
> > non-recursive there?
> 
> The relevant commits with build system changes that were merged seem to 
> be these:
> 
> 7e007e0f87c4a06396ef46081ef1d69a4bdc11ae
> build: avoid multi-level recursion for src/ directory.
> 
> d471a2192015440ec9b8c409268ba6433511f421
> build: simplify headers management and remove recursion
> 
> ea0e1eca2bc32b531242a3b0a3c471e492a6f493
> build: simplify test handling and speed up build.
> 
> I can dig up the unmerged ones from the old ML if that's of any value.

Actually, all patches from flameeyes for libosmocore were merged.

Here are the overall numbers. merged/sent with commit summary lines of 
the unmerged patches.

libosmocore 12/12

libosmo-abis 7/7

libosmo-dsp 3/5
build: flatten build to a single Makefile.am
build: avoid running unused checks

libosmo-sccp 0/7
mtp_pcap: mark structure as constant as well as static.
m2ua: remove unset talloc context.
build: flatten headers installation in include/Makefile.am
build: set automake options in configure.ac only.
build: simplify test build
m2ua: accept a constant parameter in m2ua_from_msg.
tests: remove warnings and make more data constant.

osmo-gmr 0/7
build: avoid recursing into include/ for non-installed headers.
build: simplify building by avoiding recursion in src/.
gmr1_rx: remove to variables set but not used
build: simplify documentation install.
build: remove unused test and get rid of libtool.
build: move automake options to configure.ac
gitignore: ignore src/gmr1_gen_mat as well.

sam7-util 2/2

Kind regards,
-Alex
diff mbox

Patch

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@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