From: Marek VavruĊĦa Date: Sun, 6 Dec 2015 12:20:39 +0000 (+0100) Subject: build: *DIR variables are assembled in Makefile X-Git-Tag: v1.0.0-beta3~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0343095614bbfd3ae464f11bb183891dde08cce;p=thirdparty%2Fknot-resolver.git build: *DIR variables are assembled in Makefile this allows to override any dstdir variable without patching config.mk --- diff --git a/Makefile b/Makefile index 298429deb..63bfdea57 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/config.mk b/config.mk index c7c2e51d1..5b99b3478 100644 --- a/config.mk +++ b/config.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 diff --git a/daemon/daemon.mk b/daemon/daemon.mk index 7a156b436..f8751188a 100644 --- a/daemon/daemon.mk +++ b/daemon/daemon.mk @@ -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) diff --git a/daemon/engine.c b/daemon/engine.c index 78eb0a466..ac52ba059 100644 --- a/daemon/engine.c +++ b/daemon/engine.c @@ -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); diff --git a/etc/etc.mk b/etc/etc.mk index 4a5a428fa..eb2aa97ff 100644 --- a/etc/etc.mk +++ b/etc/etc.mk @@ -1,6 +1,6 @@ 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 diff --git a/lib/module.c b/lib/module.c index 6b4316247..369be3aa2 100644 --- a/lib/module.c +++ b/lib/module.c @@ -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; } } diff --git a/modules/modules.mk b/modules/modules.mk index a607f76c7..98c82bd4d 100644 --- a/modules/modules.mk +++ b/modules/modules.mk @@ -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 diff --git a/platform.mk b/platform.mk index 993bb1d6d..c5c15fcd3 100644 --- a/platform.mk +++ b/platform.mk @@ -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