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.
This commit is contained in:
Andrew Bettison 2014-03-04 21:53:01 +10:30
parent 7081e7044f
commit e1949c15de
3 changed files with 72 additions and 84 deletions

View File

@ -3,7 +3,11 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/sourcefiles.mk
SERVALD_SRC_FILES = $(SERVAL_SOURCES) $(ANDROIDONLY_SOURCES)
SERVALD_SRC_FILES = \
$(SQLITE3_SOURCES) \
$(SERVAL_CLIENT_SOURCES) \
$(SERVAL_DAEMON_SOURCES) \
$(ANDROIDONLY_SOURCES)
NACL_BASE = nacl/src
NACL_INC := $(LOCAL_PATH)/nacl/include
include $(LOCAL_PATH)/$(NACL_BASE)/nacl.mk

View File

@ -8,63 +8,36 @@ include $(NACL_BASE)/nacl.mk
include sourcefiles.mk
include headerfiles.mk
SERVALD_SRCS = \
$(SQLITE3_SOURCES) \
$(NACL_SOURCES) \
$(SERVAL_CLIENT_SOURCES) \
$(SERVAL_DAEMON_SOURCES)
HAVE_ALSA= @HAVE_ALSA@
ifeq (HAVE_ALSA,1)
SERVAL_SOURCES+= audio_alsa.c
SERVALD_SRCS+= audio_alsa.c
endif
HAVE_VOIPTEST= @HAVE_VOIPTEST@
ifeq ($(HAVE_VOIPTEST), 1)
SERVAL_SOURCES+= pa_phone.c
SERVALD_SRCS+= pa_phone.c
VOIPTEST_CFLAGS=-DHAVE_VOIPTEST=1
endif
SRCS= $(NACL_SOURCES) $(SERVAL_SOURCES)
MONITOR_CLIENT_SRCS = \
$(SERVAL_CLIENT_SOURCES) \
monitor-client.c
MONITORCLIENTSRCS=conf.c \
conf_om.c \
conf_parse.c \
conf_schema.c \
dataformats.c \
log.c \
log_util.c \
xprintf.c \
os.c \
mem.c \
monitor-client.c \
instance.c \
net.c \
socket.c \
str.c \
strbuf.c \
strbuf_helpers.c \
rotbuf.c
MDPCLIENTSRCS=conf.c \
conf_om.c \
conf_parse.c \
conf_schema.c \
dataformats.c \
os.c \
mem.c \
log.c \
log_util.c \
xprintf.c \
MDP_CLIENT_SRCS = \
$(SERVAL_CLIENT_SOURCES) \
mdp_client.c \
instance.c \
net.c \
mdp_net.c \
socket.c \
str.c \
strbuf.c \
strbuf_helpers.c \
rotbuf.c
OBJS= $(SRCS:.c=.o)
SERVAL_OBJS= $(SERVAL_SOURCES:.c=.o)
MONITORCLIENTOBJS= $(MONITORCLIENTSRCS:.c=.o)
MDPCLIENTOBJS= $(MDPCLIENTSRCS:.c=.o)
mdp_net.c
SERVALD_OBJS= $(SERVALD_SRCS:.c=.o)
SERVAL_DAEMON_OBJS= $(SERVAL_DAEMON_SOURCES:.c=.o)
MONITOR_CLIENT_OBJS= $(MONITOR_CLIENT_SRCS:.c=.o)
MDP_CLIENT_OBJS= $(MDP_CLIENT_SRCS:.c=.o)
LDFLAGS=@LDFLAGS@ @LIBS@ @PORTAUDIO_LIBS@ @SRC_LIBS@ @SPANDSP_LIBS@ @CODEC2_LIBS@ @PTHREAD_LIBS@
@ -111,17 +84,17 @@ VERSION.txt:
@echo CC $<
@$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
$(SERVAL_OBJS): $(HDRS)
$(MONITORCLIENTOBJS): $(HDRS)
$(MDPCLIENTOBJS): $(HDRS)
$(SERVAL_DAEMON_OBJS): $(HDRS)
$(MONITOR_CLIENT_OBJS): $(HDRS)
$(MDP_CLIENT_OBJS): $(HDRS)
servald: $(OBJS) version.o
servald: $(SERVALD_OBJS) version.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -o $@ $(OBJS) version.o $(LDFLAGS)
@$(CC) $(CFLAGS) -Wall -o $@ $(SERVALD_OBJS) version.o $(LDFLAGS)
directory_service: $(MDPCLIENTOBJS) version.o directory_service.o
directory_service: $(MDP_CLIENT_OBJS) version.o directory_service.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -o $@ $(MDPCLIENTOBJS) version.o directory_service.o $(LDFLAGS)
@$(CC) $(CFLAGS) -Wall -o $@ $(MDP_CLIENT_OBJS) version.o directory_service.o $(LDFLAGS)
tfw_createfile: tfw_createfile.o str.o strbuf.o strbuf_helpers.o
@echo LINK $@
@ -148,17 +121,17 @@ COPYRIGHT_TOOL := $(call findPATH,sp-copyright-tool)
# This does not build on 64 bit elf platforms as NaCL isn't built with -fPIC
# DOC 20120615
libserval.so: $(OBJS) version.o
libserval.so: $(SERVALD_OBJS) version.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(OBJS) version.o $(LDFLAGS)
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(SERVALD_OBJS) version.o $(LDFLAGS)
libmonitorclient.so: $(MONITORCLIENTOBJS) version.o
libmonitorclient.so: $(MONITOR_CLIENT_OBJS) version.o
@echo LINK $@
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(MONITORCLIENTOBJS) version.o $(LDFLAGS)
@$(CC) $(CFLAGS) -Wall -shared -o $@ $(MONITOR_CLIENT_OBJS) version.o $(LDFLAGS)
libmonitorclient.a: $(MONITORCLIENTOBJS) version.o
libmonitorclient.a: $(MONITOR_CLIENT_OBJS) version.o
@echo AR $@
@$(AR) -cr $@ $(MONITORCLIENTOBJS) version.o
@$(AR) -cr $@ $(MONITOR_CLIENT_OBJS) version.o
install: servald
$(INSTALL_PROGRAM) -D servald $(DESTDIR)$(sbindir)/servald
@ -167,7 +140,7 @@ uninstall:
$(RM) $(DESTDIR)$(sbindir)/servald
clean:
@$(RM) $(OBJS) \
@$(RM) $(SERVALD_OBJS) $(MONITOR_CLIENT_OBJS) $(MDP_CLIENT_OBJS) \
tfw_createfile.o version.o \
fakeradio.o fakeradio \
tfw_createfile servald \

View File

@ -1,25 +1,50 @@
SERVAL_SOURCES = \
sqlite-amalgamation-3070900/sqlite3.c \
# The "client" source files do not depend on "serval.h" or "rhizome.h", ie,
# they can be linked into executables other than servald.
SERVAL_CLIENT_SOURCES = \
conf.c \
conf_om.c \
conf_parse.c \
conf_schema.c \
dataformats.c \
fifo.c \
instance.c \
log.c \
log_util.c \
mem.c \
net.c \
os.c \
randombytes.c \
rotbuf.c \
socket.c \
srandomdev.c \
strbuf.c \
strbuf_helpers.c \
str.c \
strlcpy.c \
uuid.c \
xprintf.c
# These source files are imported and do not depend on any local header files.
# They also take a long time to compile, so their dependencies should be as
# narrow as possible to avoid unnecessary recompilations when developers modify
# header files.
SQLITE3_SOURCES = \
sqlite-amalgamation-3070900/sqlite3.c
# The source files for building the Serval DNA daemon.
SERVAL_DAEMON_SOURCES = \
cli.c \
commandline.c \
conf.c \
conf_om.c \
conf_parse.c \
conf_schema.c \
crc32.c \
crypto.c \
dataformats.c \
directory_client.c \
dna_helper.c \
encode.c \
fdqueue.c \
fifo.c \
golay.c \
httpd.c \
http_server.c \
keyring.c \
log.c \
log_util.c \
lsif.c \
main.c \
radio_link.c \
@ -29,14 +54,9 @@ SERVAL_SOURCES = \
mdp_net.c \
msp_client.c \
msp_proxy.c \
os.c \
mem.c \
instance.c \
socket.c \
monitor.c \
monitor-client.c \
monitor-cli.c \
net.c \
nonce.c \
overlay.c \
overlay_address.c \
@ -52,7 +72,6 @@ SERVAL_SOURCES = \
overlay_packetformats.c \
overlay_payload.c \
performance_timing.c \
randombytes.c \
route_link.c \
rhizome.c \
rhizome_bundle.c \
@ -66,21 +85,13 @@ SERVAL_SOURCES = \
rhizome_packetformats.c \
rhizome_store.c \
rhizome_sync.c \
rotbuf.c \
serval_packetvisualise.c \
server.c \
sha2.c \
sighandlers.c \
slip.c \
srandomdev.c \
str.c \
strbuf.c \
strbuf_helpers.c \
strlcpy.c \
uuid.c \
vomp.c \
vomp_console.c \
xprintf.c \
fec-3.0.1/ccsds_tables.c \
fec-3.0.1/decode_rs_8.c \
fec-3.0.1/encode_rs_8.c \