summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: f59930cace4f30be688270c82c8fb6770ce9ffd5 (plain)
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
CFLAGS=-Wall -Wextra
LDFLAGS=-lpam -lutempter -ldl

SBINDIR=/sbin
MANDIR=/usr/share/man

all: autologin

clean:
	$(RM) autologin

install: $(DESTDIR)$(SBINDIR)/autologin $(DESTDIR)$(MANDIR)/man8/autologin.8.gz

$(DESTDIR)$(SBINDIR) $(DESTDIR)$(MANDIR):
	mkdir -p $@

$(DESTDIR)$(SBINDIR)/autologin: $(DESTDIR)$(SBINDIR) autologin
	install -m 711 $^ $@

$(DESTDIR)$(MANDIR)/man8/autologin.8.gz: $(DESTDIR)$(MANDIR) autologin.8
	cat autologin.8 | gzip > $(DESTDIR)$(MANDIR)/man8/autologin.8.gz

GITTAG=autologin-$(shell rpm -q --specfile autologin.spec --qf '%{version}-%{release}\n' | head -n1)
distdir=$(shell rpm -q --specfile --qf '%{name}-%{version}-%{release}\n' autologin.spec | head -n1)
ORIGIN=$(shell git config --get remote.origin.url)

tag:
	git tag $(GITTAG)

force-tag:
	git tag -f $(GITTAG)

ARCHIVEOUTDIR=$(pwd)

local-archive:
	$(MAKE) archive ORIGIN=$(ARCHIVEOUTDIR)

archive:
	repo=`pwd`; \
	tmpdir=`mktemp -d /tmp/make_archive_XXXXXX`; \
	if test -d "$$tmpdir" ; then \
		git clone $(ORIGIN) $$tmpdir/autologin;\
		cd $$tmpdir/autologin;\
		git checkout $(GITTAG) $(distdir);\
		tar --exclude=.git cvzf $(distdir).tar.gz $(distdir); \
		mkdir -p $$tmpdir/rpm-build-top;\
		rpmbuild \
			--define "_topdir $$tmpdir/rpm-build-top" \
			--define "_sourcedir $$tmpdir/rpm-build-top" \
			--define "_specdir $$tmpdir/rpm-build-top" \
			--define "_builddir $$tmpdir/rpm-build-top" \
			--define "_srpmdir $$tmpdir/rpm-build-top" \
			--define "_rpmdir $$tmpdir/rpm-build-top" \
			--define "_rpmdir $$tmpdir/rpm-build-top" \
			-tb $(distdir).tar.gz;\
		cp -v $(distdir).tar.gz $(ARCHIVEOUTDIR)/;\
		rm -fr $$tmpdir;\
	fi