]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib: allow building with only core library (no cache and no lmdb) separate-library
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 12 Feb 2019 18:36:19 +0000 (10:36 -0800)
committerPetr Špaček <petr.spacek@nic.cz>
Tue, 12 Feb 2019 19:45:11 +0000 (19:45 +0000)
contrib/contrib.mk
lib/lib.mk
lib/module.c

index c8be0246ecd53b79e367b58fc608afb11e806482..2d7b2dd8968e6fecffd41862a95f3367aa88630f 100644 (file)
@@ -1,7 +1,6 @@
 contrib_SOURCES := \
        contrib/ccan/asprintf/asprintf.c \
        contrib/ccan/ilog/ilog.c \
-       contrib/ccan/json/json.c \
        contrib/ucw/mempool.c \
        contrib/ucw/mempool-fmt.c \
        contrib/murmurhash3/murmurhash3.c \
@@ -10,6 +9,9 @@ contrib_SOURCES := \
 contrib_CFLAGS := -fPIC
 contrib_TARGET := $(abspath contrib)/contrib$(AREXT)
 
+ifneq ($(LIBRARY_ONLY), yes)
+contrib_SOURCES += contrib/ccan/json/json.c
+
 # Use built-in LMDB if not found
 ifneq ($(HAS_lmdb), yes)
 contrib_SOURCES += contrib/lmdb/mdb.c \
@@ -18,5 +20,7 @@ contrib_CFLAGS  += -pthread
 contrib_LIBS    += -pthread
 lmdb_CFLAGS     += -I$(abspath contrib/lmdb)
 endif
+endif
+
 
 $(eval $(call make_static,contrib,contrib))
index 6560c6ea5069967777ce4ddf8816198448da099a..5419511321fd335afc6ac06b6c375d61796d38bc 100644 (file)
@@ -1,13 +1,4 @@
 libkres_SOURCES := \
-       lib/cache/api.c \
-       lib/cache/cdb_lmdb.c \
-       lib/cache/entry_list.c \
-       lib/cache/entry_pkt.c \
-       lib/cache/entry_rr.c \
-       lib/cache/knot_pkt.c \
-       lib/cache/nsec1.c \
-       lib/cache/nsec3.c \
-       lib/cache/peek.c \
        lib/dnssec.c \
        lib/dnssec/nsec.c \
        lib/dnssec/nsec3.c \
@@ -17,7 +8,6 @@ libkres_SOURCES := \
        lib/generic/map.c \
        lib/generic/queue.c \
        lib/generic/trie.c \
-       lib/layer/cache.c \
        lib/layer/iterate.c \
        lib/layer/validate.c \
        lib/module.c \
@@ -29,9 +19,6 @@ libkres_SOURCES := \
 
 libkres_HEADERS := \
        lib/cache/api.h \
-       lib/cache/cdb_api.h \
-       lib/cache/cdb_lmdb.h \
-       lib/cache/impl.h \
        lib/defines.h \
        lib/dnssec.h \
        lib/dnssec/nsec.h \
@@ -55,10 +42,35 @@ libkres_HEADERS := \
 
 # Dependencies
 libkres_DEPEND := $(contrib)
-libkres_CFLAGS := -fPIC $(lmdb_CFLAGS)
-libkres_LIBS := $(contrib_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(lmdb_LIBS) $(gnutls_LIBS)
+libkres_CFLAGS := -fPIC
+libkres_LIBS := $(contrib_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(gnutls_LIBS)
 libkres_TARGET := -L$(abspath lib) -lkres
 
+ifneq ($(LIBRARY_ONLY), yes)
+libkres_SOURCES += \
+       lib/layer/cache.c \
+       lib/cache/api.c \
+       lib/cache/cdb_lmdb.c \
+       lib/cache/entry_list.c \
+       lib/cache/entry_pkt.c \
+       lib/cache/entry_rr.c \
+       lib/cache/knot_pkt.c \
+       lib/cache/nsec1.c \
+       lib/cache/nsec3.c \
+       lib/cache/peek.c
+
+libkres_HEADERS += \
+       lib/cache/cdb_api.h \
+       lib/cache/cdb_lmdb.h \
+       lib/cache/impl.h
+
+libkres_CFLAGS += $(lmdb_CFLAGS)
+libkres_LIBS += $(lmdb_LIBS)
+else
+libkres_CFLAGS += -DLIBRARY_ONLY
+endif
+
+
 ifeq ($(ENABLE_COOKIES),yes)
 libkres_SOURCES += \
        lib/cookies/alg_containers.c \
index 68abc84b933e4041b0f587dda3fb140b71d009b6..ce0df7343af1bab1bc45ddf69adfc70790df6af9 100644 (file)
@@ -30,7 +30,9 @@ const kr_layer_api_t *cache_layer(struct kr_module *module);
 static const struct kr_module embedded_modules[] = {
        { "iterate",  NULL, NULL, NULL, iterate_layer,  NULL, NULL, NULL },
        { "validate", NULL, NULL, NULL, validate_layer, NULL, NULL, NULL },
+#ifndef LIBRARY_ONLY
        { "cache",    NULL, NULL, NULL, cache_layer,    NULL, NULL, NULL },
+#endif
 };
 
 /** Library extension. */