From 00804e9fc149e1c389a0054a397aa4e5189371e3 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 1 Jun 2018 11:07:00 +0930 Subject: [PATCH] Make servald_features() available to iOS app Add servald_features.o to the libservaldaemon.a static library (was only in libservaldaemon.so before), and create the "servald_features.h" public header so that an iOS app's Swift code can simply refer to the servald_features() function in order to link in all the Serval DNA daemon features. --- Makefile.in | 27 +++++++++++++++++++++------ headerfiles.mk | 1 + servald_features.c | 1 + servald_features.h | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 servald_features.h diff --git a/Makefile.in b/Makefile.in index 1d43e10e..dda7639d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -354,21 +354,36 @@ $(SIMULATOR_OBJS): Makefile $(CONFIG_H) $(PREFIXED_HEADERS) $(LIBSODIUM_HEADER # Rules for main targets. +# The daemon static library. This is linked into any statically-linked daemon, +# such as the Swift Daemon API module's static library, and contains all the +# features of the full Serval DNA daemon. It includes servald_features.o so +# that a statically-linked server can simply reference servald_features() in +# order to force all the features to be linked in. It also includes all the +libservaldaemon.a: _servald.a $(LIBSODIUM_A) + @$(call MERGE_STATIC_LIBS, $@, $^) + +# This intermediate library exists only so that libservaldaemon.a can be +# constructed by merging two static libraries. .INTERMEDIATE: _servald.a -_servald.a: $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o +_servald.a: $(SERVALD_OBJS) \ + $(OBJSDIR_TOOLS)/version.o \ + $(OBJSDIR_SERVALD)/servald_features.o @echo AR $@ @$(RM) $@ @$(AR) -cr $@ $^ -libservaldaemon.a: _servald.a $(LIBSODIUM_A) - @$(call MERGE_STATIC_LIBS, $@, $^) - +# The daemon shared library. This is linked in at run-time by the JNI +# interface using dlopen(3). The servald_features.o object is explicitly +# included here, even though it is also available in libservaldaemon.a, because +# without it, many feature-specific .o object files would not be pulled into +# the shared library, and the Java API would then fail at run-time with errors +# like: +# java.lang.UnsatisfiedLinkError: libservaldaemon.so: undefined symbol: __stop_httpd libservaldaemon.so: \ $(OBJSDIR_SERVALD)/servald_features.o \ $(OBJSDIR_SERVALD)/log_output_console.o \ $(SERVAL_DAEMON_JNI_OBJS) \ - _servald.a \ - $(LIBSODIUM_A) + libservaldaemon.a @echo LINK $@ @$(CC) -Wall -shared -o $@ $(LDFLAGS) $(filter %.o, $^) $(filter %.a, $^) diff --git a/headerfiles.mk b/headerfiles.mk index a0b38dbf..aa4cf242 100644 --- a/headerfiles.mk +++ b/headerfiles.mk @@ -33,6 +33,7 @@ LIB_HDRS= \ # are exposed by the iOS framework module, so they are accessible to Swift code # in Xcode projects. PUBLIC_HDRS= \ + servald_features.h \ commandline.h \ constants.h \ conf.h \ diff --git a/servald_features.c b/servald_features.c index 3a784ad1..681dd60a 100644 --- a/servald_features.c +++ b/servald_features.c @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "servald_features.h" #include "feature.h" void servald_features() diff --git a/servald_features.h b/servald_features.h new file mode 100644 index 00000000..56ec4642 --- /dev/null +++ b/servald_features.h @@ -0,0 +1,20 @@ +/* +Serval DNA daemon features +Copyright (C) 2018 Flinders University + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +void servald_features();