all: info lib daemon modules
install: lib-install daemon-install modules-install etc-install
check: all tests
-clean: lib-clean daemon-clean modules-clean tests-clean doc-clean
+clean: contrib-clean lib-clean daemon-clean modules-clean tests-clean doc-clean
doc: doc-html
.PHONY: all install check clean doc info
info:
$(info Target: Knot DNS Resolver $(MAJOR).$(MINOR).$(PATCH)-$(PLATFORM))
$(info Compiler: $(CC) $(BUILD_CFLAGS))
- $(info Linker: $(LD) $(BUILD_LDFLAGS))
+ $(info HARDENING: $(HARDENING))
+ $(info BUILDMODE: $(BUILDMODE))
+ $(info PREFIX: $(PREFIX))
$(info PREFIX: $(PREFIX))
$(info DESTDIR: $(DESTDIR))
$(info BINDIR: $(BINDIR))
$(info [$(HAS_libmemcached)] libmemcached (modules/memcached))
$(info [$(HAS_hiredis)] hiredis (modules/redis))
$(info [$(HAS_cmocka)] cmocka (tests/unit))
- $(info [$(HAS_socket_wrapper)] socket_wrapper (lib))
$(info )
# Installation directories
$(INSTALL) -m 0750 -d $@
# Sub-targets
+include contrib/contrib.mk
include lib/lib.mk
include daemon/daemon.mk
include modules/modules.mk
MAJOR := 1
MINOR := 0
PATCH := 0-beta2
+HARDENING := yes
# Paths
PREFIX := /usr/local
--- /dev/null
+/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * Cleanup attributes.
+ * @cond internal
+ */
+#pragma once
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define auto_free __attribute__((cleanup(_cleanup_free)))
+static inline void _cleanup_free(char **p) {
+ free(*p);
+}
+#define auto_close __attribute__((cleanup(_cleanup_close)))
+static inline void _cleanup_close(int *p) {
+ if (*p > 0) close(*p);
+}
+#define auto_fclose __attribute__((cleanup(_cleanup_fclose)))
+static inline void _cleanup_fclose(FILE **p) {
+ if (*p) fclose(*p);
+}
+/* @endcond */
\ No newline at end of file
*/
#include <uv.h>
+#include <contrib/cleanup.h>
#include <libknot/descriptor.h>
#include "lib/cache.h"
-kresd_EMBED := \
- contrib/ccan/asprintf/asprintf.c
kresd_SOURCES := \
- $(kresd_EMBED) \
daemon/io.c \
daemon/network.c \
daemon/engine.c \
daemon/bindings.c \
daemon/ffimodule.c \
daemon/main.c
+
kresd_DIST := daemon/lua/kres.lua daemon/lua/trust_anchors.lua
# Embedded resources
$(INSTALL) -m 0644 $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
kresd_CFLAGS := -fPIE
-kresd_DEPEND := $(libkres)
-kresd_LIBS := $(libkres_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS)
+kresd_DEPEND := $(libkres) $(contrib)
+kresd_LIBS := $(contrib_TARGET) $(libkres_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS)
# Make binary
ifeq ($(HAS_lua)|$(HAS_libuv), yes|yes)
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <contrib/cleanup.h>
#include <ccan/json/json.h>
#include <ccan/asprintf/asprintf.h>
#include <uv.h>
#include <string.h>
#include <getopt.h>
#include <uv.h>
+#include <contrib/cleanup.h>
+#include <contrib/ucw/mempool.h>
+#include <contrib/ccan/asprintf/asprintf.h>
-#include "contrib/ucw/mempool.h"
-#include "contrib/ccan/asprintf/asprintf.h"
#include "lib/defines.h"
#include "lib/resolve.h"
#include "lib/dnssec.h"
-ccan_EMBED := \
- contrib/ccan/ilog/ilog.c \
- contrib/ccan/isaac/isaac.c \
- contrib/ccan/json/json.c \
- contrib/ucw/mempool.c \
- contrib/murmurhash3/murmurhash3.c
-
libkres_SOURCES := \
- $(ccan_EMBED) \
lib/generic/map.c \
lib/layer/iterate.c \
lib/layer/validate.c \
lib/cache.h
# Dependencies
-libkres_DEPEND :=
+libkres_DEPEND := $(contrib)
libkres_CFLAGS := -fvisibility=hidden -fPIC
-libkres_LIBS := $(libknot_LIBS) $(libdnssec_LIBS)
+libkres_LIBS := $(contrib_TARGET) $(libknot_LIBS) $(libdnssec_LIBS)
libkres_TARGET := -L$(abspath lib) -lkres
# Make library
#include <stdlib.h>
#include <dlfcn.h>
#include <pthread.h>
-#include <unistd.h>
+#include <contrib/cleanup.h>
#include "lib/defines.h"
#include "lib/utils.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <sys/time.h>
+#include <contrib/cleanup.h>
+#include <ccan/isaac/isaac.h>
#include <libknot/descriptor.h>
#include <libknot/dname.h>
#include <libknot/rrtype/rrsig.h>
-#include "ccan/isaac/isaac.h"
#include "lib/defines.h"
#include "lib/utils.h"
#include "lib/generic/array.h"
#include "lib/generic/map.h"
#include "lib/generic/array.h"
-/*
- * General-purpose attributes.
- * @cond internal
- */
-#define auto_free __attribute__((cleanup(_cleanup_free)))
-extern void _cleanup_free(char **p);
-#define auto_close __attribute__((cleanup(_cleanup_close)))
-extern void _cleanup_close(int *p);
-#define auto_fclose __attribute__((cleanup(_cleanup_fclose)))
-extern void _cleanup_fclose(FILE **p);
-/* @endcond */
-
/*
* Logging and debugging.
*/
cachectl_CFLAGS := -fvisibility=hidden -fPIC
cachectl_SOURCES := modules/cachectl/cachectl.c
cachectl_DEPEND := $(libkres)
-cachectl_LIBS := $(libkres_TARGET) $(libkres_LIBS)
+cachectl_LIBS := $(contrib_TARGET) $(libkres_TARGET) $(libkres_LIBS)
$(call make_c_module,cachectl)
\ No newline at end of file
#include <libknot/rrtype/aaaa.h>
#include <ccan/json/json.h>
#include <ucw/mempool.h>
+#include <contrib/cleanup.h>
#include "daemon/engine.h"
#include "lib/zonecut.h"
hints_CFLAGS := -fvisibility=hidden -fPIC
hints_SOURCES := modules/hints/hints.c
hints_DEPEND := $(libkres)
-hints_LIBS := $(libkres_TARGET) $(libkres_LIBS)
+hints_LIBS := $(contrib_TARGET) $(libkres_TARGET) $(libkres_LIBS)
$(call make_c_module,hints)
\ No newline at end of file
-kmemcached_CFLAGS := -fvisibility=hidden
+kmemcached_CFLAGS := -fvisibility=hidden -fPIC
kmemcached_SOURCES := modules/kmemcached/kmemcached.c modules/kmemcached/namedb_memcached.c
kmemcached_LIBS := $(libkres_TARGET) $(libkres_LIBS) $(libmemcached_LIBS)
$(call make_c_module,kmemcached)
-redis_CFLAGS := -fvisibility=hidden
+redis_CFLAGS := -fvisibility=hidden -fPIC
redis_SOURCES := modules/redis/redis.c modules/redis/namedb_redis.c
redis_LIBS := $(libkres_TARGET) $(libkres_LIBS) $(hiredis_LIBS) $(libuv_LIBS)
$(call make_c_module,redis)
#include <libknot/packet/pkt.h>
#include <ccan/json/json.h>
+#include <contrib/cleanup.h>
#include "lib/layer/iterate.h"
#include "lib/rplan.h"
stats_CFLAGS := -fvisibility=hidden -fPIC
stats_SOURCES := modules/stats/stats.c
-stats_DEPEND := $(libkres)
-stats_LIBS := $(libkres_TARGET) $(libkres_LIBS)
+stats_DEPEND := $(libkres) $(contrib)
+stats_LIBS := $(contrib_TARGET) $(libkres_TARGET) $(libkres_LIBS)
$(call make_c_module,stats)