Commit Graph

160 Commits

Author SHA1 Message Date
Andrew Bettison
1efe6686fc Use config.h instead of -DHAVE_FOO=1
swiftc(1) requires every -D option to be prefixed with -Xcc, which
is not easy to achieve using autoconf.

Now instead of setting configuration macros like HAVE_LSEEK64 on the
command line using -D, they are defined in config.h, which is generated
by ./configure, ignored by Git, and included by all headers and source
files that use any configuration macro.

The dependency on Makefile has been replaced with a dependency on
Makefile.in and config.h, which helps avoid some redundant full
recompiles after running ./configure, because the configure script
does not overwrit config.h if its content does not change.
2016-10-19 16:27:20 +10:30
Andrew Bettison
42f62d2b8b Move JNI setInstancePath() into own source file 2016-10-19 16:26:00 +10:30
Andrew Bettison
a3f3de571a Minor fixes to Makefile.in 2016-10-19 10:54:44 +10:30
Andrew Bettison
8325aacc5d Fix broken Batphone build
Recent changes such as the Makefile.in overhaul and the introduction of
feature-driven linking broke the Android build.  This commit fixes the
breakage:
- detects the presence of gettid() in configure.ac and only defines
  gettid() in serval.c if HAVE_GETTID is not defined
- builds libserval.so not libservald.so on Android, to avoid a conflict
  on the module name "servald" in Android.mk
- renames cli_cleanup() to command_cleanup(), defines it in
  commandline.h instead of cli.h, and supplies it in android.c
- supplies the 'keyring' global in android.c
- removes log_stderr.c from the Android build, since it conflicted with
  log.c
2016-10-19 09:52:07 +10:30
Andrew Bettison
71cbe86566 Switch to feature-driven linking
This introduces a new way of linking Serval executables and dynamic
libraries from static libraries like libservald.a -- called
"feature-driven" linking.

The Makefile now links servald and serval-tests from libservald.a,
rather than from an explicit list of object (.o) files.  Thanks to the
section-based method for registering functions such as HTTP handlers,
CLI commands and MDP handlers, these object files had become
"stand-alone" and hence were no longer included in the link because
there was no unresolved reference that required them to be linked in.

The new "feature.h" provides the DECLARE_FEATURE(name) macro that each
stand-alone source file uses to declare the named feature(s) it
provides.  Each executable can call the USE_FEATURE(name) macro in any
of its explicitly-linked source files to cause the corresponding
object(s) to be included in the link, eg, servald_features.c.

The DEFINE_BINDING() macro has been extended so that every individual
MDP binding is given a feature name based on its port number macro, eg,
"mdp_binding_MDP_PORT_ECHO".

Some features have been factored into their own separate source files so
they can be omitted or included in a build independently of each other:
- the MDP bindings for MDP_PORT_DNALOOKUP, MDP_PORT_ECHO,
  MDP_PORT_TRACE, MDP_PORT_KEYMAPREQUEST, MDP_PORT_RHIZOME_xxx,
  MDP_PORT_PROBE, MDP_PORT_STUN, MDP_PORT_STUNREQ
- the CLI "log" and "echo" commands
- the CLI "rhizome direct" command

The JNI source files are only compiled if the <jni.h> header is present,
otherwise they are omitted from libservald.so.
2016-10-19 09:33:01 +10:30
Andrew Bettison
c8bf8a7733 Refactor JNI out of CLI and server main loop
The CLI and server main loop now have no conditional JNI code.  All JNI
code has been moved into separate source files, which #include the new
"jni_common.h" instead of <jni.h>.  The "cli.h" header no longer
includes <jni.h>, so the rest of the Serval source code is now
unaffected by JNI definitions.

The 'cf_limbo' global variable is now thread-local, so that each thread
has its own independent copy of the loaded configuration.  The JNI
server entry point now calls cf_init() once.  The new 'cf_initialised'
flag prevents clobbering the config state by redundant calls to
cf_init().

The CLI "stop" command now sends SIGHUP to the specific thread in which
the server is running.  This is achieved by writing the PID and TID
(Linux Thread ID) into the pidfile, separated by a space, on systems
that support the Linux gettid() and tgkill() system calls.  The server's
signal handler has been overhauled, and its logging improved.
2016-10-13 16:23:18 +10:30
Andrew Bettison
29a771e315 Overhaul Makefile.in
Changed the built libraries and updated INSTALL.md accordingly:
- the 'servaldwrap' executable is now built
- libservald.[a,so] now contains the full daemon executable
- libservalclient.[a,so] contains the client library
- libserval.a is no longer built

Building the 'servaldwrap' executable is a step towards ensuring that
the libservald.so library can be linked and executed, without requiring
an Android build to reveal any failure.

Added the SOURCE_PREFIX variable that allows the make to be invoked from
within any current working directory, not just the serval-dna
repository's root directory.

Fixed the serval_version.o target to invoke the version_string.sh
script with the --repository=DIR option, so that the build will work
even if the current working directory is not within the serval-dna
repository.

Re-ordered and added some comments for clarity, and added some missing
.PHONY declarations.
2016-10-13 16:23:09 +10:30
Andrew Bettison
4b2060554e Rename configure.in to configure.ac 2016-10-13 16:05:58 +10:30
Andrew Bettison
e34141a2a5 Upgrade to SQLite 3.14.2
Ignores a variety of warnings when compiling sqlite3.c.

Uses the new sqlite3_trace_v2() function for logging SQL statements, now
that sqlite3_trace() and sqlite3_profile() are deprecated.

Fixes a rhizomeops test failure caused because SQLite 3.12 increased the
default block size from 1024 to 4096, causing the fixed overhead of an
empty Rhizome db to exceed 32KB.  This caused the test to fail because
the first "file add" failed.  Now the test fixture adapts to the fixed
overhead.

Deletes the SQLite 3.10.2 source amalgamation.
2016-09-21 22:47:35 +09:30
Jeremy Lakeman
e15e332072 Swap from included nacl to host libsodium 2016-05-09 10:32:04 +09:30
Andrew Bettison
f0d3dec67a Suppress sqlite.c compile warnings with gcc 5.3 2016-02-01 13:49:53 +10:30
Jeremy Lakeman
7b6f167b9b Update sqlite 2016-01-27 16:27:03 +10:30
Jeremy Lakeman
2f7fa26791 Expand m4 section attribute detection to include linking the resulting object
clang on linux was being detected as if it was using darwin's macho format.
2016-01-19 11:23:04 +10:30
Andrew Bettison
ae18d765a7 Fix OSX build errors 2016-01-18 21:16:01 +10:30
Jeremy Lakeman
0c275e67ef Clean up compilation warnings 2015-10-19 13:45:57 +10:30
Andrew Bettison
3c18b7a3d9 Add missing header dependencies to Makefile 2015-09-21 12:45:03 +09:30
Jeremy Lakeman
e680ccb0ec Update test_cli to match recent config changes 2015-03-30 13:50:23 +10:30
Jeremy Lakeman
7bc253e844 Refactor source and build process to split out test commands 2014-12-01 13:26:27 +10:30
Jeremy Lakeman
d773207953 Improve warning messages when Makefile is stale 2014-12-01 13:26:11 +10:30
Andrew Bettison
606f087dd5 Merge latest Rhizome Java API into development 2014-07-11 12:29:24 +09:30
Andrew Bettison
838f971850 Fix Makefile.in for OpenWRT build
Was not passing $(CFLAGS) $(DEFS) to compile servald_version.c, which
provoked a "cc1: note: someone does not honour COPTS correctly, passed 0
times" warning

Also was not doing "mkdir -p opts" before the compile, which produced an
"opts/version.o: No such file or directory: error
2014-07-02 10:09:13 +09:30
Andrew Bettison
c5d3069d82 'make all' now makes libserval.so 2014-06-30 11:11:01 +09:30
Jeremy Lakeman
bdac56cdb4 Omit more features of sqlite, and fix warnings 2014-06-30 10:14:12 +09:30
Jeremy Lakeman
77dc7fc14c Disable and remove pthreads to support compiling with clang 2014-06-11 20:32:16 +09:30
Andrew Bettison
3d537f9645 Improve test framework: test coverage support 2014-06-06 14:47:54 +09:30
Andrew Bettison
15c37fdcea Improve Makefile dependencies 2014-05-29 11:04:09 +09:30
Andrew Bettison
21f51965c1 Overhaul Makefile and header files
Make .o files in separate subdirectories for servald and library
Factor struct __sourceloc and __WHENCE__ from "log.h" into "whence.h"
Factor sid_t etc from "serval.h" into "serval_types.h"
Factor rhizome_bid_t etc from "rhizome.h" into "rhizome_types.h"
Do not include "serval.h" in library sources
Add log_stderr.c and logMessage.c for stand-alone executables
2014-05-26 15:36:26 +09:30
Jeremy Lakeman
7420f46653 Create new AF_UNIX based network simulator 2014-05-23 10:47:22 +09:30
Jeremy Lakeman
7bd34b7d9b Don't rebuild version.o if nothing has changed 2014-05-12 13:44:50 +09:30
Jeremy Lakeman
4a2b54de1b Warn if Makefile is out of date 2014-05-12 13:44:50 +09:30
Jeremy Lakeman
8e7d13fd27 Treat all compile warnings as errors 2014-05-02 15:44:39 +09:30
Jeremy Lakeman
1228df2b70 Remove bitrot related to voip testing 2014-04-07 15:48:10 +09:30
Andrew Bettison
53c1b1c04c Filesystem Heirarchy Standard (FHS) paths
If no instance directory specified, then use paths like
/etc/serval/serval.conf
/var/cache/serval
/var/log/serval
/var/run/serval
etc. for files, instead of all in a single directory.

Log all directory creation as INFO messages.

Interpretation of log.file.directory_path has changed slightly.

Updated servald configuration tech doc.
2014-03-26 15:35:43 +10:30
Andrew Bettison
e1949c15de Refactor Makefile.in and Android.mk
Immediate benefit: does not recompile sqlite3.c when any Serval header
file is touched.

Also makes it a bit clearer which source files are imported and which
can be used in "client" binaries other than servald.
2014-03-04 21:53:01 +10:30
Andrew Bettison
8e9440860b version_string.sh uses VERSION.txt if not in a Git repo 2014-03-03 15:21:53 +10:30
Andrew Bettison
30590ab140 ./configure checks for GCC stack smashing protection 2014-03-03 15:21:53 +10:30
Jeremy Lakeman
89b1ca2e2f Tidy up android build file for inclusion in other projects 2014-03-02 17:46:11 -08:00
gardners
0c8fcb0128 Make -z relro option conditional on it being available. 2014-02-18 14:04:08 +10:30
Jeremy Lakeman
a7b43581ce Rename libservald to libserval for consistency with android build 2014-02-12 14:29:13 +10:30
Andrew Bettison
4cf97b7d41 Do not generate COPYRIGHT.txt in normal build
Only when making the "copyright" target.  Otherwise Makefile is broken
for developers without serval-tools and Python.
2013-12-11 15:10:01 +10:30
Petter Reinholdtsen
4d80c7c5db Merge branch 'development' into warnings-security 2013-12-07 17:57:46 +01:00
Jeremy Lakeman
bc34c642ee Add link arguments so the linker can find math functions 2013-12-06 12:50:08 +10:30
Andrew Bettison
9c124c8ba8 Add "servald version" command and "make copyright"
New COPYRIGHT.txt is regenerated manually using "make copyright" which
invokes the sp-copyright-tool utility from the serval-tools repo.
2013-12-05 14:32:01 +10:30
Andrew Bettison
56309886f3 Merge branch 'naf4' into 'development'
Copyright notices added to most source files and headers

New 'config_test' make target

Add RHIZOME_BUNDLE_ID_xxx, deprecate RHIZOME_MANIFEST_ID_xxx

Consolidate Rhizome string functions
2013-12-04 02:09:30 +10:30
Andrew Bettison
bf84c5815f Fix 'make install' target, add 'make uninstall'
Define $(sbindir) and $(exec_prefix)

Define $(INSTALL), $(INSTALL_PROGRAM) and $(INSTALL_DATA)

Use $(RM) instead of rm -f
2013-12-03 14:29:13 +10:30
Andrew Bettison
92253ca97d Revive config_test.c
Move config-dependent code (recvwithttl) from net.c to mdp_net.c (new)

Move log-implementation-independent code from log.c to log_util.c (new)

Build config_test binary in Makefile
2013-11-21 16:05:17 +10:30
Petter Reinholdtsen
e7afd5d165 Make sure './configure && make all install' work. 2013-10-13 10:09:17 +02:00
Petter Reinholdtsen
76f3169ec4 Enable more warnings and use the flags from dpkg-buildflags to enhance security. 2013-10-13 09:01:05 +02:00
Andrew Bettison
ae61a4f35c Issue #20: Make abstract sockets work
Finish the work started by Daniel in 2012, by using abstract local
AF_UNIX sockets on platforms that support them (Linux, Android).

Fix all sorts of bugs and issues that prevented the existing MDP and
Monitor client and server code from working with abstract socket names.
2013-09-19 17:26:06 +09:30
Andrew Bettison
987875969c Improve version_string.sh script
Full --help usage message
Better error handling and reporting
Only considers tags that look like version numbers
Does not create and delete local "START" tag
Lots of options, including --ignore-untracked and --unmodified
Suitable for use in Batphone repository
2013-09-12 17:50:54 +09:30