-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
65 lines (50 loc) · 1.98 KB
/
Makefile
1
2
3
4
5
6
7
8
9
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
PREFIX ?= /usr/local
# This INIT_FILES_PREFIX could be different than PREFIX, as INIT_FILES_PREFIX
# is defined as the location of init scripts and must be placed in a specific
# place. The main use of this variable is for testing the build system
INIT_FILES_PREFIX ?=
BIN_FILES_PREFIX ?= /usr/local
CMDSEP = ;
PWD = $(shell pwd)
MKDIR = mkdir
RMDIR = rmdir
CP = cp
INSTALL = install
RM = rm
INIT_SYSTEM := systemd
# Input files
SRC_DOCKER_FILE = Dockerfile
SERVICE_NAME = docker-dmm7510@
# Generated names from Input
DOCKER_FILES_DEST = ${PREFIX}/etc/${SERVICE_NAME}
# All installable files grouped
DOCKER_FILES_FULL_NAME := ${SRC_DOCKER_FILE}
# Strip off a leading ./
DOCKER_FILES=$(DOCKER_FILES_FULL_NAME:./%=%)
# Script files
INIT_FILES_FULL_NAME := $(shell cd ${INIT_SYSTEM} && find etc -type f)
# Strip off a leading ./
INIT_FILES=$(INIT_FILES_FULL_NAME:./%=%)
INIT_FILES_ABS=$(INIT_FILES:%=/%)
INIT_FILES_DIR=$(dir $(INIT_FILES_PREFIX)$(INIT_FILES_ABS))
# Binary files
BIN_FILES_FULL_NAME := $(shell cd ${INIT_SYSTEM} && find bin -type f)
# Strip off a leading ./
BIN_FILES=$(BIN_FILES_FULL_NAME:./%=%)
.PHONY: all clean mrproper install uninstall
all:
install:
${MKDIR} -p ${DOCKER_FILES_DEST}
${MKDIR} -p ${INIT_FILES_DIR}
$(foreach dockerfile,$(DOCKER_FILES),cp --preserve=mode --parents $(dockerfile) ${DOCKER_FILES_DEST}/ $(CMDSEP))
$(foreach script,$(INIT_FILES),cp --preserve=mode ${INIT_SYSTEM}/$(script) ${INIT_FILES_PREFIX}/$(script) $(CMDSEP))
$(foreach bin,$(BIN_FILES),cp --preserve=mode ${INIT_SYSTEM}/$(bin) ${BIN_FILES_PREFIX}/$(bin) $(CMDSEP))
-./scripts/enable-service.sh -s $(SERVICE_NAME)
uninstall:
-./scripts/disable-service.sh -s $(SERVICE_NAME)
-$(foreach bin,$(BIN_FILES),rm -f ${BIN_FILES_PREFIX}/$(bin) $(CMDSEP))
-$(foreach script,$(INIT_FILES),rm -f ${INIT_FILES_PREFIX}/$(script) $(CMDSEP))
$(foreach dockerfile,$(DOCKER_FILES),rm -f ${DOCKER_FILES_DEST}/$(dockerfile) $(CMDSEP))
-${RMDIR} ${DOCKER_FILES_DEST}
clean:
mrproper: clean