Makefile 5.64 KB
Newer Older
1 2 3 4
include config.mk
include platform.mk

# Targets
5
all: info lib daemon client modules etc
6
install: lib-install daemon-install client-install modules-install etc-install
7
check: all tests
8
clean: contrib-clean lib-clean daemon-clean client-clean modules-clean \
9
	tests-clean doc-clean bench-clean coverage-clean
10
doc: doc-html
11 12 13
lint: lint-lua lint-c
lint-c: libkres-lint kresd-lint kresc-lint
lint-lua: $(patsubst %.lua.in,%.lua,$(wildcard */*/*.lua.in))
14 15
	luacheck --codes --formatter TAP .

16
.PHONY: all install check clean doc info lint
17 18

# Dependencies
19
KNOT_MINVER := 2.6.4
20 21 22
$(eval $(call find_lib,libknot,$(KNOT_MINVER),yes))
$(eval $(call find_lib,libdnssec,$(KNOT_MINVER),yes))
$(eval $(call find_lib,libzscanner,$(KNOT_MINVER),yes))
23
$(eval $(call find_lib,lmdb))
24 25
$(eval $(call find_lib,libuv,1.0,yes))
$(eval $(call find_lib,nettle,,yes))
26
$(eval $(call find_alt,lua,luajit))
27 28
$(eval $(call find_luapkg,ltn12))
$(eval $(call find_luapkg,ssl.https))
29
$(eval $(call find_lib,cmocka))
30 31
$(eval $(call find_bin,doxygen))
$(eval $(call find_bin,sphinx-build))
32
$(eval $(call find_pythonpkg,breathe))
33 34
#$(eval $(call find_lib,libmemcached,1.0))
#$(eval $(call find_lib,hiredis,,yes))
Grigorii Demidov's avatar
Grigorii Demidov committed
35
$(eval $(call find_lib,socket_wrapper))
36
$(eval $(call find_lib,libsystemd,227))
37
$(eval $(call find_lib,gnutls))
38
$(eval $(call find_lib,libedit))
39
$(eval $(call find_lib,libprotobuf-c,1))
vendemiat's avatar
vendemiat committed
40
$(eval $(call find_lib,libfstrm,0.2))
41
$(eval $(call find_bin,protoc-c))
42 43
$(eval $(call find_bin,lcov))
$(eval $(call find_bin,luacov))
44

45 46 47 48 49 50 51 52 53 54 55
# Lookup SONAME
$(eval $(call find_soname,libknot))
$(eval $(call find_soname,libzscanner))

ifeq ($(libknot_SONAME),)
  $(error "Unable to resolve libknot_SONAME, update find_soname in platform.mk")
endif
ifeq ($(libzscanner_SONAME),)
  $(error "Unable to resolve libzscanner_SONAME, update find_some in platform.mk")
endif

56 57 58 59 60 61 62 63
# Find Go version and platform
GO_VERSION := $(shell $(GO) version 2>/dev/null)
ifeq ($(GO_VERSION),)
        GO_VERSION := 0
else
        GO_PLATFORM := $(word 2,$(subst /, ,$(word 4,$(GO_VERSION))))
        GO_VERSION := $(subst .,,$(subst go,,$(word 3,$(GO_VERSION))))
endif
64 65
$(eval $(call find_ver,go,$(GO_VERSION),16))

66
# Check if Go is able to build shared libraries
67 68 69 70
ifeq ($(HAS_go),yes)
ifneq ($(GO_PLATFORM),$(filter $(GO_PLATFORM),amd64 386 arm arm64))
HAS_go := no
endif
71
else
72 73
$(eval $(call find_ver,go,$(GO_VERSION),15))
ifeq ($HAS_go,yes)
74
ifneq ($(GO_PLATFORM),$(filter $(GO_PLATFORM),arm amd64))
75
HAS_go := no
76
endif
77
endif
78
endif
79

vendemiat's avatar
vendemiat committed
80
# check for fstrm and protobuf for dnstap
81
ifeq ($(HAS_libfstrm)|$(HAS_libprotobuf-c)|$(HAS_protoc-c),yes|yes|yes)
vendemiat's avatar
vendemiat committed
82 83 84
ENABLE_DNSTAP := yes
endif

85 86
# Overview
info:
87
	$(info Target:     Knot DNS Resolver $(VERSION)-$(PLATFORM))
88
	$(info Compiler:   $(CC) $(BUILD_CFLAGS))
89
	$(info Linker:     $(CCLD) $(BUILD_LDFLAGS))
90 91 92
	$(info )
	$(info Variables)
	$(info ---------)
93 94 95
	$(info HARDENING:  $(HARDENING))
	$(info BUILDMODE:  $(BUILDMODE))
	$(info PREFIX:     $(PREFIX))
96
	$(info PREFIX:     $(PREFIX))
97
	$(info DESTDIR:    $(DESTDIR))
98
	$(info BINDIR:     $(BINDIR))
99
	$(info SBINDIR:    $(SBINDIR))
100
	$(info LIBDIR:     $(LIBDIR))
101
	$(info ETCDIR:     $(ETCDIR))
102 103 104
	$(info INCLUDEDIR: $(INCLUDEDIR))
	$(info MODULEDIR:  $(MODULEDIR))
	$(info )
105
	$(info Core Dependencies)
106 107
	$(info ------------)
	$(info [$(HAS_libknot)] libknot (lib))
108
	$(info [yes] $(if $(filter $(HAS_lmdb),yes),system,embedded) lmdb (lib))
109
	$(info [$(HAS_lua)] luajit (daemon))
110
	$(info [$(HAS_libuv)] libuv (daemon))
111
	$(info [$(HAS_gnutls)] libgnutls (daemon))
112 113 114 115
	$(info )
	$(info Optional)
	$(info --------)
	$(info [$(HAS_doxygen)] doxygen (doc))
116 117
	$(info [$(HAS_sphinx-build)] sphinx-build (doc))
	$(info [$(HAS_breathe)] python-breathe (doc))
118
	$(info [$(HAS_go)] go (modules/go, Go buildmode=c-shared support))
119 120
#	$(info [$(HAS_libmemcached)] libmemcached (modules/memcached))
#	$(info [$(HAS_hiredis)] hiredis (modules/redis))
121
	$(info [$(HAS_cmocka)] cmocka (tests/unit))
122
	$(info [$(HAS_libsystemd)] systemd (daemon))
123
	$(info [$(HAS_nettle)] nettle (modules/cookies))
124 125
	$(info [$(HAS_ltn12)] Lua socket ltn12 (trust anchor bootstrapping))
	$(info [$(HAS_ssl.https)] Lua ssl.https (trust anchor bootstrapping))
126
	$(info [$(HAS_libedit)] libedit (client))
vendemiat's avatar
vendemiat committed
127 128
	$(info [$(HAS_libfstrm)] libfstrm (modules/dnstap))
	$(info [$(HAS_libprotobuf-c)] libprotobuf-c (modules/dnstap))
129
	$(info [$(HAS_protoc-c)] proto-c (modules/dnstap))
130 131
	$(info [$(HAS_lcov)] lcov (code coverage))
	$(info [$(HAS_luacov)] luacov (code coverage))
132 133
	$(info )

134
# Verify required dependencies are met, as listed above
135
ifeq ($(HAS_libknot),no)
136
	$(error libknot >= $(KNOT_MINVER) required)
137 138
endif
ifeq ($(HAS_libzscanner),no)
139
	$(error libzscanner >= $(KNOT_MINVER) required)
140 141
endif
ifeq ($(HAS_libdnssec),no)
142
	$(error libdnssec >= $(KNOT_MINVER) required)
143
endif
144 145 146
ifeq ($(HAS_lua),no)
	$(error luajit required)
endif
147 148 149
ifeq ($(HAS_libuv),no)
	$(error libuv >= 1.0 required)
endif
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
ifeq ($(HAS_gnutls),no)
	$(error gnutls required)
endif


BUILD_CFLAGS += $(libknot_CFLAGS) $(libuv_CFLAGS) $(nettle_CFLAGS) $(cmocka_CFLAGS) $(lua_CFLAGS) $(libdnssec_CFLAGS) $(libsystemd_CFLAGS)
BUILD_CFLAGS += $(addprefix -I,$(wildcard contrib/ccan/*) contrib/murmurhash3)

# Work around luajit on OS X
ifeq ($(PLATFORM), Darwin)
ifneq (,$(findstring luajit, $(lua_LIBS)))
	lua_LIBS += -pagezero_size 10000 -image_base 100000000
endif
endif

165 166
# Check if it has nettle to support DNS cookies
ifeq ($(HAS_nettle), yes)
167 168 169
BUILD_CFLAGS += -DENABLE_COOKIES
ENABLE_COOKIES := yes
endif
170

171
# Installation directories
172
$(DESTDIR)$(MODULEDIR):
173
	$(INSTALL) -d $@
174
$(DESTDIR)$(ETCDIR):
175
	$(INSTALL) -m 0755 -d $@
176

177
# Sub-targets
178
include contrib/contrib.mk
179
include coverage.mk
180
include lib/lib.mk
181
include client/client.mk
182
include daemon/daemon.mk
183
include modules/modules.mk
184
include tests/tests.mk
185
include doc/doc.mk
186
include etc/etc.mk
187
include bench/bench.mk