These are some minor modifications to make openbsc also run on OSX.
You have to have these MacPorts installed: pkgconfig automake autoconf libtool libdbi libdbi-drivers sqlite3
... and set: export LDFLAGS='-L/opt/local/lib' export CPPFLAGS='-I/opt/local/include'
Everything else should work as usual.
Tobias Engel (3): Define struct iphdr for OSX Do not use --version-script linker flag on OSX Add "extern" keywords
configure.ac | 12 ++++++++++++ include/osmocom/gsm/abis_nm.h | 10 +++++----- src/gb/Makefile.am | 2 +- src/gb/gprs_ns_frgre.c | 2 +- src/gsm/Makefile.am | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-)
Use FreeBSD struct iphdr definition for OSX also. From the commentary in the source file: On BSD the IPv4 struct is called struct ip and instead of iXX the members are called ip_XX. One could change this code to use struct ip but that would require to define _BSD_SOURCE and that might have other complications. Instead make sure struct iphdr is present on FreeBSD. --- src/gb/gprs_ns_frgre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gb/gprs_ns_frgre.c b/src/gb/gprs_ns_frgre.c index 2344381..e557c7e 100644 --- a/src/gb/gprs_ns_frgre.c +++ b/src/gb/gprs_ns_frgre.c @@ -48,7 +48,7 @@ struct gre_hdr { uint16_t ptype; } __attribute__ ((packed));
-#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__APPLE__) /** * On BSD the IPv4 struct is called struct ip and instead of iXX * the members are called ip_XX. One could change this code to use
Wouldn't it be better to use #ifndef __linux__? Who else uses struct iphdr?
Add a check to not use --version-script linker flag if compiled on OSX since it doesn't exist there --- configure.ac | 12 ++++++++++++ src/gb/Makefile.am | 2 +- src/gsm/Makefile.am | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index f119c90..24ddd0c 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,18 @@ LT_INIT([pic-only])
AC_CONFIG_MACRO_DIR([m4])
+dnl check os: some linker flags not available on osx +case $host in +*-darwin*) + ;; +*) + LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map' + LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map' + ;; +esac +AC_SUBST(LTLDFLAGS_OSMOGB) +AC_SUBST(LTLDFLAGS_OSMOGSM) + dnl checks for header files AC_HEADER_STDC AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h) diff --git a/src/gb/Makefile.am b/src/gb/Makefile.am index c137766..04d2108 100644 --- a/src/gb/Makefile.am +++ b/src/gb/Makefile.am @@ -11,7 +11,7 @@ noinst_HEADERS = common_vty.h if ENABLE_GB lib_LTLIBRARIES = libosmogb.la
-libosmogb_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libosmogb.map -version-info $(LIBVERSION) +libosmogb_la_LDFLAGS = $(LTLDFLAGS_OSMOGB) -version-info $(LIBVERSION) libosmogb_la_LIBADD = \ $(top_builddir)/src/libosmocore.la \ $(top_builddir)/src/vty/libosmovty.la \ diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index b72a8d4..0544e0a 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -21,7 +21,7 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c gsm_utils.c \ milenage/aes-encblock.c milenage/aes-internal.c \ milenage/aes-internal-enc.c milenage/milenage.c gan.c
-libosmogsm_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libosmogsm.map -version-info $(LIBVERSION) +libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la
EXTRA_DIST = libosmogsm.map
Without the "extern" keyword the variables in this header file will be seen as empty definitions when compiled on OSX. --- include/osmocom/gsm/abis_nm.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index cc01765..320ac3e 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -14,10 +14,10 @@ enum abis_nm_msgtype; enum gsm_phys_chan_config;
-const enum abis_nm_msgtype abis_nm_reports[4]; -const enum abis_nm_msgtype abis_nm_no_ack_nack[3]; -const enum abis_nm_msgtype abis_nm_sw_load_msgs[9]; -const enum abis_nm_msgtype abis_nm_nacks[33]; +extern const enum abis_nm_msgtype abis_nm_reports[4]; +extern const enum abis_nm_msgtype abis_nm_no_ack_nack[3]; +extern const enum abis_nm_msgtype abis_nm_sw_load_msgs[9]; +extern const enum abis_nm_msgtype abis_nm_nacks[33];
extern const struct value_string abis_nm_obj_class_names[]; extern const struct value_string abis_nm_adm_state_names[]; @@ -26,7 +26,7 @@ const char *abis_nm_nack_cause_name(uint8_t cause); const char *abis_nm_nack_name(uint8_t nack); const char *abis_nm_event_type_name(uint8_t cause); const char *abis_nm_severity_name(uint8_t cause); -const struct tlv_definition abis_nm_att_tlvdef; +extern const struct tlv_definition abis_nm_att_tlvdef; const char *abis_nm_opstate_name(uint8_t os); const char *abis_nm_avail_name(uint8_t avail); const char *abis_nm_test_name(uint8_t test);
Tobias Engel wrote:
export LDFLAGS='-L/opt/local/lib' export CPPFLAGS='-I/opt/local/include'
What requires these flags to be set manually?
These are the locations where software gets installed by MacPorts
Which software, in this case? The purpose of pkgconfig is to avoid dealing with these flags manually.
//Peter
On 24.10.12 19:37, Peter Stuge wrote:
Tobias Engel wrote:
export LDFLAGS='-L/opt/local/lib' export CPPFLAGS='-I/opt/local/include'
What requires these flags to be set manually?
These are the locations where software gets installed by MacPorts
Which software, in this case? The purpose of pkgconfig is to avoid dealing with these flags manually.
libdbi, for example. There is no .pc file installed with the libdbi port:
$ port contents libdbi Port libdbi contains: /opt/local/include/dbi/dbd.h /opt/local/include/dbi/dbi-dev.h /opt/local/include/dbi/dbi.h /opt/local/lib/libdbi.1.dylib /opt/local/lib/libdbi.a /opt/local/lib/libdbi.dylib /opt/local/lib/libdbi.la
-Tobias
Hi Tobias,
On Wed, Oct 24, 2012 at 05:52:50PM +0200, Tobias Engel wrote:
These are some minor modifications to make openbsc also run on OSX.
thanks for the patches, I've pushed the libosmocore ones now.