]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
contrib: compile to convenience static library
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 9 Dec 2015 18:30:22 +0000 (19:30 +0100)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 9 Dec 2015 18:30:22 +0000 (19:30 +0100)
this is needed to make sure it always compiles with PIC

18 files changed:
Makefile
config.mk
contrib/cleanup.h [new file with mode: 0644]
daemon/bindings.c
daemon/daemon.mk
daemon/engine.c
daemon/main.c
lib/lib.mk
lib/module.c
lib/utils.c
lib/utils.h
modules/cachectl/cachectl.mk
modules/hints/hints.c
modules/hints/hints.mk
modules/kmemcached/kmemcached.mk
modules/redis/redis.mk
modules/stats/stats.c
modules/stats/stats.mk

index 3a69c9aab4d9a76daaa19d49c8c501407954c41e..93e16e43c64c11cfcf2e9dde08ff23765995f121 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ include platform.mk
 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
 
@@ -49,7 +49,9 @@ BUILD_CFLAGS += $(addprefix -I,$(wildcard contrib/ccan/*) contrib/murmurhash3)
 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))
@@ -72,7 +74,6 @@ info:
        $(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
@@ -82,6 +83,7 @@ $(DESTDIR)$(ETCDIR):
        $(INSTALL) -m 0750 -d $@
 
 # Sub-targets
+include contrib/contrib.mk
 include lib/lib.mk
 include daemon/daemon.mk
 include modules/modules.mk
index 9c45b6a588033d2ce33eb1ace59acc68af73d118..4a0719a54513292ac8568ebbcfb40a843a2ca112 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -2,6 +2,7 @@
 MAJOR := 1
 MINOR := 0
 PATCH := 0-beta2
+HARDENING := yes
 
 # Paths
 PREFIX := /usr/local
diff --git a/contrib/cleanup.h b/contrib/cleanup.h
new file mode 100644 (file)
index 0000000..7dcd750
--- /dev/null
@@ -0,0 +1,37 @@
+/*  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
index 9c751146a1ad73fb072828d746cf353363554cbb..e97230c91af78593f598024f9f298fc97b28ca85 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <uv.h>
+#include <contrib/cleanup.h>
 #include <libknot/descriptor.h>
 
 #include "lib/cache.h"
index 50a5c1b1f2088f6ccda80e8a23fa58107467a088..b3ee60de9e9b2617b54f3539ada999539415da7a 100644 (file)
@@ -1,7 +1,4 @@
-kresd_EMBED := \
-       contrib/ccan/asprintf/asprintf.c
 kresd_SOURCES := \
-       $(kresd_EMBED)   \
        daemon/io.c          \
        daemon/network.c     \
        daemon/engine.c      \
@@ -9,6 +6,7 @@ kresd_SOURCES := \
        daemon/bindings.c    \
        daemon/ffimodule.c   \
        daemon/main.c
+
 kresd_DIST := daemon/lua/kres.lua daemon/lua/trust_anchors.lua
 
 # Embedded resources
@@ -25,8 +23,8 @@ bindings-install: $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
        $(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)
index ac52ba0593fb557069f7110a42c8352c1dae2b8c..2890c598ff18efc2c6d692593957761a3c8f3350 100644 (file)
@@ -14,6 +14,7 @@
     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>
index ba653431e93b9c905b4bd724c76d055ddca2c194..f874a1f15e18ec1699f39d45ac9a109a5384f672 100644 (file)
 #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"
index f068e23fdaa24ff27453770b706a33da09441623..d981e4f777f19adc582abc760c550a405e92bd53 100644 (file)
@@ -1,12 +1,4 @@
-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   \
@@ -47,9 +39,9 @@ libkres_HEADERS := \
        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
index 369be3aa26513d4615eb0ef9c303e82f3423a2dd..cd075a8eee0c83682564e3da0378be912f64b3be 100644 (file)
@@ -17,7 +17,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 #include <pthread.h>
-#include <unistd.h>
+#include <contrib/cleanup.h>
 
 #include "lib/defines.h"
 #include "lib/utils.h"
index d2715592a5e009b26088c11ccdf829ec86c77032..22365787c083cc46119528711eba32f087e14d2d 100644 (file)
 #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"
index a0f10bad8eb60ed00c4fec7137b1d575151bbc82..a5b34dffcb0b6b2e41ac1c5b956255ac6602ecdd 100644 (file)
 #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.
  */
index cb21be1bb1f921ac443239c2b4bd206032a050cf..f39cfa60a3c06df82872424c01e515cc7d8c0674 100644 (file)
@@ -1,5 +1,5 @@
 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
index 776c8c6a173e20bb8946901bed3f2522453cb250..03c13ce0699e6bea705f9731d815ad9bab4866bb 100644 (file)
@@ -26,6 +26,7 @@
 #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"
index 3573027f7af31253bd361ea37932665563c87303..c7bb521be5536c35e76ab7e3ea3e43966dd405e4 100644 (file)
@@ -1,5 +1,5 @@
 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
index 87462a707135922d59cb6220a16f276ee09ba85e..148bd5952918d8bf227f1f510cb0860941143673 100644 (file)
@@ -1,4 +1,4 @@
-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)
index 765f231aeef5060980edbad8ac45d3c47ca54b8a..2cb4463a7e0fd2a2cdcf7e85ca62945056858133 100644 (file)
@@ -1,4 +1,4 @@
-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)
index 11c1c8a33edccb3f52cfc12edb78c0564c9b0911..2b3e6219e7a4f25747a18cddbd3c0793a6528184 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <libknot/packet/pkt.h>
 #include <ccan/json/json.h>
+#include <contrib/cleanup.h>
 
 #include "lib/layer/iterate.h"
 #include "lib/rplan.h"
index b56c072a95c513d8c167053d49f92749c1dee8fb..17e462472787a02baaaf19007af1b8f7e647b213 100644 (file)
@@ -1,5 +1,5 @@
 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)