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

# Targets
5 6
all: info lib daemon client modules
install: lib-install daemon-install client-install modules-install etc-install
7
check: all tests
8 9
clean: contrib-clean lib-clean daemon-clean client-clean modules-clean \
	tests-clean doc-clean bench-clean
10
doc: doc-html
11
.PHONY: all install check clean doc info
12 13 14

# Options
ifdef COVERAGE
15
BUILD_CFLAGS += --coverage
16 17 18
endif

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

42 43 44 45 46 47 48 49 50 51 52
# 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

53 54 55 56 57 58 59 60
# 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
61 62
$(eval $(call find_ver,go,$(GO_VERSION),16))

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

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

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

129
# Verify required dependencies are met, as listed above
130 131 132 133 134 135 136 137 138
ifeq ($(HAS_libknot),no)
	$(error libknot >= 2.3.1 required)
endif
ifeq ($(HAS_libzscanner),no)
	$(error libzscanner >= 2.3.1 required)
endif
ifeq ($(HAS_libdnssec),no)
	$(error libdnssec >= 2.3.1 required)
endif
139 140 141
ifeq ($(HAS_lua),no)
	$(error luajit required)
endif
142 143 144
ifeq ($(HAS_libuv),no)
	$(error libuv >= 1.0 required)
endif
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
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

# Check if it has libknot 2.3.0 and nettle to support DNS cookies
$(eval $(call find_alt,knot230,libknot,2.3))
ifeq ($(HAS_nettle)|$(HAS_knot230),yes|yes)
BUILD_CFLAGS += -DENABLE_COOKIES
ENABLE_COOKIES := yes
endif
166

167
# Installation directories
168
$(DESTDIR)$(MODULEDIR):
169
	$(INSTALL) -d $@
170
$(DESTDIR)$(ETCDIR):
171
	$(INSTALL) -m 0750 -d $@
172

173
# Sub-targets
174
include contrib/contrib.mk
175 176
include lib/lib.mk
include daemon/daemon.mk
177
include modules/modules.mk
178
include tests/tests.mk
179
include doc/doc.mk
180
include etc/etc.mk
181
include bench/bench.mk