Commit f0343095 authored by Marek Vavruša's avatar Marek Vavruša

build: *DIR variables are assembled in Makefile

this allows to override any dstdir variable without
patching config.mk
parent 1af623da
......@@ -75,12 +75,12 @@ info:
$(info )
# Installation directories
$(PREFIX)/$(MODULEDIR):
$(MODULEDIR):
$(INSTALL) -d $@
moduledir: $(PREFIX)/$(MODULEDIR)
$(PREFIX)/$(ETCDIR):
moduledir: $(MODULEDIR)
$(ETCDIR):
$(INSTALL) -m 0750 -d $@
etcdir: $(PREFIX)/$(ETCDIR)
etcdir: $(ETCDIR)
# Sub-targets
include lib/lib.mk
......
......@@ -5,11 +5,11 @@ PATCH := 0-beta2
# Paths
PREFIX := /usr/local
BINDIR := /bin
LIBDIR := /lib
INCLUDEDIR := /include
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
INCLUDEDIR := $(PREFIX)/include
MODULEDIR := $(LIBDIR)/kdns_modules
ETCDIR := /etc/kresd
ETCDIR := $(PREFIX)/etc/kresd
# Tools
CC ?= cc
......
......@@ -22,7 +22,7 @@ endif
# Installed FFI bindings
bindings-install: $(kresd_DIST) moduledir
$(INSTALL) -m 0644 $(kresd_DIST) $(PREFIX)/$(MODULEDIR)
$(INSTALL) -m 0644 $(kresd_DIST) $(MODULEDIR)
kresd_DEPEND := $(libkres)
kresd_LIBS := $(libkres_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS)
......
......@@ -396,9 +396,9 @@ static int init_state(struct engine *engine)
lua_setglobal(engine->L, "user");
lua_pushcfunction(engine->L, l_libpath);
lua_setglobal(engine->L, "libpath");
lua_pushliteral(engine->L, PREFIX MODULEDIR);
lua_pushliteral(engine->L, MODULEDIR);
lua_setglobal(engine->L, "moduledir");
lua_pushliteral(engine->L, PREFIX ETCDIR);
lua_pushliteral(engine->L, ETCDIR);
lua_setglobal(engine->L, "etcdir");
lua_pushlightuserdata(engine->L, engine);
lua_setglobal(engine->L, "__engine");
......@@ -506,7 +506,7 @@ int engine_cmd(struct engine *engine, const char *str)
static int engine_loadconf(struct engine *engine, const char *config_path)
{
/* Use module path for including Lua scripts */
static const char l_paths[] = "package.path = package.path..';" PREFIX MODULEDIR "/?.lua'";
static const char l_paths[] = "package.path = package.path..';" MODULEDIR "/?.lua'";
int ret = l_dobytecode(engine->L, l_paths, sizeof(l_paths) - 1, "");
if (ret != 0) {
lua_pop(engine->L, 1);
......
etc_SOURCES := icann-ca.pem
etc-install: etcdir
$(INSTALL) -m 0640 $(addprefix etc/,$(etc_SOURCES)) $(PREFIX)/$(ETCDIR)
$(INSTALL) -m 0640 $(addprefix etc/,$(etc_SOURCES)) $(ETCDIR)
.PHONY: etc-install
......@@ -139,9 +139,9 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path)
/* Search for module library, use current namespace if not found. */
if (load_library(module, name, path) != 0) {
/* Expand HOME env variable, as the linker may not expand it. */
auto_free char *local_path = kr_strcatdup(2, getenv("HOME"), "/.local" MODULEDIR);
auto_free char *local_path = kr_strcatdup(2, getenv("HOME"), "/.local/lib/kdns_modules");
if (load_library(module, name, local_path) != 0) {
if (load_library(module, name, PREFIX MODULEDIR) != 0) {
if (load_library(module, name, MODULEDIR) != 0) {
module->lib = RTLD_DEFAULT;
}
}
......
......@@ -46,7 +46,7 @@ define lua_target
$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
$(1)-clean:
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES)) moduledir
$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(PREFIX)/$(MODULEDIR)
$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(MODULEDIR)
.PHONY: $(1) $(1)-install $(1)-clean
endef
......@@ -67,14 +67,14 @@ $(1)-clean:
$(RM) -r $(2)/$(1).h $(2)/$(1)$(LIBEXT)
ifeq ($$(strip $$($(1)_INSTALL)),)
$(1)-dist:
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)
$(INSTALL) -d $(MODULEDIR)
else
$(1)-dist: $$($(1)_INSTALL)
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)/$(1)
$(INSTALL) -m 0644 $$^ $(PREFIX)/$(MODULEDIR)/$(1)
$(INSTALL) -d $(MODULEDIR)/$(1)
$(INSTALL) -m 0644 $$^ $(MODULEDIR)/$(1)
endif
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist moduledir
$(INSTALL) $(2)/$(1)$(LIBEXT) $(PREFIX)/$(MODULEDIR)
$(INSTALL) $(2)/$(1)$(LIBEXT) $(MODULEDIR)
.PHONY: $(1)-clean $(1)-install $(1)-dist
endef
......
......@@ -81,12 +81,12 @@ ifeq ($(6), yes)
endif
$(1)-install: $(2)/$(1)$(3)
ifneq ($(5),$(MODULEDIR))
$(INSTALL) -d $(PREFIX)/$(5)
$(INSTALL) -d $(5)
endif
$(INSTALL) $(2)/$(1)$(3) $(PREFIX)/$(5)
$(INSTALL) $(2)/$(1)$(3) $(5)
ifneq ($$(strip $$($(1)_HEADERS)),)
$(INSTALL) -d $(PREFIX)/$(INCLUDEDIR)/$(1)
$(INSTALL) -m 644 $$($(1)_HEADERS) $(PREFIX)/$(INCLUDEDIR)/$(1)
$(INSTALL) -d $(INCLUDEDIR)/$(1)
$(INSTALL) -m 644 $$($(1)_HEADERS) $(INCLUDEDIR)/$(1)
endif
.PHONY: $(1)-clean $(1)-install
endef
......
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