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

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

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

26
# List of Golang modules
27
ifeq ($(HAS_go),yes)
28 29 30
ifeq ($(HAS_geoip),yes)
modules_TARGETS += tinyweb
endif
31 32
endif

33 34 35 36 37
# Make C module
define make_c_module
$(eval $(call make_module,$(1),modules/$(1)))
endef

38 39 40 41 42 43 44
# Make Lua module
define make_lua_module
$(eval $(call lua_target,$(1),modules/$(1)))
endef

# Lua target definition
define lua_target
45
$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
46
$(1)-clean:
47
$(1)-install: $$(addprefix $(2)/,$$($(1)_SOURCES))
48
	$(INSTALL) -d $(PREFIX)/$(MODULEDIR)
49
	$(INSTALL) -m 0644 $$^ $(PREFIX)/$(MODULEDIR)
50
.PHONY: $(1) $(1)-install $(1)-clean
51 52
endef

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

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

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

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

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

.PHONY: modules modules-clean modules-install