daemon.mk 2.53 KB
Newer Older
1
kresd_SOURCES := \
2 3
	daemon/io.c          \
	daemon/network.c     \
4
	daemon/engine.c      \
Marek Vavruša's avatar
Marek Vavruša committed
5
	daemon/worker.c      \
6
	daemon/bindings.c    \
7
	daemon/ffimodule.c   \
8
	daemon/tls.c         \
9
	daemon/tls_ephemeral_credentials.c \
10
	daemon/tls_session_ticket-srv.c \
11
	daemon/zimport.c     \
12
	daemon/session.c     \
Marek Vavruša's avatar
Marek Vavruša committed
13
	daemon/main.c
14

15 16
kresd_DIST := daemon/lua/kres.lua daemon/lua/kres-gen.lua \
              daemon/lua/trust_anchors.lua daemon/lua/zonefile.lua
Marek Vavruša's avatar
Marek Vavruša committed
17

18 19
# Embedded resources
%.inc: %.lua
20
	@$(call quiet,XXD_LUA,$<) $< > $@
21 22 23
ifeq ($(AMALG), yes)
kresd.amalg.c: daemon/lua/sandbox.inc daemon/lua/config.inc
else
24
daemon/engine.o: daemon/lua/sandbox.inc daemon/lua/config.inc
25
kresd-lint: daemon/lua/sandbox.inc daemon/lua/config.inc
26
endif
27

28
# Installed FFI bindings
29 30
bindings-install: $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
	$(INSTALL) -m 0644 $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
31

32 33 34
LUA_HAS_SETFUNCS := \
	$(shell pkg-config luajit --atleast-version=2.1.0-beta3 && echo 1 || echo 0)

35 36
kresd_CFLAGS := -fPIE \
		-Dlibknot_SONAME=\"$(libknot_SONAME)\" \
37
		-Dlibzscanner_SONAME=\"$(libzscanner_SONAME)\" \
38
		-DROOTHINTS=\"$(ROOTHINTS)\" \
39
		-DLIBEXT=\"$(LIBEXT)\" \
40
		-DLUA_HAS_SETFUNCS="$(LUA_HAS_SETFUNCS)"
41
kresd_DEPEND := $(libkres) $(contrib)
42
kresd_LIBS := $(libkres_TARGET) $(contrib_TARGET) $(libknot_LIBS) \
43 44
              $(libzscanner_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS) \
              $(gnutls_LIBS)
45 46 47 48 49 50

# Enable systemd
ifeq ($(HAS_libsystemd), yes)
kresd_CFLAGS += -DHAS_SYSTEMD
kresd_LIBS += $(libsystemd_LIBS)
endif
Marek Vavruša's avatar
Marek Vavruša committed
51 52

# Make binary
53
$(eval $(call make_sbin,kresd,daemon,yes))
54 55

# Targets
56
date := $(shell head -n1 < NEWS | sed 's/.*(\(.*\)).*/\1/' | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$$' || date -u -r NEWS +%F)
57
daemon: $(kresd) $(kresd_DIST)
58
daemon-install: kresd-install bindings-install
59
ifneq ($(SED),)
60 61
	$(SED) -e "s/@VERSION@/$(VERSION)/" -e "s/@DATE@/$(date)/" \
		-e "s|@MODULEDIR@|$(MODULEDIR)|" \
62
		-e "s|@KEYFILE_DEFAULT@|$(KEYFILE_DEFAULT)|" \
63
		doc/kresd.8.in > doc/kresd.8
64 65
	$(INSTALL) -d -m 0755 $(DESTDIR)$(MANDIR)/man8/
	$(INSTALL) -m 0644 doc/kresd.8 $(DESTDIR)$(MANDIR)/man8/
66
endif
67
daemon-clean: kresd-clean
68
	@$(RM) daemon/lua/*.inc daemon/lua/trust_anchors.lua
69

70
daemon/lua/trust_anchors.lua: daemon/lua/trust_anchors.lua.in
71
	@$(call quiet,SED,$<) -e "s|@ETCDIR@|$(ETCDIR)|g;s|@KEYFILE_DEFAULT@|$(KEYFILE_DEFAULT)|g" $< > $@
72

73 74
daemon/lua/kres-gen.lua: | $(libkres)
	@echo "WARNING: regenerating $@"
75 76
	@# the sed saves some space(s)
	daemon/lua/kres-gen.sh | sed 's/    /\t/g' > $@
77 78
.DELETE_ON_ERROR: daemon/lua/kres-gen.lua

79
.PHONY: daemon daemon-install daemon-clean