# Copyright (C) 2016-2018 Luke Shumaker # SPDX-License-Identifier: AGPL-3.0-or-later # GNU standard settings prefix = /usr/local exec_prefix = $(prefix) bindir = $(exec_prefix)/bin localstatedir = $(prefix)/var runstatedir = $(or $(shell systemd-path system-runtime 2>/dev/null),$(localstatedir)/run) sysconfdir = $(prefix)/etc # systemd settings rootprefix = $(prefix) systemunitdir = $(or $(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null),$(rootprefix)/lib/systemd/system) # other pkgconfdir = $(sysconfdir)/conf.d/qemu.d BINPROG = $(bindir)/qemu SOCAT = /bin/socat outdir = . srcdir = . #### files.out.all += qemu qemu@.service files.sys.all += $(BINPROG) files.sys.all += $(systemunitdir)/qemu@.service files.sys.all += $(pkgconfdir) var = $(patsubst ./%,%,$(outdir)/.var.) all: $(addprefix $(outdir)/,$(files.out.all)) clean: rm -f -- $(addprefix $(outdir)/,$(files.out.all)) install: $(addprefix $(DESTDIR),$(files.sys.all)) .PHONY: all clean install .SECONDARY: .DELETE_ON_ERROR: $(outdir)/qemu: $(var)runstatedir $(var)pkgconfdir $(outdir)/qemu@.service: $(var)runstatedir $(var)BINPROG $(var)SOCAT $(outdir)/%: $(srcdir)/%.in sed $(foreach v,$(patsubst $(var)%,%,$(filter $(var)%,$^)),-e 's|@$v@|$($v)|g') < $< > $@ $(DESTDIR)$(BINPROG): $(outdir)/qemu install -DTm755 $< $@ $(DESTDIR)$(systemunitdir)/%: $(outdir)/% install -DTm644 $< $@ $(DESTDIR)$(pkgconfdir): install -d $@ #### # Magic to depend on the value of variables .PHONY: FORCE $(var)%: FORCE @printf '%s' $(call quote.shell,$($*)) | sed 's/^/#/' | ./write-ifchanged $@ -include $(wildcard $(var)*) define at.nl endef # I put this as the last line in the file because it confuses Emacs # syntax highlighting and makes the remainder of the file difficult to # edit. quote.shell = $(subst $(at.nl),'$$'\n'','$(subst ','\'',$1)')