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

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

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

# Dependencies
18 19 20
$(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))
21
$(eval $(call find_lib,lmdb))
22 23
$(eval $(call find_lib,libuv,1.0,yes))
$(eval $(call find_lib,nettle,,yes))
24
$(eval $(call find_alt,lua,luajit))
25
$(eval $(call find_lib,cmocka))
26 27
$(eval $(call find_bin,doxygen))
$(eval $(call find_bin,sphinx-build))
28
$(eval $(call find_lib,libmemcached,1.0))
29
$(eval $(call find_lib,hiredis,,yes))
Grigorii Demidov's avatar
Grigorii Demidov committed
30
$(eval $(call find_lib,socket_wrapper))
31
$(eval $(call find_lib,libsystemd,227))
Daniel Kahn Gillmor's avatar
Daniel Kahn Gillmor committed
32
$(eval $(call find_lib,gnutls))
33

34 35 36 37 38 39 40 41 42 43 44
# 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

45 46 47 48 49 50 51 52
# 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
53 54
$(eval $(call find_ver,go,$(GO_VERSION),16))

55
# Check if Go is able to build shared libraries
56 57 58 59
ifeq ($(HAS_go),yes)
ifneq ($(GO_PLATFORM),$(filter $(GO_PLATFORM),amd64 386 arm arm64))
HAS_go := no
endif
60
else
61 62
$(eval $(call find_ver,go,$(GO_VERSION),15))
ifeq ($HAS_go,yes)
63
ifneq ($(GO_PLATFORM),$(filter $(GO_PLATFORM),arm amd64))
64
HAS_go := no
65
endif
66
endif
67
endif
68

69 70 71 72 73 74 75
# Work around luajit on OS X
ifeq ($(PLATFORM), Darwin)
ifneq (,$(findstring luajit, $(lua_LIBS)))
	lua_LIBS += -pagezero_size 10000 -image_base 100000000
endif
endif

Karel Slaný's avatar
Karel Slaný committed
76
BUILD_CFLAGS += $(libknot_CFLAGS) $(libuv_CFLAGS) $(nettle_CFLAGS) $(cmocka_CFLAGS) $(lua_CFLAGS) $(libdnssec_CFLAGS) $(libsystemd_CFLAGS)
77
BUILD_CFLAGS += $(addprefix -I,$(wildcard contrib/ccan/*) contrib/murmurhash3)
78

79 80 81
# 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)
82
BUILD_CFLAGS += -DENABLE_COOKIES
83
ENABLE_COOKIES := yes
84 85
endif

86 87
# Overview
info:
88
	$(info Target:     Knot DNS Resolver $(VERSION)-$(PLATFORM))
89
	$(info Compiler:   $(CC) $(BUILD_CFLAGS))
90 91 92
	$(info )
	$(info Variables)
	$(info ---------)
93 94 95
	$(info HARDENING:  $(HARDENING))
	$(info BUILDMODE:  $(BUILDMODE))
	$(info PREFIX:     $(PREFIX))
96
	$(info PREFIX:     $(PREFIX))
Marek Vavruša's avatar
Marek Vavruša committed
97
	$(info DESTDIR:    $(DESTDIR))
98
	$(info BINDIR:     $(BINDIR))
99
	$(info SBINDIR:    $(SBINDIR))
100
	$(info LIBDIR:     $(LIBDIR))
101
	$(info ETCDIR:     $(ETCDIR))
102 103 104 105 106 107
	$(info INCLUDEDIR: $(INCLUDEDIR))
	$(info MODULEDIR:  $(MODULEDIR))
	$(info )
	$(info Dependencies)
	$(info ------------)
	$(info [$(HAS_libknot)] libknot (lib))
108
	$(info [$(HAS_lmdb)] lmdb (lib))
109
	$(info [$(HAS_lua)] luajit (daemon))
110
	$(info [$(HAS_libuv)] libuv (daemon))
Daniel Kahn Gillmor's avatar
Daniel Kahn Gillmor committed
111
	$(info [$(HAS_gnutls)] libgnutls (daemon))
Karel Slaný's avatar
Karel Slaný committed
112
	$(info [$(HAS_nettle)] nettle (DNS cookies))
113 114 115 116
	$(info )
	$(info Optional)
	$(info --------)
	$(info [$(HAS_doxygen)] doxygen (doc))
117
	$(info [$(HAS_go)] go (modules/go, Go buildmode=c-shared support))
118 119 120
	$(info [$(HAS_libmemcached)] libmemcached (modules/memcached))
	$(info [$(HAS_hiredis)] hiredis (modules/redis))
	$(info [$(HAS_cmocka)] cmocka (tests/unit))
121
	$(info [$(HAS_libsystemd)] systemd (daemon))
122 123
	$(info )

124 125 126 127 128 129 130 131 132 133 134 135 136
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
ifeq ($(HAS_libuv),no)
	$(error libuv >= 1.0 required)
endif

137
# Installation directories
Marek Vavruša's avatar
Marek Vavruša committed
138
$(DESTDIR)$(MODULEDIR):
139
	$(INSTALL) -d $@
Marek Vavruša's avatar
Marek Vavruša committed
140
$(DESTDIR)$(ETCDIR):
141
	$(INSTALL) -m 0750 -d $@
142

143
# Sub-targets
144
include contrib/contrib.mk
145 146
include lib/lib.mk
include daemon/daemon.mk
147
include modules/modules.mk
148
include tests/tests.mk
149
include doc/doc.mk
150
include etc/etc.mk