mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
c8bf8a7733
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.
301 lines
10 KiB
Makefile
301 lines
10 KiB
Makefile
# Makefile.in for Serval DNA
|
|
# vim: noet ts=8 sts=0 sw=8
|
|
prefix=@prefix@
|
|
exec_prefix=@exec_prefix@
|
|
bindir=@bindir@
|
|
sbindir=@sbindir@
|
|
sysconfdir=@sysconfdir@
|
|
localstatedir=@localstatedir@
|
|
|
|
SQLITE3_AMALGAMATION = sqlite-amalgamation-3140200
|
|
|
|
include sourcefiles.mk
|
|
include headerfiles.mk
|
|
|
|
OBJSDIR_SERVALD = objs_servald
|
|
OBJSDIR_LIB = objs_lib
|
|
OBJSDIR_TOOLS = objs
|
|
|
|
OBJSDIRS = $(OBJSDIR_SERVALD) $(OBJSDIR_LIB) $(OBJSDIR_TOOLS)
|
|
|
|
ALL_SOURCES = \
|
|
$(SERVAL_CLIENT_SOURCES) \
|
|
$(MDP_CLIENT_SOURCES) \
|
|
$(SERVAL_DAEMON_SOURCES) \
|
|
$(SERVAL_DAEMON_JNI_SOURCES) \
|
|
$(TEST_SOURCES) \
|
|
$(SERVAL_LIB_SOURCES) \
|
|
$(MONITOR_CLIENT_SRCS) \
|
|
$(SIMULATOR_SOURCES) \
|
|
$(SQLITE3_SOURCES)
|
|
|
|
SERVAL_DAEMON_OBJS = \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_CLIENT_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(MDP_CLIENT_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_DAEMON_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_DAEMON_JNI_SOURCES:.c=.o))
|
|
SQLITE3_OBJS = \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(notdir $(SQLITE3_SOURCES:.c=.o)))
|
|
SERVALD_OBJS = \
|
|
$(SQLITE3_OBJS) \
|
|
$(SERVAL_DAEMON_OBJS)
|
|
TEST_OBJS = \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(TEST_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_CLIENT_SOURCES:.c=.o))
|
|
LIB_SERVAL_OBJS = \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_CLIENT_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_LIB_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(MDP_CLIENT_SOURCES:.c=.o))
|
|
MONITOR_CLIENT_OBJS = \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_CLIENT_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_LIB_SOURCES:.c=.o)) \
|
|
$(addprefix $(OBJSDIR_LIB)/, $(MONITOR_CLIENT_SRCS:.c=.o))
|
|
SIMULATOR_OBJS = \
|
|
$(addprefix $(OBJSDIR_TOOLS)/, $(SIMULATOR_SOURCES:.c=.o))
|
|
|
|
PREFIXED_HEADERS = $(addprefix $(SOURCE_PREFIX), $(HDRS))
|
|
|
|
CC= @CC@
|
|
|
|
LDFLAGS=@LDFLAGS@ @LIBS@
|
|
|
|
CFLAGS= -I$(SOURCE_PREFIX)$(SQLITE3_AMALGAMATION) @CPPFLAGS@ @CFLAGS@
|
|
CFLAGS+=-DSYSCONFDIR="\"$(sysconfdir)\"" -DLOCALSTATEDIR="\"$(localstatedir)\""
|
|
CFLAGS+=-DSQLITE_THREADSAFE=0 \
|
|
-DSQLITE_OMIT_DATETIME_FUNCS \
|
|
-DSQLITE_OMIT_COMPILEOPTION_DIAGS \
|
|
-DSQLITE_OMIT_DEPRECATED \
|
|
-DSQLITE_OMIT_LOAD_EXTENSION \
|
|
-DSQLITE_OMIT_VIRTUALTABLE \
|
|
-DSQLITE_OMIT_AUTHORIZATION
|
|
CFLAGS+=-fPIC
|
|
CFLAGS+=-Wall -Werror
|
|
# Solaris magic
|
|
CFLAGS+=-DSHA2_USE_INTTYPES_H -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1
|
|
# OSX magic to compensate for the Solaris magic
|
|
CFLAGS+=-D_DARWIN_C_SOURCE
|
|
CFLAGS_SQLITE= @CFLAGS_SQLITE@
|
|
|
|
INSTALL= install
|
|
INSTALL_PROGRAM=$(INSTALL)
|
|
INSTALL_DATA= $(INSTALL) -m 644
|
|
|
|
-include $(SOURCE_PREFIX)Makefile.dbg
|
|
|
|
# More warnings, discover problems that only happen on some archs
|
|
CFLAGS+=-Wextra
|
|
# Security enhancements from Debian
|
|
CFLAGS+=-Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
|
|
|
|
DEFS= @DEFS@
|
|
|
|
.PHONY: all libs test install uninstall clean
|
|
|
|
all: libs servald servaldwrap test
|
|
|
|
libs: libservald.so libservald.a \
|
|
libservalclient.so libservalclient.a \
|
|
libmonitorclient.so libmonitorclient.a
|
|
|
|
test: tfw_createfile directory_service fakeradio simulator serval-tests
|
|
|
|
install: servald
|
|
$(INSTALL_PROGRAM) -D servald $(DESTDIR)$(sbindir)/servald
|
|
|
|
uninstall:
|
|
$(RM) $(DESTDIR)$(sbindir)/servald
|
|
|
|
clean:
|
|
@$(RM) -r $(OBJSDIRS:%=%/*) \
|
|
servald \
|
|
libservald.so libservald.a \
|
|
libservalclient.so libservalclient.a \
|
|
libmonitorclient.so libmonitorclient.a \
|
|
tfw_createfile directory_service fakeradio simulator serval-tests
|
|
|
|
# Source code test coverage support -- see doc/Testing.md
|
|
|
|
.PHONY: covzero covinit covhtml is_built_with_coverage has_coverage_data
|
|
|
|
covzero: | is_built_with_coverage
|
|
@echo REMOVE all .gcda files
|
|
@find $(OBJSDIRS) -type f -name '*.gcda' -print0 | xargs -0 $(RM)
|
|
|
|
covinit: servald-initial.info
|
|
|
|
covhtml: coverage_html/index.html
|
|
|
|
is_built_with_coverage:
|
|
@for obj in $(SERVALD_OBJS); do \
|
|
gcno="$${obj%.o}.gcno" ;\
|
|
if [ ! -r "$$gcno" ]; then \
|
|
echo "ERROR: servald has not been compiled for code coverage; missing $$gcno" ;\
|
|
exit 1 ;\
|
|
fi ;\
|
|
done
|
|
|
|
has_coverage_data: | is_built_with_coverage
|
|
@count=0; for obj in $(SERVALD_OBJS); do \
|
|
gcda="$${obj%.o}.gcda" ;\
|
|
[ -s "$$gcda" ] && count=$$(($$count + 1)) ;\
|
|
done ;\
|
|
if [ $$count -eq 0 ]; then \
|
|
echo "ERROR: no code coverage data; run some tests" ;\
|
|
exit 1 ;\
|
|
fi
|
|
|
|
servald-initial.info: $(SOURCE_PREFIX)Makefile servald | is_built_with_coverage
|
|
geninfo --quiet --initial --checksum --base-directory=$(abspath .) --no-external $(OBJSDIR_SERVALD) -o $@
|
|
|
|
servald-coverage.info: $(SOURCE_PREFIX)Makefile servald $(shell find $(OBJSDIR_SERVALD) -type f -name '*.gcda' 2>/dev/null) | has_coverage_data
|
|
geninfo --quiet --checksum --base-directory=$(abspath .) --no-external $(OBJSDIR_SERVALD) -o $@ 2>&1 | { grep -v 'WARNING: no data found for .*\.h$$' || true; }
|
|
@[ -s $@ ]
|
|
|
|
coverage_html/index.html: $(SOURCE_PREFIX)Makefile servald-initial.info servald-coverage.info
|
|
$(RM) -r coverage_html
|
|
genhtml --quiet servald-initial.info servald-coverage.info -o coverage_html
|
|
|
|
# Autconf support -- helpful messages to help avoid some common build mistakes.
|
|
|
|
.PRECIOUS: $(SOURCE_PREFIX)Makefile $(SOURCE_PREFIX)config.status $(SOURCE_PREFIX)configure
|
|
|
|
$(SOURCE_PREFIX)Makefile: $(SOURCE_PREFIX)Makefile.in $(SOURCE_PREFIX)config.status
|
|
$(warning Makefile may be out of date, please run ./config.status)
|
|
|
|
$(SOURCE_PREFIX)config.status: $(SOURCE_PREFIX)configure
|
|
$(warning config.status may be out of date, please run ./configure)
|
|
|
|
$(SOURCE_PREFIX)configure: $(SOURCE_PREFIX)configure.ac
|
|
$(warning configure may be out of date, please run autoreconf -f -i -I m4)
|
|
|
|
# Embed Serval DNA's version into libraries and executables.
|
|
|
|
$(OBJSDIR_TOOLS)/version.o: $(addprefix $(SOURCE_PREFIX), $(ALL_SOURCES)) \
|
|
$(PREFIXED_HEADERS) \
|
|
$(SOURCE_PREFIX)version_servald.c \
|
|
$(SOURCE_PREFIX)version_string.sh \
|
|
$(wildcard VERSION.txt) \
|
|
$(SOURCE_PREFIX)COPYRIGHT.txt
|
|
@echo CC version_servald.c
|
|
@mkdir -p $(dir $@)
|
|
@$(RM) $(@:.o=.gcno) $(@:.o=.gcda)
|
|
@V=`$(SOURCE_PREFIX)./version_string.sh --repository=$(SOURCE_PREFIX) --ignore-untracked` \
|
|
&& C="`sed -e :a -e N -e '$$!ba' -e 's/[\\\\"]/\\\\&/g' -e 's/\\n/\\\\n/g' $(SOURCE_PREFIX)COPYRIGHT.txt`" \
|
|
&& $(CC) $(CFLAGS) $(DEFS) -c $(SOURCE_PREFIX)version_servald.c -o $@ -DSERVALD_VERSION="\"$$V\"" -DSERVALD_COPYRIGHT="\"$$C\""
|
|
|
|
#' <-- fixes vim syntax highlighting
|
|
|
|
# Compile SQLITE as a special case, because it is imported source code.
|
|
# Instead of fixing warnings case-by-case in the sqlite.c source code, simply
|
|
# suppress the classes of warnings that cause compilation errors with
|
|
# -Werror.
|
|
$(SQLITE3_OBJS): $(OBJSDIR_SERVALD)/%.o: $(SOURCE_PREFIX)$(SQLITE3_AMALGAMATION)/%.c
|
|
@echo SERVALD CC $<
|
|
@mkdir -p $(dir $@)
|
|
@$(RM) $(@:.o=.gcno) $(@:.o=.gcda)
|
|
@$(CC) $(CFLAGS) $(CFLAGS_SQLITE) $(DEFS) -c $< -o $@
|
|
|
|
# No object files in source directory!
|
|
%.o: $(SOURCE_PREFIX)%.c
|
|
|
|
$(OBJSDIR_TOOLS)/%.o: $(SOURCE_PREFIX)%.c
|
|
@echo CC $<
|
|
@mkdir -p $(dir $@)
|
|
@$(RM) $(@:.o=.gcno) $(@:.o=.gcda)
|
|
@$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
|
|
|
|
$(OBJSDIR_SERVALD)/%.o: $(SOURCE_PREFIX)%.c
|
|
@echo SERVALD CC $<
|
|
@mkdir -p $(dir $@)
|
|
@$(RM) $(@:.o=.gcno) $(@:.o=.gcda)
|
|
@$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
|
|
|
|
$(OBJSDIR_LIB)/%.o: $(SOURCE_PREFIX)%.c
|
|
@echo LIB CC $<
|
|
@mkdir -p $(dir $@)
|
|
@$(RM) $(@:.o=.gcno) $(@:.o=.gcda)
|
|
@$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
|
|
|
|
# Dependencies on header files. The following list of dependencies is too
|
|
# broad so it sometimes results in unnecessary re-compilation, but that is
|
|
# better than too narrow, which can result in missed re-compilation.
|
|
|
|
$(SERVAL_DAEMON_OBJS): $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
$(SERVALD_OBJS): $(SOURCE_PREFIX)Makefile
|
|
$(LIB_SERVAL_OBJS): $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
$(TEST_OBJS): $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
$(OBJSDIR_TOOLS)/tfw_createfile.o: $(SOURCE_PREFIX)Makefile $(SOURCE_PREFIX)str.h
|
|
$(OBJSDIR_TOOLS)/directory_service.o: $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
$(MONITOR_CLIENT_OBJS): $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
$(SIMULATOR_OBJS): $(SOURCE_PREFIX)Makefile $(PREFIXED_HEADERS)
|
|
|
|
# Rules for main targets.
|
|
|
|
servald: $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o $(LDFLAGS)
|
|
|
|
servaldwrap: $(OBJSDIR_SERVALD)/servalwrap.o $(OBJSDIR_TOOLS)/version.o
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $^ $(LDFLAGS)
|
|
|
|
serval-tests: $(TEST_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(TEST_OBJS) $(OBJSDIR_TOOLS)/version.o $(LDFLAGS)
|
|
|
|
directory_service: $(OBJSDIR_TOOLS)/directory_service.o libservalclient.a
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(OBJSDIR_TOOLS)/directory_service.o libservalclient.a $(LDFLAGS)
|
|
|
|
tfw_createfile: $(OBJSDIR_TOOLS)/tfw_createfile.o libservalclient.a
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(OBJSDIR_TOOLS)/tfw_createfile.o libservalclient.a $(LDFLAGS)
|
|
|
|
fakeradio: $(OBJSDIR_TOOLS)/fakeradio.o libservalclient.a
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(OBJSDIR_TOOLS)/fakeradio.o libservalclient.a $(LDFLAGS)
|
|
|
|
simulator: $(SIMULATOR_OBJS) libservalclient.a
|
|
@echo LINK $@
|
|
@$(CC) -Wall -o $@ $(SIMULATOR_OBJS) libservalclient.a $(LDFLAGS)
|
|
|
|
libservalclient.so: $(LIB_SERVAL_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo AR $@
|
|
@$(CC) -Wall -shared -o $@ $(LIB_SERVAL_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
|
|
libservalclient.a: $(LIB_SERVAL_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo AR $@
|
|
@$(AR) -cr $@ $(LIB_SERVAL_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
|
|
libservald.so: $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo LINK $@
|
|
@$(CC) -Wall -shared -o $@ $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o $(LDFLAGS)
|
|
|
|
libservald.a: $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo AR $@
|
|
@$(AR) -cr $@ $(SERVALD_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
|
|
libmonitorclient.so: $(MONITOR_CLIENT_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo LINK $@
|
|
@$(CC) -Wall -shared -o $@ $(MONITOR_CLIENT_OBJS) $(OBJSDIR_TOOLS)/version.o $(LDFLAGS)
|
|
|
|
libmonitorclient.a: $(MONITOR_CLIENT_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
@echo AR $@
|
|
@$(AR) -cr $@ $(MONITOR_CLIENT_OBJS) $(OBJSDIR_TOOLS)/version.o
|
|
|
|
# Helpful target to update the COPYRIGHT.txt file by harvesting copyright
|
|
# information from the contents of all the source and header files. This
|
|
# should be run periodically and the results reviewed, manually adjusted and
|
|
# committed to the repository.
|
|
|
|
findPATH = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
|
|
COPYRIGHT_TOOL := $(call findPATH,sp-copyright-tool)
|
|
|
|
copyright:
|
|
@if [ -x "$(COPYRIGHT_TOOL)" ]; then \
|
|
echo GENERATE COPYRIGHT.txt; \
|
|
$(COPYRIGHT_TOOL) -o COPYRIGHT.txt condense *.c *.h; \
|
|
else \
|
|
echo 'sp-copyright-tool is not in $$PATH; COPYRIGHT.txt not updated'; \
|
|
fi
|