# Copyright (c) 2012-2014 Kaarle Ritvanen # See LICENSE file for license details ROOT_DIR := / LUA_VERSION := 5.2 confdir := etc/aconf luadir := usr/share/lua/$(LUA_VERSION)/aconf resdir := usr/share/aconf webdir := $(resdir)/web starter := usr/sbin/aconfd all: install define _copy = install -d $$(dir $$@) install -m $(if $(1),$(1),644) $$< $$@ endef define copy = $(ROOT_DIR)/$(2)/$(3): $(1)/$(3) $(call _copy,$(4)) files += $(2)/$(3) endef define rcopy = $(ROOT_DIR)/$(2)/%.$(3): $(1)/%.$(3) $(call _copy) files += $(patsubst $(1)/%.$(3),$(2)/%.$(3),$(shell find $(1) -name '*.$(3)' $(4))) endef define link = $(ROOT_DIR)/$(resdir)/$(1): install -d $$(dir $$@) ln -s /$(2) $$@ files += $(resdir)/$(1) endef $(eval $(call link,aconf,$(luadir))) $(eval $(call rcopy,aconf,$(luadir),lua,-not -path 'aconf/modules/demo-*')) $(eval $(call link,config,$(confdir))) $(eval $(call copy,config,$(confdir),aaa.json,600)) $(eval $(call copy,.,$(resdir),LICENSE)) $(ROOT_DIR)/$(starter): run-server.sh install -d $(dir $@) install -m 755 $< $@ $(eval $(call copy,.,$(resdir),server.lua)) $(eval $(call copy,web,$(webdir),client.css)) $(eval $(call copy,web,$(webdir),client.html)) $(eval $(call rcopy,web,$(webdir),js)) install: $(foreach f,$(files),$(ROOT_DIR)/$(f)) $(ROOT_DIR)/$(starter) .PHONY: all install