Makefile 5.54 KB
Newer Older
1 2
SHELL=/bin/bash -o pipefail -o errexit

3 4 5 6
include config.mk
include platform.mk

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

18
.PHONY: all install check clean doc info lint
19 20

# Dependencies
21
KNOT_MINVER := 2.7.2
22 23 24
$(eval $(call find_lib,libknot,$(KNOT_MINVER),yes))
$(eval $(call find_lib,libdnssec,$(KNOT_MINVER),yes))
$(eval $(call find_lib,libzscanner,$(KNOT_MINVER),yes))
25
$(eval $(call find_lib,lmdb))
26 27
$(eval $(call find_lib,libuv,1.0,yes))
$(eval $(call find_lib,nettle,,yes))
28
$(eval $(call find_alt,lua,luajit))
29 30
$(eval $(call find_luapkg,ltn12))
$(eval $(call find_luapkg,ssl.https))
31
$(eval $(call find_lib,cmocka))
32 33
$(eval $(call find_bin,doxygen))
$(eval $(call find_bin,sphinx-build))
34
$(eval $(call find_pythonpkg,breathe))
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 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
	$(info [$(HAS_cmocka)] cmocka (tests/unit))
120
	$(info [$(HAS_libsystemd)] systemd (daemon))
121
#	$(info [$(HAS_nettle)] nettle (modules/cookies))
122 123
	$(info [$(HAS_ltn12)] Lua socket ltn12 (trust anchor bootstrapping))
	$(info [$(HAS_ssl.https)] Lua ssl.https (trust anchor bootstrapping))
124
	$(info [$(HAS_libedit)] libedit (client))
vendemiat's avatar
vendemiat committed
125 126
	$(info [$(HAS_libfstrm)] libfstrm (modules/dnstap))
	$(info [$(HAS_libprotobuf-c)] libprotobuf-c (modules/dnstap))
127
	$(info [$(HAS_protoc-c)] proto-c (modules/dnstap))
128 129
	$(info [$(HAS_lcov)] lcov (code coverage))
	$(info [$(HAS_luacov)] luacov (code coverage))
130 131
	$(info )

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

163
# Check if it has nettle to support DNS cookies
164 165 166 167 168 169 170

# temporarily turn off cookies
#ifeq ($(HAS_nettle), yes)
#BUILD_CFLAGS += -DENABLE_COOKIES
#ENABLE_COOKIES := yes
#endif
ENABLE_COOKIES := no
171

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

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