Skip to content

Commit

Permalink
build: cleanup moduledir install, cleanup AMALG= for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Vavruša committed Nov 26, 2015
1 parent db04c01 commit 5ba4c0e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -73,6 +73,11 @@ info:
$(info [$(HAS_socket_wrapper)] socket_wrapper (lib))
$(info )

# Moduledir
$(PREFIX)/$(MODULEDIR):
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)
moduledir: $(PREFIX)/$(MODULEDIR)

# Sub-targets
include lib/lib.mk
include daemon/daemon.mk
Expand Down
15 changes: 8 additions & 7 deletions daemon/daemon.mk
Expand Up @@ -9,26 +9,27 @@ kresd_SOURCES := \
daemon/bindings.c \
daemon/ffimodule.c \
daemon/main.c
kresd_DIST := daemon/lua/kres.lua daemon/lua/trust_anchors.lua

# Embed resources
# Embedded resources
%.inc: %.lua
@$(call quiet,XXD,$<) $< > $@
ifeq ($(AMALG), yes)
kresd.amalg.c: daemon/lua/sandbox.inc daemon/lua/config.inc
else
daemon/engine.o: daemon/lua/sandbox.inc daemon/lua/config.inc
endif
%.inc: %.lua
@$(call quiet,XXD,$<) $< > $@

# Installed FFI bindings
bindings-install: daemon/lua/kres.lua daemon/lua/trust_anchors.lua
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)
$(INSTALL) -m 0644 $^ $(PREFIX)/$(MODULEDIR)
bindings-install: $(kresd_DIST) moduledir
$(INSTALL) -m 0644 $(kresd_DIST) $(PREFIX)/$(MODULEDIR)

kresd_DEPEND := $(libkres)
kresd_LIBS := $(libkres_TARGET) $(libknot_LIBS) $(libdnssec_LIBS) $(libuv_LIBS) $(lua_LIBS)

# Make binary
ifeq ($(HAS_lua)|$(HAS_libuv), yes|yes)
$(eval $(call make_bin,kresd,daemon))
$(eval $(call make_bin,kresd,daemon,yes))
endif

# Targets
Expand Down
2 changes: 1 addition & 1 deletion lib/lib.mk
Expand Up @@ -53,7 +53,7 @@ libkres_LIBS := $(libknot_LIBS) $(libdnssec_LIBS)
libkres_TARGET := -L$(abspath lib) -lkres

# Make library
$(eval $(call make_static,libkres,lib))
$(eval $(call make_static,libkres,lib,yes))

# Targets
lib: $(libkres)
Expand Down
8 changes: 4 additions & 4 deletions modules/modules.mk
Expand Up @@ -32,6 +32,7 @@ endif

# Make C module
define make_c_module
$(1)-install: moduledir
$(eval $(call make_module,$(1),modules/$(1)))
endef

Expand All @@ -44,9 +45,8 @@ endef
define lua_target
$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
$(1)-clean:
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES))
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)
$(INSTALL) -m 0644 $$^ $(PREFIX)/$(MODULEDIR)
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES)) moduledir
$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(PREFIX)/$(MODULEDIR)
.PHONY: $(1) $(1)-install $(1)-clean
endef

Expand All @@ -73,7 +73,7 @@ $(1)-dist: $$($(1)_INSTALL)
$(INSTALL) -d $(PREFIX)/$(MODULEDIR)/$(1)
$(INSTALL) -m 0644 $$^ $(PREFIX)/$(MODULEDIR)/$(1)
endif
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist moduledir
$(INSTALL) $(2)/$(1)$(LIBEXT) $(PREFIX)/$(MODULEDIR)
.PHONY: $(1)-clean $(1)-install $(1)-dist
endef
Expand Down
31 changes: 14 additions & 17 deletions platform.mk
Expand Up @@ -80,30 +80,23 @@ ifeq ($(6), yes)
$(RM) $(1).amalg.c $(1).amalg.o
endif
$(1)-install: $(2)/$(1)$(3)
ifneq ($(5),$(MODULEDIR))
$(INSTALL) -d $(PREFIX)/$(5)
$(INSTALL) $$^ $(PREFIX)/$(5)
endif
$(INSTALL) $(2)/$(1)$(3) $(PREFIX)/$(5)
ifneq ($$(strip $$($(1)_HEADERS)),)
$(INSTALL) -d $(PREFIX)/$(INCLUDEDIR)/$(1)
$(INSTALL) -m 644 $$($(1)_HEADERS) $(PREFIX)/$(INCLUDEDIR)/$(1)
endif
.PHONY: $(1)-clean $(1)-install
endef

# Make targets (name,path)
make_bin = $(call make_target,$(1),$(2),$(BINEXT),$(BINFLAGS),$(BINDIR),yes)
make_lib = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(LIBDIR),yes)
make_module = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(MODULEDIR),no)
make_shared = $(call make_target,$(1),$(2),$(MODEXT),-$(MODTYPE),$(LIBDIR),yes)
make_static = $(call make_target,$(1),$(2),$(AREXT),-$(ARTYPE),$(LIBDIR),yes)

# Evaluate library
define have_lib
ifeq ($$(strip $$($(1)_LIBS)),)
HAS_$(1) := no
else
HAS_$(1) := yes
endif
endef
# Make targets (name,path,amalgable yes|no)
make_bin = $(call make_target,$(1),$(2),$(BINEXT),$(BINFLAGS),$(BINDIR),$(3))
make_lib = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(LIBDIR),$(3))
make_module = $(call make_target,$(1),$(2),$(LIBEXT),-$(LIBTYPE),$(MODULEDIR),$(3))
make_shared = $(call make_target,$(1),$(2),$(MODEXT),-$(MODTYPE),$(LIBDIR),$(3))
make_static = $(call make_target,$(1),$(2),$(AREXT),-$(ARTYPE),$(LIBDIR),$(3))

# Find library (pkg-config)
define find_lib
Expand All @@ -121,7 +114,11 @@ define find_alt
$(1)_LIBS := $(shell pkg-config --libs $(2) --silence-errors)
endif
endif
$(call have_lib,$(1),$(3))
ifeq ($$(strip $$($(1)_LIBS)),)
HAS_$(1) := no
else
HAS_$(1) := yes
endif
endef

# Find binary
Expand Down

0 comments on commit 5ba4c0e

Please sign in to comment.