Commit 374ed2ca authored by Marek Vavruša's avatar Marek Vavruša

contrib: compile to convenience static library

this is needed to make sure it always compiles with PIC
parent 967ce709
......@@ -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
......
......@@ -2,6 +2,7 @@
MAJOR := 1
MINOR := 0
PATCH := 0-beta2
HARDENING := yes
# Paths
PREFIX := /usr/local
......
/* 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
......@@ -15,6 +15,7 @@
*/
#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 \
......@@ -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)
......
......@@ -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>
......
......@@ -18,9 +18,10 @@
#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 \
......@@ -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
......
......@@ -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"
......
......@@ -17,15 +17,15 @@
#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"
......
......@@ -23,18 +23,6 @@
#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
......@@ -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"
......
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)
......@@ -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"
......
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment