aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2015-12-15 15:10:31 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2015-12-15 15:10:31 +0100
commit29b9e00355d148be2500d361f2f284e6fa86bab9 (patch)
tree00ef16ebc16fcfb20fa79148bec30d304eda260e
parenta7b02405be1617c6b643fabb34275dc2559b8210 (diff)
Autotoolize the build
Use Autoconf/make for building and autotest for tests
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac34
-rw-r--r--src/Makefile53
-rw-r--r--src/Makefile.am25
-rw-r--r--src/hnbap/Makefile.am (renamed from src/hnbap/Makefile)37
-rw-r--r--src/ranap/Makefile.am (renamed from src/ranap/Makefile)44
-rw-r--r--src/rua/Makefile.am (renamed from src/rua/Makefile)41
-rw-r--r--src/tests/Makefile24
-rw-r--r--src/tests/Makefile.am51
-rw-r--r--src/tests/test-helpers.ok12
-rw-r--r--src/tests/test-hnbap.ok4
-rw-r--r--src/tests/testsuite.at15
12 files changed, 163 insertions, 178 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..af437a6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..f125726
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,34 @@
+AC_INIT([osmo-iuh], [0.0],
+dnl m4_esyscmd([./git-version-gen .tarball-version]),
+ [openbsc@lists.osmocom.org])
+
+AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.6 subdir-objects])
+AC_CONFIG_TESTDIR(src/tests)
+
+dnl kernel style compile messages
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+dnl checks for programs
+AC_PROG_MAKE_SET
+AC_PROG_MKDIR_P
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_RANLIB
+
+PKG_CHECK_MODULES(OSMOCORE, libosmocore)
+PKG_CHECK_MODULES(OSMOGSM, libosmogsm)
+PKG_CHECK_MODULES(OSMOVTY, libosmovty)
+PKG_CHECK_MODULES(ASN1C, libasn1c)
+
+AC_CONFIG_MACRO_DIR([m4])
+
+dnl checks for header files
+AC_HEADER_STDC
+
+AC_OUTPUT(
+ src/Makefile
+ src/hnbap/Makefile
+ src/ranap/Makefile
+ src/rua/Makefile
+ src/tests/Makefile
+ Makefile)
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index f5e4bd3..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-ASN1_ROOT=../asn1/
-ASN1_FILES=HNBAP-CommonDataTypes.asn
-
-ASN1TOSTRUCT:=$(ASN1_ROOT)/utils/asn1tostruct.py
-
-PKG_INCLUDES:=$(shell pkg-config --cflags libosmocore libosmovty libosmogsm libasn1c)
-PKG_LDFLAGS:=$(shell pkg-config --libs libosmocore libosmovty libosmogsm libasn1c)
-
-CFLAGS:=-g -Wall $(PKG_INCLUDES) -Ihnbap/
-LDFLAGS:=$(PKG_LDFLAGS) -lsctp
-
-HNBAP_OBJS=hnbap_encoder.o hnbap_decoder.o hnbap_common.o
-RUA_OBJS=rua_encoder.o rua_decoder.o rua_common.o
-RANAP_OBJS=ranap_common.o #ranap_encoder.o ranap_decoder.o
-
-LIBS=hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a ranap/libosmo-asn1-ranap.a
-
-all: hnbgw
-
-.PHONY: hnbap_encoder.c
-hnbap_encoder.c: $(ASN1_ROOT)/hnbap/HNBAP-PDU-Contents.asn
- $(ASN1TOSTRUCT) -f $<
-
-.PHONY: rua_encoder.c
-rua_encoder.c: $(ASN1_ROOT)/rua/RUA-PDU-Contents.asn
- $(ASN1TOSTRUCT) -p RUA_ -f $<
-
-.PHONY: ranap_encoder.c
-ranap_encoder.c: $(ASN1_ROOT)/ranap/RANAP-PDU-Contents.asn
- $(ASN1TOSTRUCT) -p RANAP_ -f $<
-
-hnbap/libosmo-asn1-hnbap.a:
- $(MAKE) -C hnbap
-
-rua/libosmo-asn1-rua.a:
- $(MAKE) -C rua
-
-ranap/libosmo-asn1-ranap.a:
- $(MAKE) -C ranap
-
-hnbgw: $(HNBAP_OBJS) $(RUA_OBJS) $(RANAP_OBJS) iu_helpers.o asn1helpers.o hnbgw.o hnbgw_hnbap.o hnbgw_rua.o hnbgw_ranap.o $(LIBS)
- $(CC) $(LDFLAGS) -o $@ $^
-
-%.o: %.c
- $(CC) $(CFLAGS) -o $@ -c $^
-
-clean:
- @rm -f hnbgw *.o
-
-mrproper: clean
- $(MAKE) -C hnbap clean
- $(MAKE) -C rua clean
- $(MAKE) -C ranap clean
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..d6498b2
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,25 @@
+SUBDIRS = hnbap rua ranap tests
+
+ASN1_ROOT = $(top_builddir)/asn1/
+ASN1TOSTRUCT = $(ASN1_ROOT)/utils/asn1tostruct.py
+
+AM_CFLAGS = $(OSMOCORE_CFLAGS) $(OSMOVTY_CFLAGS) $(OSMOGSM_CFLAGS) $(ASN1C_CFLAGS) -Ihnbap/
+COMMON_LDADD = -lsctp
+
+bin_PROGRAMS = hnbgw
+
+hnbgw_SOURCES = hnbap_encoder.c hnbap_decoder.c rua_encoder.c rua_decoder.c ranap_common.c rua_common.c hnbap_common.c iu_helpers.c asn1helpers.c hnbgw.c hnbgw_hnbap.c hnbgw_rua.c hnbgw_ranap.c
+hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOVTY_LIBS) $(OSMOGSM_LIBS) $(ASN1C_LIBS) $(COMMON_LDADD) hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a ranap/libosmo-asn1-ranap.a
+
+
+.PHONY: hnbap_encoder.c
+hnbap_encoder.c : $(ASN1_ROOT)/hnbap/HNBAP-PDU-Contents.asn
+ $(ASN1TOSTRUCT) -f $<
+
+.PHONY: rua_encoder.c
+rua_encoder.c : $(ASN1_ROOT)/rua/RUA-PDU-Contents.asn
+ $(ASN1TOSTRUCT) -p RUA_ -f $<
+
+.PHONY: ranap_encoder.c
+ranap_encoder.c : $(ASN1_ROOT)/ranap/RANAP-PDU-Contents.asn
+ $(ASN1TOSTRUCT) -p RANAP_ -f $<
diff --git a/src/hnbap/Makefile b/src/hnbap/Makefile.am
index 3b79237..ec11926 100644
--- a/src/hnbap/Makefile
+++ b/src/hnbap/Makefile.am
@@ -1,4 +1,4 @@
-ASN_MODULE_SOURCES= \
+ASN_MODULE_FILES= \
Criticality.c \
Presence.c \
PrivateIE-ID.c \
@@ -115,7 +115,7 @@ ASN_MODULE_SOURCES= \
PrivateMessage.c \
IE.c
-ASN_MODULE_HEADERS= \
+ASN_MODULE_INC= \
Criticality.h \
Presence.h \
PrivateIE-ID.h \
@@ -232,32 +232,9 @@ ASN_MODULE_HEADERS= \
PrivateMessage.h \
IE.h
-lib_LTLIBRARIES=libsomething.la
-libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
-
-# This file may be used as an input for make(3)
-# Remove the lines below to convert it into a pure .am file
-PKG_INCLUDES:=$(shell pkg-config --cflags libasn1c)
-CFLAGS += -I. $(PKG_INCLUDES)
-OBJS=${ASN_MODULE_SOURCES:.c=.o}
-
-all: libosmo-asn1-hnbap.a
-
-libosmo-asn1-hnbap.a: ${OBJS}
- $(AR) r $@ $^
-
-.SUFFIXES:
-.SUFFIXES: .c .o
-
-.c.o:
- $(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- rm -f libosmo-asn1-hnbap.a
- rm -f $(OBJS)
-
-regen: regenerate-from-asn1-source
-
-regenerate-from-asn1-source:
- asn1c -gen-PER -fnative-types ../../asn1/hnbap/HNBAP-CommonDataTypes.asn ../../asn1/hnbap/HNBAP-Constants.asn ../../asn1/hnbap/HNBAP-IEs.asn ../../asn1/hnbap/HNBAP-PDU.asn
+AM_CFLAGS = $(ASN1C_CFLAGS) -I.
+noinst_LIBRARIES=libosmo-asn1-hnbap.a
+libosmo_asn1_hnbap_a_SOURCES=$(ASN_MODULE_FILES)
+include_HEADERS = $(ASN_MODULE_INC)
+libosmo_asn1_hnbap_a_LIBADD=$(ASN1C_LDADD)
diff --git a/src/ranap/Makefile b/src/ranap/Makefile.am
index 59db793..e3c4c04 100644
--- a/src/ranap/Makefile
+++ b/src/ranap/Makefile.am
@@ -1,4 +1,4 @@
-ASN_MODULE_SOURCES= \
+ASN_MODULE_FILES= \
RANAP_Criticality.c \
RANAP_Presence.c \
RANAP_PrivateIE-ID.c \
@@ -516,7 +516,7 @@ ASN_MODULE_SOURCES= \
RANAP_GERAN-Iumode-RAB-FailedList-RABAssgntResponse.c \
RANAP_RAB-ContextList-RANAP-RelocInf.c
-ASN_MODULE_HEADERS= \
+ASN_MODULE_INC= \
RANAP_Criticality.h \
RANAP_Presence.h \
RANAP_PrivateIE-ID.h \
@@ -1038,39 +1038,9 @@ ASN_MODULE_HEADERS= \
RANAP_RAB-FailedList-EnhRelocInfoRes.h \
RANAP_RAB-ModifyList.h
+AM_CFLAGS = $(ASN1C_CFLAGS) -I.
-lib_LTLIBRARIES=libosmo-asn1-ranap.la
-libsomething_la_SOURCES=$(ASN_MODULE_SOURCES)
-
-# Remove the lines below to convert it into a pure .am file
-PKG_INCLUDES:=$(shell pkg-config --cflags libasn1c)
-CFLAGS += -I. $(PKG_INCLUDES)
-OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
-
-all: libosmo-asn1-ranap.a
-
-libosmo-asn1-ranap.a: ${OBJS}
- $(AR) r $@ $^
-
-.SUFFIXES:
-.SUFFIXES: .c .o
-
-.c.o:
- $(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- rm -f libosmo-asn1-ranap.a
- rm -f $(OBJS)
-
-clean-srcs:
- @rm -f *.c *.h Makefile.am.sample
-
-regen: regenerate-from-asn1-source
-
-regenerate-from-asn1-source: clean clean-srcs
- ASN1C_PREFIX="RANAP_" asn1c -gen-PER ../../asn1/ranap/RANAP-CommonDataTypes.asn ../../asn1/ranap/RANAP-Constants.asn ../../asn1/ranap/RANAP-IEs.asn ../../asn1/ranap/RANAP-PDU.asn
- # remove the local copy of the runtime code
- @rm ANY.* BOOLEAN.* INTEGER.* NativeEnumerated.* NativeInteger.* NULL.* OBJECT_IDENTIFIER.* asn_* OCTET_STRING.* converter-sample.c per_* xer_* constr* der_* ber_* BIT_STRING.*
- # some fixups in erroneous code that asn1c generates
- sed -i '6i#include <constr_CHOICE.h>' RANAP_ChosenEncryptionAlgorithm.h RANAP_ChosenIntegrityProtectionAlgorithm.h RANAP_IMSI.h RANAP_PLMNidentity.h
- sed -i 's/Member/MemberA/' RANAP_LA-LIST.[ch] RANAP_SDU-Parameters.[ch] RANAP_RABParametersList.[ch]
+noinst_LIBRARIES=libosmo-asn1-ranap.a
+libosmo_asn1_ranap_a_SOURCES=$(ASN_MODULE_FILES)
+include_HEADERS=$(ASN_MODULE_INC)
+libosmo_asn1_ranap_a_LIBADD=$(ASN1C_LDADD)
diff --git a/src/rua/Makefile b/src/rua/Makefile.am
index f37a3c1..be0d7cc 100644
--- a/src/rua/Makefile
+++ b/src/rua/Makefile.am
@@ -1,4 +1,4 @@
-ASN_MODULE_SOURCES= \
+ASN_MODULE_FILES= \
RUA_Criticality.c \
RUA_Presence.c \
RUA_ProcedureCode.c \
@@ -35,7 +35,7 @@ ASN_MODULE_SOURCES= \
RUA_PrivateMessage.c \
RUA_IE.c
-ASN_MODULE_HEADERS= \
+ASN_MODULE_INC= \
RUA_Criticality.h \
RUA_Presence.h \
RUA_ProcedureCode.h \
@@ -72,37 +72,10 @@ ASN_MODULE_HEADERS= \
RUA_PrivateMessage.h \
RUA_IE.h
+AM_CFLAGS = $(ASN1C_CFLAGS) -I.
-lib_LTLIBRARIES=libosmo-asn1-rua.la
-libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
-
-# Remove the lines below to convert it into a pure .am file
-PKG_INCLUDES:=$(shell pkg-config --cflags libasn1c)
-CFLAGS += -I. $(PKG_INCLUDES)
-OBJS=${ASN_MODULE_SOURCES:.c=.o}
-
-all: libosmo-asn1-rua.a
-
-libosmo-asn1-rua.a: ${OBJS}
- $(AR) r $@ $^
-
-.SUFFIXES:
-.SUFFIXES: .c .o
-
-.c.o:
- $(CC) $(CFLAGS) -o $@ -c $<
-
-clean:
- rm -f libosmo-asn1-rua.a
- rm -f $(OBJS)
-
-clean-srcs:
- @rm -f *.c *.h Makefile.am.sample
-
-regen: regenerate-from-asn1-source
-
-regenerate-from-asn1-source: clean clean-srcs
- ASN1C_PREFIX="RUA_" asn1c -gen-PER ../../asn1/rua/RUA-CommonDataTypes.asn ../../asn1/rua/RUA-Constants.asn ../../asn1/rua/RUA-IEs.asn ../../asn1/rua/RUA-PDU.asn
- # remove the local copy of the runtime code
- @rm ANY.* BOOLEAN.* INTEGER.* NativeEnumerated.* NativeInteger.* OBJECT_IDENTIFIER.* asn_* OCTET_STRING.* converter-sample.c per_* xer_* constr* der_* ber_* BIT_STRING.*
+noinst_LIBRARIES=libosmo-asn1-rua.a
+libosmo_asn1_rua_a_SOURCES=$(ASN_MODULE_FILES)
+include_HEADERS=$(ASN_MODULES_INC)
+libosmo_asn1_rua_a_LIBADD=$(ASN1C_LDADD)
diff --git a/src/tests/Makefile b/src/tests/Makefile
deleted file mode 100644
index 0cedab9..0000000
--- a/src/tests/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-
-PKG_INCLUDES:=$(shell pkg-config --cflags libosmocore libosmovty libosmogsm libasn1c)
-PKG_LDFLAGS:=$(shell pkg-config --libs libosmocore libosmovty libosmogsm libasn1c)
-
-CFLAGS:=-g -Wall $(PKG_INCLUDES) -I.. -I../hnbap
-LDFLAGS:=$(PKG_LDFLAGS) -lsctp
-
-test-helpers: ../iu_helpers.o ../asn1helpers.o test-helpers.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-test-hnbap: ../iu_helpers.o ../asn1helpers.o ../hnbap_common.o ../hnbap_decoder.o test-hnbap.c ../hnbap/libosmo-asn1-hnbap.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
-
-HNBAP_OBJS=../hnbap_encoder.o ../hnbap_decoder.o ../hnbap_common.o
-RUA_OBJS=../rua_encoder.o ../rua_decoder.o ../rua_common.o
-RANAP_OBJS=../ranap_common.o #ranap_encoder.o ranap_decoder.o
-
-LIBS=../hnbap/libosmo-asn1-hnbap.a ../rua/libosmo-asn1-rua.a ../ranap/libosmo-asn1-ranap.a
-
-hnb-test: $(HNBAP_OBJS) $(RUA_OBJS) $(RANAP_OBJS) ../iu_helpers.o ../asn1helpers.o hnb-test.o $(LIBS)
- $(CC) $(LDFLAGS) -o $@ $^
-
-clean:
- @rm -f hnb-test test-helpers test-hnbap *.o
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
new file mode 100644
index 0000000..f7a9670
--- /dev/null
+++ b/src/tests/Makefile.am
@@ -0,0 +1,51 @@
+AM_CFLAGS = $(OSMOVTY_CFLAGS) $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(ASN1C_CFLAGS) -g -I$(top_builddir)/src -I$(top_builddir)/src/hnbap/
+
+COMMON_LIBS = $(OSMOVTY_LIBS) $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(ASN1C_LIBS) -lsctp
+
+check_PROGRAMS = test-helpers test-hnbap hnb-test
+
+HNBAP_FILES = $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c $(top_builddir)/src/hnbap_encoder.c
+RUA_FILES = $(top_builddir)/src/rua_common.c $(top_builddir)/src/rua_decoder.c $(top_builddir)/src/rua_encoder.c
+RANAP_FILES = $(top_builddir)/src/ranap_common.c ### $(top_builddir)/src/ranap_decoder.c $(top_builddir)/src/ranap_encoder.c
+
+test_helpers_SOURCES = $(top_builddir)/src/iu_helpers.c $(top_builddir)/src/asn1helpers.c test-helpers.c
+test_helpers_LDADD = $(COMMON_LIBS)
+
+test_hnbap_SOURCES = $(top_builddir)/src/iu_helpers.c $(top_builddir)/src/asn1helpers.c $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c test-hnbap.c
+test_hnbap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a
+
+hnb_test_SOURCES = $(top_builddir)/src/iu_helpers.c $(top_builddir)/src/asn1helpers.c $(HNBAP_FILES) $(RUA_FILES) $(RANAP_FILES) hnb-test.c
+hnb_test_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a $(top_builddir)/src/rua/libosmo-asn1-rua.a $(top_builddir)/src/ranap/libosmo-asn1-ranap.a
+
+
+
+# The `:;' works around a Bash 3.2 bug when the output is not writeable.
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME],' && \
+ echo ' [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME],' && \
+ echo ' [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION],' && \
+ echo ' [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING],' && \
+ echo ' [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \
+ echo ' [$(PACKAGE_BUGREPORT)])'; \
+ echo 'm4_define([AT_PACKAGE_URL],' && \
+ echo ' [$(PACKAGE_URL)])'; \
+ } >'$(srcdir)/package.m4'
+
+TESTSUITE = $(srcdir)/testsuite
+
+check-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+
+AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te
+AUTOTEST = $(AUTOM4TE) --language=autotest
+
+$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4
+ $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+ mv $@.tmp $@
+
diff --git a/src/tests/test-helpers.ok b/src/tests/test-helpers.ok
new file mode 100644
index 0000000..4ba4d54
--- /dev/null
+++ b/src/tests/test-helpers.ok
@@ -0,0 +1,12 @@
+Testing Iu helper functions
+pre-encoded: 10325476f8
+decoded: 012345678
+re-encoded: 10325476f8
+Testing asn.1 helper functions
+Encoding 0xdeadbeef to asn.1 bitstring
+Encoded: 20deadbeef
+Decoding back to uint32_t: 0xdeadbeef
+Encoding efbead to 24-bit asn.1 bitstring
+Encoded: 18adbeef
+Decoding string from asn.1: 0123456789012345
+Decoding large string from asn1: 0123456789012345678901234567890
diff --git a/src/tests/test-hnbap.ok b/src/tests/test-hnbap.ok
new file mode 100644
index 0000000..03331c4
--- /dev/null
+++ b/src/tests/test-hnbap.ok
@@ -0,0 +1,4 @@
+Testing asn.1 HNBAP decoding
+HNBAP register request for HNB 10005B9-0010942050@
+HNBAP UE Register request from IMSI 262011234567890
+HNBAP UE Register accept to IMSI 262011234567890
diff --git a/src/tests/testsuite.at b/src/tests/testsuite.at
new file mode 100644
index 0000000..bcea93a
--- /dev/null
+++ b/src/tests/testsuite.at
@@ -0,0 +1,15 @@
+AT_INIT
+AT_BANNER([Regression tests.])
+
+
+AT_SETUP([helpers])
+AT_KEYWORDS([helpers])
+cat $abs_srcdir/test-helpers.ok > expout
+AT_CHECK([$abs_top_builddir/src/tests/test-helpers], [0], [expout])
+AT_CLEANUP
+
+AT_SETUP([hnbap])
+AT_KEYWORDS([hnbap])
+cat $abs_srcdir/test-hnbap.ok > expout
+AT_CHECK([$abs_top_builddir/src/tests/test-hnbap], [0], [expout])
+AT_CLEANUP