# Tools
CC ?= cc
-CFLAGS += -std=c99 -D_GNU_SOURCE -Wall -fPIC -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib)
+CFLAGS += -std=c99 -D_GNU_SOURCE -Wall -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib)
CFLAGS += -DPACKAGE_VERSION="\"$(MAJOR).$(MINOR)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\""
RM := rm -f
LN := ln -s
/** Make next iterative query. */
int kr_make_query(struct kr_query *query, knot_pkt_t *pkt);
-
-/* Processing module implementation. */
-const knot_layer_api_t *iterate_layer(struct kr_module *module);
+++ /dev/null
-/* Copyright (C) 2014 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/>.
- */
-
-#pragma once
-
-#include "lib/layer.h"
-
-/* Processing module implementation. */
-const knot_layer_api_t *rrcache_layer(struct kr_module *module);
libkresolve_TARGET := -Wl,-rpath,lib -Llib -lkresolve
# Make library
-$(eval $(call make_lib,libkresolve,lib))
+$(eval $(call make_static,libkresolve,lib))
# Targets
lib: $(libkresolve)
#include "lib/utils.h"
#include "lib/module.h"
+/* List of embedded modules */
+const knot_layer_api_t *iterate_layer(struct kr_module *module);
+const knot_layer_api_t *rrcache_layer(struct kr_module *module);
+const knot_layer_api_t *pktcache_layer(struct kr_module *module);
+static const struct kr_module embedded_modules[] = {
+ { "iterate", NULL, NULL, NULL, iterate_layer, NULL, NULL, NULL },
+ { "rrcache", NULL, NULL, NULL, rrcache_layer, NULL, NULL, NULL },
+ { "pktcache", NULL, NULL, NULL, pktcache_layer, NULL, NULL, NULL },
+};
+
/** Library extension. */
#if defined(__APPLE__)
#define LIBEXT ".dylib"
#elif _WIN32
- #define LIBEXT ".lib"
+ #define LIBEXT ".dll"
#else
#define LIBEXT ".so"
#endif
/** Load C module symbols. */
static int load_sym_c(struct kr_module *module, uint32_t api_required)
{
+ /* Check if it's embedded first */
+ for (unsigned i = 0; i < sizeof(embedded_modules)/sizeof(embedded_modules[0]); ++i) {
+ const struct kr_module *embedded = &embedded_modules[i];
+ if (strcmp(module->name, embedded->name) == 0) {
+ module->init = embedded->init;
+ module->deinit = embedded->deinit;
+ module->config = embedded->config;
+ module->layer = embedded->layer;
+ return kr_ok();
+ }
+ }
+ /* Load dynamic library module */
auto_free char *module_prefix = kr_strcatdup(2, module->name, "_");
ABI_CHECK(module, module_prefix, "api", api_required);
ABI_LOAD(module, module_prefix, "init", "deinit", "config", "layer", "props");
GCCGO := gccgo
LIBEXT := .so
MODEXT := $(LIBEXT)
+AREXT := .a
LIBTYPE := shared
MODTYPE := shared
+ARTYPE := static
BINEXT :=
PLATFORM = Linux
ifeq ($(OS),Windows_NT)
$$(eval $$(call make_objs,$(1)))
$(1) := $(2)/$(1)$(3)
$(2)/$(1)$(3): $$($(1)_OBJ) $$($(1)_DEPEND)
+ifeq ($(4),-$(ARTYPE))
+ $(call quiet,AR,$$@) rcs $$@ $$($(1)_OBJ)
+else
$(call quiet,CCLD,$$@) $(CFLAGS) $$($(1)_OBJ) -o $$@ $(4) $(LDFLAGS) $$($(1)_LIBS)
+endif
$(1)-clean:
$(RM) $$($(1)_OBJ) $$($(1)_DEP) $(2)/$(1)$(3)
$(1)-install: $(2)/$(1)$(3)
make_lib = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(LIBDIR))
make_module = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(MODULEDIR))
make_shared = $(call make_target,$(1),$(2),$(MODEXT),-$(MODTYPE),$(LIBDIR))
+make_static = $(call make_target,$(1),$(2),$(AREXT),-$(ARTYPE),$(LIBDIR))
# Evaluate library
define have_lib