modules.mk 2.44 KB
Newer Older
1
# List of built-in modules
2
modules_TARGETS := hints \
3
                   stats
4

5 6 7 8
# Memcached
ifeq ($(HAS_libmemcached),yes)
modules_TARGETS += kmemcached
endif
9 10 11 12
# Redis
ifeq ($(HAS_hiredis),yes)
modules_TARGETS += redis
endif
13

14 15
# List of Lua modules
ifeq ($(HAS_lua),yes)
16
modules_TARGETS += ketcd \
17
                   graphite \
18
                   policy \
19
                   view \
20
                   predict \
21
                   dns64 \
22
                   renumber \
23 24
                   http \
                   daf
25 26
endif

27 28
# Make C module
define make_c_module
29
$(1)-install: $(DESTDIR)$(MODULEDIR)
30 31 32
$(eval $(call make_module,$(1),modules/$(1)))
endef

33 34 35 36 37 38 39
# Make Lua module
define make_lua_module
$(eval $(call lua_target,$(1),modules/$(1)))
endef

# Lua target definition
define lua_target
40
$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
41
$(1)-clean:
42 43 44 45 46 47 48 49 50
ifeq ($$(strip $$($(1)_INSTALL)),)
$(1)-dist:
	$(INSTALL) -d $(DESTDIR)$(MODULEDIR)
else
$(1)-dist: $$($(1)_INSTALL)
	$(INSTALL) -d $(DESTDIR)$(MODULEDIR)/$(1)
	$(INSTALL) -m 0644 $$^ $(DESTDIR)$(MODULEDIR)/$(1)
endif
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES)) $(DESTDIR)$(MODULEDIR) $(1)-dist
51
	$(INSTALL) -m 0644 $$(addprefix $(2)/,$$($(1)_SOURCES)) $(DESTDIR)$(MODULEDIR)
52
.PHONY: $(1) $(1)-install $(1)-clean $(1)-dist
53 54
endef

55 56 57 58 59
# Make Go module
define make_go_module
$(eval $(call go_target,$(1),modules/$(1)))
endef

60 61 62
# Filter CGO flags
CGO_CFLAGS := $(filter-out -flto,$(BUILD_CFLAGS))

63
# Go target definition
64 65
define go_target 
$(1) := $(2)/$(1)$(LIBEXT)
66
$(2)/$(1)$(LIBEXT): $$($(1)_SOURCES) $$($(1)_DEPEND)
67
	@echo "  GO	$(2)"; CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$$($(1)_LIBS) $(CFLAGS)" $(GO) build -buildmode=c-shared -o $$@ $$($(1)_SOURCES)
68
$(1)-clean:
69
	$(RM) -r $(2)/$(1).h $(2)/$(1)$(LIBEXT)
70 71
ifeq ($$(strip $$($(1)_INSTALL)),)
$(1)-dist:
72
	$(INSTALL) -d $(DESTDIR)$(MODULEDIR)
73 74
else
$(1)-dist: $$($(1)_INSTALL)
75 76
	$(INSTALL) -d $(DESTDIR)$(MODULEDIR)/$(1)
	$(INSTALL) -m 0644 $$^ $(DESTDIR)$(MODULEDIR)/$(1)
77
endif
78 79
$(1)-install: $(2)/$(1)$(LIBEXT) $(1)-dist $(DESTDIR)$(MODULEDIR)
	$(INSTALL) $(2)/$(1)$(LIBEXT) $(DESTDIR)$(MODULEDIR)
80
.PHONY: $(1)-clean $(1)-install $(1)-dist
81 82
endef

83 84 85
# Include modules
$(foreach module,$(modules_TARGETS),$(eval include modules/$(module)/$(module).mk))
$(eval modules = $(foreach module,$(modules_TARGETS),$$($(module))))
86

87 88
# Targets
modules: $(modules)
89 90
modules-clean: $(addsuffix -clean,$(modules_TARGETS))
modules-install: $(addsuffix -install,$(modules_TARGETS))
91 92

.PHONY: modules modules-clean modules-install