github.com/Lephar/snapd@v0.0.0-20210825215435-c7fba9cef4d2/data/systemd/Makefile (about) 1 # 2 # Copyright (C) 2017 Canonical Ltd 3 # 4 # This program is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License version 3 as 6 # published by the Free Software Foundation. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 SNAPD_ENVIRONMENT_FILE := /etc/environment 17 SNAP_MOUNT_DIR ?= /snap 18 BINDIR := /usr/bin 19 LIBEXECDIR := /usr/lib 20 SYSTEMDSYSTEMUNITDIR := /lib/systemd/system 21 22 SYSTEMD_UNITS_GENERATED := $(wildcard *.in) 23 # NOTE: sort removes duplicates so this gives us all the units, generated or otherwise 24 SYSTEMD_UNITS = $(sort $(SYSTEMD_UNITS_GENERATED:.in=) $(wildcard *.service) $(wildcard *.timer) $(wildcard *.socket)) 25 26 .PHONY: all 27 all: $(SYSTEMD_UNITS) check 28 29 .PHONY: check 30 check: snapd.run-from-snap snapd.core-fixup.sh 31 if command -v shellcheck >/dev/null; then shellcheck $^; fi 32 33 .PHONY: install 34 install: $(SYSTEMD_UNITS) 35 # NOTE: old (e.g. 14.04) GNU coreutils doesn't -D with -t 36 install -d -m 0755 $(DESTDIR)/$(SYSTEMDSYSTEMUNITDIR) 37 install -m 0644 -t $(DESTDIR)/$(SYSTEMDSYSTEMUNITDIR) $^ 38 install -d -m 0755 $(DESTDIR)/$(LIBEXECDIR)/snapd 39 install -m 0755 -t $(DESTDIR)/$(LIBEXECDIR)/snapd snapd.core-fixup.sh 40 install -m 0755 -t $(DESTDIR)/$(LIBEXECDIR)/snapd snapd.run-from-snap 41 42 .PHONY: clean 43 clean: 44 rm -f $(SYSTEMD_UNITS_GENERATED:.in=) 45 46 %: %.in 47 cat $< | \ 48 sed s:@libexecdir@:$(LIBEXECDIR):g | \ 49 sed s:@SNAPD_ENVIRONMENT_FILE@:$(SNAPD_ENVIRONMENT_FILE):g | \ 50 sed s:@bindir@:$(BINDIR):g | \ 51 sed s:@SNAP_MOUNT_DIR@:$(SNAP_MOUNT_DIR):g | \ 52 cat > $@