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

build: DESTDIR= support, doc

parent f0343095
......@@ -51,6 +51,7 @@ info:
$(info Compiler: $(CC) $(BUILD_CFLAGS))
$(info Linker: $(LD) $(BUILD_LDFLAGS))
$(info PREFIX: $(PREFIX))
$(info DESTDIR: $(DESTDIR))
$(info BINDIR: $(BINDIR))
$(info LIBDIR: $(LIBDIR))
$(info ETCDIR: $(ETCDIR))
......@@ -75,12 +76,10 @@ info:
$(info )
# Installation directories
$(MODULEDIR):
$(DESTDIR)$(MODULEDIR):
$(INSTALL) -d $@
moduledir: $(MODULEDIR)
$(ETCDIR):
$(DESTDIR)$(ETCDIR):
$(INSTALL) -m 0750 -d $@
etcdir: $(ETCDIR)
# Sub-targets
include lib/lib.mk
......
......@@ -21,8 +21,8 @@ daemon/engine.o: daemon/lua/sandbox.inc daemon/lua/config.inc
endif
# Installed FFI bindings
bindings-install: $(kresd_DIST) moduledir
$(INSTALL) -m 0644 $(kresd_DIST) $(MODULEDIR)
bindings-install: $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
$(INSTALL) -m 0644 $(kresd_DIST) $(DESTDIR)$(MODULEDIR)
kresd_DEPEND := $(libkres)
kresd_LIBS := $(libkres_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS)
......
......@@ -123,6 +123,18 @@ Alternatively you can build only specific parts of the project, i.e. ``library``
.. note:: Documentation is not built by default, run ``make doc`` to build it.
Building for packages
~~~~~~~~~~~~~~~~~~~~~
The build system supports both DESTDIR_ and `amalgamated builds <https://www.sqlite.org/amalgamation.html>`_.
.. code-block:: bash
$ make install DESTDIR=/tmp/stage # Staged install
$ make all install AMALG=yes # Amalgamated build
.. note:: Amalgamated build assembles everything in one source file and compiles it. It is useful for packages, as the compiler sees the whole program and is able to produce a smaller and faster binary. On the other hand, it complicates debugging.
Building dependencies
~~~~~~~~~~~~~~~~~~~~~
......@@ -195,3 +207,5 @@ Read the `documentation <deckard_doc>`_ for more information about requirements,
.. _deckard: https://gitlab.labs.nic.cz/knot/deckard
.. _deckard_doc: https://gitlab.labs.nic.cz/knot/resolver/blob/master/tests/README.rst
.. _DESTDIR: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
etc_SOURCES := icann-ca.pem
etc-install: etcdir
$(INSTALL) -m 0640 $(addprefix etc/,$(etc_SOURCES)) $(ETCDIR)
etc-install: $(DESTDIR)$(ETCDIR)
$(INSTALL) -m 0640 $(addprefix etc/,$(etc_SOURCES)) $(DESTDIR)$(ETCDIR)
.PHONY: etc-install
......@@ -32,7 +32,7 @@ endif
# Make C module
define make_c_module
$(1)-install: moduledir
$(1)-install: $(DESTDIR)$(MODULEDIR)
$(eval $(call make_module,$(1),modules/$(1)))
endef
......@@ -45,8 +45,8 @@ endef
define lua_target
$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
$(1)-clean:
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES)) moduledir
$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(MODULEDIR)
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES)) $(DESTDIR)$(MODULEDIR)
$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(DESTDIR)$(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 $(MODULEDIR)
$(INSTALL) -d $(DESTDIR)$(MODULEDIR)
else
$(1)-dist: $$($(1)_INSTALL)
$(INSTALL) -d $(MODULEDIR)/$(1)
$(INSTALL) -m 0644 $$^ $(MODULEDIR)/$(1)
$(INSTALL) -d $(DESTDIR)$(MODULEDIR)/$(1)
$(INSTALL) -m 0644 $$^ $(DESTDIR)$(MODULEDIR)/$(1)
endif
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist moduledir
$(INSTALL) $(2)/$(1)$(LIBEXT) $(MODULEDIR)
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist $(DESTDIR)$(MODULEDIR)
$(INSTALL) $(2)/$(1)$(LIBEXT) $(DESTDIR)$(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 $(5)
$(INSTALL) -d $(DESTDIR)$(5)
endif
$(INSTALL) $(2)/$(1)$(3) $(5)
$(INSTALL) $(2)/$(1)$(3) $(DESTDIR)$(5)
ifneq ($$(strip $$($(1)_HEADERS)),)
$(INSTALL) -d $(INCLUDEDIR)/$(1)
$(INSTALL) -m 644 $$($(1)_HEADERS) $(INCLUDEDIR)/$(1)
$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)/$(1)
$(INSTALL) -m 644 $$($(1)_HEADERS) $(DESTDIR)$(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