From 83457922813ace30efa355ed00b8967e64218aee Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 26 Aug 2016 23:56:44 +0200 Subject: [PATCH] build: fix ranap gen, use same for gen hnbap and rua gen fix extraneous rebuild for each make invocation: touch the ranap.stamp file in src/ as the make target suggests. fix for 'make distcheck': ranap gen: move generated sources to builddir, not srcdir. Thus we also -I the builddir include to pick up those headers. hnbap and rua have the same situation as ranap (they generate numerous files from a single make rule). Use the same makefile semantics for those two (commit for ranap gen omitted the same changes for hnbap and rua). The generated headers are thus moved to include/osmocom/*/, so adjust #include statements accordingly (*_common.h, *_ies_defs.h). Also move hnbap_common.h to include/osmocom/hnbap and rua_common.h to include/osmocom/rua, since the *_ies_defs.h want to include them; and since *_ies_defs.h are now in include/osmocom/*, we want a '' include now. Also adjust gitignore. Change-Id: I32213666fcdfc144008fa7d46497c0938d093e86 --- .gitignore | 4 ++ include/osmocom/hnbap/Makefile.am | 1 + {src => include/osmocom/hnbap}/hnbap_common.h | 0 include/osmocom/ranap/Makefile.am | 4 +- include/osmocom/rua/Makefile.am | 1 + {src => include/osmocom/rua}/rua_common.h | 0 src/.gitignore | 3 -- src/Makefile.am | 39 ++++++++++++++----- src/hnbap_common.c | 2 +- src/hnbgw_hnbap.c | 4 +- src/hnbgw_rua.c | 4 +- src/rua_common.c | 2 +- src/rua_msg_factory.c | 4 +- src/tests/hnb-test-rua.c | 2 +- src/tests/hnb-test.c | 4 +- src/tests/test-hnbap.c | 4 +- 16 files changed, 51 insertions(+), 27 deletions(-) rename {src => include/osmocom/hnbap}/hnbap_common.h (100%) rename {src => include/osmocom/rua}/rua_common.h (100%) diff --git a/.gitignore b/.gitignore index b2538a76..e1430f98 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,9 @@ src/osmo-hnbgw tags libosmo-ranap.pc m4 +gen_hnbap.stamp +gen_rua.stamp gen_ranap.stamp +include/osmocom/hnbap/hnbap_ies_defs.h +include/osmocom/rua/rua_ies_defs.h include/osmocom/ranap/ranap_ies_defs.h diff --git a/include/osmocom/hnbap/Makefile.am b/include/osmocom/hnbap/Makefile.am index 7ab5d7f8..83654cb8 100644 --- a/include/osmocom/hnbap/Makefile.am +++ b/include/osmocom/hnbap/Makefile.am @@ -1,4 +1,5 @@ noinst_HEADERS = \ + hnbap_common.h hnbap_ies_defs.h \ AccessResult.h \ Access-stratum-release-indicator.h \ AdditionalNeighbourInfoList.h \ diff --git a/src/hnbap_common.h b/include/osmocom/hnbap/hnbap_common.h similarity index 100% rename from src/hnbap_common.h rename to include/osmocom/hnbap/hnbap_common.h diff --git a/include/osmocom/ranap/Makefile.am b/include/osmocom/ranap/Makefile.am index 13f1e1c1..4728ac83 100644 --- a/include/osmocom/ranap/Makefile.am +++ b/include/osmocom/ranap/Makefile.am @@ -3,8 +3,8 @@ # the build process wants this header file, it should first build # src/ranap_encoder.c and src/ranap_decoder.c. # This rule sucks: -ranap_ies_defs.h: $(top_builddir)/src/ranap_encoder.c - make -C $(top_builddir)/src/ ranap_encoder.c +ranap_ies_defs.h: + $(MAKE) -C $(top_builddir)/src/ gen_ranap.stamp ranap_HEADERS = \ ranap_ies_defs.h \ diff --git a/include/osmocom/rua/Makefile.am b/include/osmocom/rua/Makefile.am index 059dfb8c..8e8896dc 100644 --- a/include/osmocom/rua/Makefile.am +++ b/include/osmocom/rua/Makefile.am @@ -1,4 +1,5 @@ noinst_HEADERS = \ + rua_common.h rua_ies_defs.h \ RUA_Ansi-41-IDNNS.h \ RUA_Cause.h \ RUA_CauseMisc.h \ diff --git a/src/rua_common.h b/include/osmocom/rua/rua_common.h similarity index 100% rename from src/rua_common.h rename to include/osmocom/rua/rua_common.h diff --git a/src/.gitignore b/src/.gitignore index 9384c58e..55bca01b 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,13 +1,10 @@ hnbap_decoder.c hnbap_encoder.c -hnbap_ies_defs.h rua_decoder.c rua_encoder.c -rua_ies_defs.h ranap_decoder.c ranap_encoder.c -ranap_ies_defs.h hnbgw diff --git a/src/Makefile.am b/src/Makefile.am index 17e60e2b..ffdfef82 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,25 +3,48 @@ SUBDIRS = hnbap rua ranap tests # Build {hnbap,rua,ranap}_{encoder,decoder}.c using asn1tostruct ASN1_ROOT = $(top_builddir)/asn1/ ASN1TOSTRUCT = $(ASN1_ROOT)/utils/asn1tostruct.py -BUILT_SOURCES = hnbap_decoder.c hnbap_encoder.c rua_decoder.c rua_encoder.c gen_ranap.stamp +BUILT_SOURCES = hnbap_decoder.c hnbap_encoder.c rua_decoder.c rua_encoder.c \ + gen_hnbap.stamp gen_rua.stamp gen_ranap.stamp -hnbap_encoder.c hnbap_decoder.c hnbap_ies_defs.h: $(ASN1_ROOT)/hnbap/HNBAP-PDU-Contents.asn $(ASN1TOSTRUCT) +gen_hnbap.stamp: $(ASN1_ROOT)/hnbap/HNBAP-PDU-Contents.asn $(ASN1TOSTRUCT) $(ASN1TOSTRUCT) -f $< +# We also need to replace the include in the newly generated .c files: + sed -i 's,^#include "hnbap_ies_defs.h",#include ,' hnbap_encoder.c hnbap_decoder.c + sed -i 's,^#include "hnbap_common.h",#include ,' hnbap_encoder.c hnbap_decoder.c hnbap_ies_defs.h + mv hnbap_ies_defs.h $(top_builddir)/include/osmocom/hnbap/ +# this is ugly ^. hnbap_ies_defs.h is generated from asn1tostruct.py here, but +# it should live in include/osmocom/hnbap/. + touch $(top_builddir)/src/$@ + +hnbap_decoder.c hnbap_encoder.c: gen_hnbap.stamp -rua_encoder.c rua_decoder.c rua_ies_defs.h: $(ASN1_ROOT)/rua/RUA-PDU-Contents.asn $(ASN1TOSTRUCT) +gen_rua.stamp: $(ASN1_ROOT)/rua/RUA-PDU-Contents.asn $(ASN1TOSTRUCT) $(ASN1TOSTRUCT) -p RUA_ -f $< +# We also need to replace the include in the newly generated .c files: + sed -i 's,^#include "rua_ies_defs.h",#include ,' rua_encoder.c rua_decoder.c + sed -i 's,^#include "rua_common.h",#include ,' rua_encoder.c rua_decoder.c rua_ies_defs.h + mv rua_ies_defs.h $(top_builddir)/include/osmocom/rua/ +# this is ugly ^. rua_ies_defs.h is generated from asn1tostruct.py here, but +# it should live in include/osmocom/rua/. + touch $(top_builddir)/src/$@ + +rua_decoder.c rua_encoder.c: gen_rua.stamp gen_ranap.stamp: $(ASN1_ROOT)/ranap/RANAP-PDU-Contents.asn $(ASN1TOSTRUCT) $(ASN1TOSTRUCT) -p RANAP_ -f $< # We also need to replace the include in the newly generated .c files: sed -i 's,^#include "ranap_ies_defs.h",#include ,' ranap_encoder.c ranap_decoder.c sed -i 's,^#include "ranap_common.h",#include ,' ranap_encoder.c ranap_decoder.c ranap_ies_defs.h - mv ranap_ies_defs.h $(top_srcdir)/include/osmocom/ranap/ + mv ranap_ies_defs.h $(top_builddir)/include/osmocom/ranap/ # this is ugly ^. ranap_ies_defs.h is generated from asn1tostruct.py here, but # it should live in include/osmocom/ranap/. - touch $(top_builddir)/$@ + touch $(top_builddir)/src/$@ + +ranap_decoder.c ranap_encoder.c: gen_ranap.stamp -AM_CFLAGS = -I$(top_srcdir)/include $(OSMOCORE_CFLAGS) $(OSMOVTY_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMONETIF_CFLAGS) $(ASN1C_CFLAGS) $(OSMOSIGTRAN_CFLAGS) +AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + $(OSMOCORE_CFLAGS) $(OSMOVTY_CFLAGS) $(OSMOGSM_CFLAGS) \ + $(OSMONETIF_CFLAGS) $(ASN1C_CFLAGS) $(OSMOSIGTRAN_CFLAGS) COMMON_LDADD = -lsctp # build the shared RANAP library @@ -37,9 +60,7 @@ libosmo_ranap_la_SOURCES = ranap_common.c ranap_encoder.c ranap_decoder.c ranap_ # bin_PROGRAMS = osmo-hnbgw -noinst_HEADERS = hnbap_common.h hnbap_ies_defs.h \ - rua_common.h rua_ies_defs.h \ - context_map.h hnbgw.h hnbgw_cn.h \ +noinst_HEADERS = context_map.h hnbgw.h hnbgw_cn.h \ hnbgw_hnbap.h hnbgw_rua.h hnbgw_ranap.h osmo_hnbgw_SOURCES = hnbap_encoder.c hnbap_decoder.c hnbap_common.c \ diff --git a/src/hnbap_common.c b/src/hnbap_common.c index f321a1c0..2cd65191 100644 --- a/src/hnbap_common.c +++ b/src/hnbap_common.c @@ -24,7 +24,7 @@ #include #include -#include "hnbap_common.h" +#include #include "hnbgw.h" static const struct value_string hnbap_cause_radio_vals[] = { diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c index 5246b814..c329fe43 100644 --- a/src/hnbgw_hnbap.c +++ b/src/hnbgw_hnbap.c @@ -28,11 +28,11 @@ #include #include "asn1helpers.h" +#include #include #include "hnbgw.h" -#include "hnbap_common.h" -#include "hnbap_ies_defs.h" +#include #define IU_MSG_NUM_IES 32 #define IU_MSG_NUM_EXT_IES 32 diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c index a6f01001..fc22bfc9 100644 --- a/src/hnbgw_rua.c +++ b/src/hnbgw_rua.c @@ -34,8 +34,8 @@ #include "hnbgw.h" #include "hnbgw_ranap.h" -#include "rua_common.h" -#include "rua_ies_defs.h" +#include +#include #include "context_map.h" static int hnbgw_rua_tx(struct hnb_context *ctx, struct msgb *msg) diff --git a/src/rua_common.c b/src/rua_common.c index fcb873e0..a5ab044b 100644 --- a/src/rua_common.c +++ b/src/rua_common.c @@ -23,7 +23,7 @@ #include -#include "rua_common.h" +#include #include "hnbgw.h" extern int asn1_xer_print; diff --git a/src/rua_msg_factory.c b/src/rua_msg_factory.c index b6645096..0bce3263 100644 --- a/src/rua_msg_factory.c +++ b/src/rua_msg_factory.c @@ -1,8 +1,8 @@ #include #include -#include "rua_common.h" -#include "rua_ies_defs.h" +#include +#include #include "rua_msg_factory.h" #include "asn1helpers.h" #include "hnbgw.h" diff --git a/src/tests/hnb-test-rua.c b/src/tests/hnb-test-rua.c index 69c41eb8..a2188521 100644 --- a/src/tests/hnb-test-rua.c +++ b/src/tests/hnb-test-rua.c @@ -1,6 +1,6 @@ #include -#include "../rua_ies_defs.h" +#include #include "hnb-test-layers.h" diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c index af87376d..2c41199f 100644 --- a/src/tests/hnb-test.c +++ b/src/tests/hnb-test.c @@ -52,8 +52,8 @@ #include "hnb-test.h" #include "hnb-test-layers.h" -#include "hnbap_common.h" -#include "hnbap_ies_defs.h" +#include +#include #include "rua_msg_factory.h" #include "asn1helpers.h" #include diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c index c6e7d94f..ef460705 100644 --- a/src/tests/test-hnbap.c +++ b/src/tests/test-hnbap.c @@ -22,8 +22,8 @@ #include #include "asn1helpers.h" -#include "hnbap_common.h" -#include "hnbap_ies_defs.h" +#include +#include #include "test_common.h" #include