Makefile 1.2 KB
Newer Older
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
1
# Installer Makefile for Alpine Wall
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
2
# Copyright (C) 2012-2017 Kaarle Ritvanen
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
3
# See LICENSE file for license details
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
4 5

ROOT_DIR := /
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
6
LUA_VERSION := 5.2
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
7

8
resdir := usr/share/awall
9
confdir := etc/awall
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

all:	install

define mkdir =
$(ROOT_DIR)/$(1):
	install -d $$@

files += $(1)
endef

define copy =
$(ROOT_DIR)/$(2)/%.$(3): $(1)/%.$(3)
	install -d $$(dir $$@)
	install -m 644 $$< $$@

files += $(patsubst $(1)/%.$(3),$(2)/%.$(3),$(shell find $(1) -name '*.$(3)'))
endef

define rename =
$(ROOT_DIR)/$(2): $(1)
	install -d $$(dir $$@)
	install -m $(3) $(1) $$@

files += $(2)
endef

$(eval $(call copy,awall,usr/share/lua/$(LUA_VERSION)/awall,lua))
37
$(eval $(call copy,json,$(resdir)/mandatory,json))
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
38 39

$(eval $(call rename,awall-cli,usr/sbin/awall,755))
40
$(eval $(call rename,sample-policy.json,$(resdir)/sample/sample-policy.json,644))
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
41

42 43
$(eval $(call mkdir,$(confdir)))
$(eval $(call mkdir,$(confdir)/optional))
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
44
$(eval $(call mkdir,$(confdir)/private))
45 46
$(eval $(call mkdir,$(resdir)/optional))
$(eval $(call mkdir,$(resdir)/private))
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
47

48 49 50 51 52
$(ROOT_DIR)/$(resdir)/modules:
	install -d $(dir $@)
	ln -s ../lua/$(LUA_VERSION)/awall/modules $@

install: $(foreach f,$(files),$(ROOT_DIR)/$(f)) $(ROOT_DIR)/$(resdir)/modules
Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
53 54

.PHONY: all