-
Notifications
You must be signed in to change notification settings - Fork 0
/
declarations.mk
75 lines (58 loc) · 2.02 KB
/
declarations.mk
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
66
67
68
69
70
71
72
73
74
75
# Author: Ethan D. Twardy <[email protected]>
# Created: 01/22/2022
SHELL := /bin/bash
PREFIX=/usr
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)/lib
DATADIR=$(PREFIX)/share
SYSTEMD_SYSTEM_UNITDIR=$(LIBDIR)/systemd/system
QUADLETDIR=$(DATADIR)/containers/systemd
VOLUMETRICDIR=/etc/volumetric/volumes.d
ROOTDIR=$(DATADIR)/twardyece
SERVICEDIR=$(ROOTDIR)
NGINXDIR=$(ROOTDIR)/routes
JENKINSDIR=$(ROOTDIR)/jenkins
###############################################################################
# Utilities and universal rules
###
$(shell mkdir -p $(B))
#: Build package resources
$(B)/build.lock: $(BUILD_TARGETS)
touch $@
build: $(B)/build.lock
define subdirInvoke
$(MAKE) -C $(1) B=$(B)/$(1) $(2);
endef
#: Build package resources in subdirectories
build-subdirs: build
$(foreach subdir,$(SUBDIRS),$(call subdirInvoke,$(subdir),build))
#: Install package files
install-subdirs: build
$(foreach subdir,$(SUBDIRS),$(call subdirInvoke,$(subdir),install))
#: Clean build files
clean-subdirs:
$(foreach subdir,$(SUBDIRS),$(call subdirInvoke,$(subdir),clean))
install:
clean:
# Creates a symlink from foo.target.requires/[email protected] to ../[email protected]
define addRequiresTemplate
mkdir -p $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).requires; \
ln -s ../$$(perl -pe 's/(?<=@)[^.]+//' <<<"$(2)") \
$(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).requires/$(2);
endef
# Creates a symlink from foo.target.requires/bar.service to ../barservice
define addRequires
mkdir -p $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).requires; \
ln -s ../$(2) $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).requires/$(2);
endef
# Create a symlink from foo.target.wants/bar.service to ../bar.service
define addWants
mkdir -p $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).wants; \
ln -s ../$(2) $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).wants/$(2);
endef
# Create a drop-in file that specifies a Before dependency on foo for bar
define dropinBefore
mkdir -p $(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).d; \
printf '%s\n' "[Unit]" "Before=$(2)" \
>$(DESTDIR)$(SYSTEMD_SYSTEM_UNITDIR)/$(1).d/$(2).conf;
endef