#!/usr/bin/make -f
-BINDIR=$(DESTDIR)/usr/bin
-LIBEXECDIR=$(DESTDIR)/usr/libexec/mythtv-status
-MANDIR=$(DESTDIR)/usr/man
-MOLLY_GUARDDIR=$(DESTDIR)/etc/molly-guard/run.d
-SBINDIR=$(DESTDIR)/usr/sbin
-SYSTEMDDIR=$(DESTDIR)/usr/lib/systemd/system
-UPDATE_MOTDDIR=$(DESTDIR)/etc/update-motd.d
+BINDIR?=/usr/bin
+LIBEXECDIR?=/usr/libexec/mythtv-status
+MANDIR?=/usr/man
+MOLLY_GUARDDIR?=/etc/molly-guard/run.d
+SBINDIR?=/usr/sbin
+SYSTEMDDIR?=/usr/lib/systemd/system
+VARLIBDIR?=/var/lib/mythtv-status
+UPDATE_MOTDDIR?=/etc/update-motd.d
+
+FILES_TO_SUBSTITUTE=$(wildcard */*.in)
+SUBSTITUTED_FILES=$(shell echo $(FILES_TO_SUBSTITUTE) | sed 's/\.in//g')
package=mythtv-status
releases=sid
../$(package)_$(deb_version).debian.tar.?z \
../build/$(release)
+$(SUBSTITUTED_FILES): $(FILES_TO_SUBSTITUTE)
+ sed -e 's,@@BINDIR@@,$(BINDIR),g;s,@@VARLIBDIR@@,$(VARLIBDIR),g;s,@@LIBEXECDIR@@,$(LIBEXECDIR),g;s,@@SBINDIR@@,$(SBINDIR),g' $@.in > $@
+
publish: $(RELEASE_FILES)
for release in $(releases); do reprepro includedsc $$release ../build/$$release/$(package)_$(deb_version).dsc; done
for release in $(releases); do reprepro includedeb $$release ../build/$$release/$(package)_$(deb_version)_all.deb; done
upload: $(RELEASE_FILES)
for release in $(releases); do cd ../build/$$release; dput $(package)_$(deb_version)*.changes; done
-install:
- install -d $(BINDIR)
- install -d $(SBINDIR)
- install -d $(LIBEXECDIR)
- install -d $(MANDIR)/man1
- install -d $(MANDIR)/man8
- install -d $(SYSTEMDDIR)
- install -m 775 bin/mythtv-status $(BINDIR)
- install -m 775 bin/mythtv_recording_now $(BINDIR)
- install -m 775 bin/mythtv_recording_soon $(BINDIR)
- install -m 775 bin/mythtv-update-motd $(SBINDIR)
- install -m 775 bin/health-check $(LIBEXECDIR)
- pod2man bin/mythtv-status > $(MANDIR)/man1/mythtv-status.1
- install -m 644 man/mythtv-update-motd.8 $(MANDIR)/man8
- install -m 644 man/mythtv_recording_now.1 $(MANDIR)/man1
- install -m 644 man/mythtv_recording_soon.1 $(MANDIR)/man1
- install -m 644 systemd/* $(SYSTEMDDIR)
+build: $(SUBSTITUTED_FILES)
+ @touch build.stamp
+
+install: $(SUBSTITUTED_FILES)
+ install -d $(DESTDIR)$(BINDIR)
+ install -d $(DESTDIR)$(SBINDIR)
+ install -d $(DESTDIR)$(LIBEXECDIR)
+ install -d $(DESTDIR)$(MANDIR)/man1
+ install -d $(DESTDIR)$(MANDIR)/man8
+ install -d $(DESTDIR)$(SYSTEMDDIR)
+ install -m 775 bin/mythtv-status $(DESTDIR)$(BINDIR)
+ install -m 775 bin/mythtv_recording_now $(DESTDIR)$(BINDIR)
+ install -m 775 bin/mythtv_recording_soon $(DESTDIR)$(BINDIR)
+ install -m 775 bin/mythtv-update-motd $(DESTDIR)$(SBINDIR)
+ install -m 775 bin/health-check $(DESTDIR)$(LIBEXECDIR)
+ pod2man bin/mythtv-status > $(DESTDIR)$(MANDIR)/man1/mythtv-status.1
+ install -m 644 man/mythtv-update-motd.8 $(DESTDIR)$(MANDIR)/man8
+ install -m 644 man/mythtv_recording_now.1 $(DESTDIR)$(MANDIR)/man1
+ install -m 644 man/mythtv_recording_soon.1 $(DESTDIR)$(MANDIR)/man1
+ install -m 644 systemd/*.service $(DESTDIR)$(SYSTEMDDIR)
+ install -m 644 systemd/*.timer $(DESTDIR)$(SYSTEMDDIR)
# Only install these files if the directories already exist.
- [ -d $(MOLLY_GUARDDIR) ] && \
- install -m 775 molly-guard/* $(MOLLY_GUARDDIR)
- [ -d $(UPDATE_MOTDDIR) ] && \
- install -m 775 update-motd.d/* $(UPDATE_MOTDDIR)
+ if [ -d $(DESTDIR)$(MOLLY_GUARDDIR) ]; then \
+ install -m 775 molly-guard/40-mythtv-recording-soon $(DESTDIR)$(MOLLY_GUARDDIR); \
+ fi
+ if [ -d $(DESTDIR)$(UPDATE_MOTDDIR) ]; then \
+ install -m 775 update-motd.d/* $(DESTDIR)$(UPDATE_MOTDDIR); \
+ fi
test:
PERL_DL_NONLAZY=1 perl "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES)
clean:
- @rm -rf build
+ @rm -rf build.stamp $(SUBSTITUTED_FILES)
clean_pkg:
@rm -f ../$(package)*.changes ../$(package)*.dsc ../$(package)*.tar.gz ../$(package)*.deb
-.PHONY: release clean install test dist
+.PHONY: release clean install test dist build