blob: c09c52b574c1f2c21b0cdee424664f598338f5b4 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# GNU Makefile for unsaver
####
# Packagers: override these on the make command line as needed.
# maximum number of devices we can monitor. 16 seems like an awful lot...
MAX_STICKS=16
# base name of joystick devices on your OS, gets numbers 0 to MAX_STICKS
# appended to it during autodetection. This is the base filename without
# the directory. If your first joystick is /dev/input/js0, say js here.
JSNODE=js
# directory where joystick devices live. monitored via inotify(7) to
# detect hotplug events.
EVENTDIR=/dev/input
# Intended for optimizations, but you could include other flags here.
# Override this, not CFLAGS
OPTFLAGS=-Wall -ansi -pedantic -std=c89 -g
# -L, -l, and maybe -Wl flags here.
LDEXTRA=
# Where 'make install' puts things.
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
MAN1DIR=$(MANDIR)/man1
DOCDIR=$(PREFIX)/share/doc/$(PROJ)
DESTDIR=
# Booleans: 'y' or 'n' for these.
STRIPBIN=y
GZIPMAN=y
# Normally these will end up as root and root (or possibly wheel). You
# could also set 'CHOWN=/bin/true' to skip it.
OWNER=$(shell id -nu 0)
GROUP=$(shell id -ng 0)
# These are only used if you're rebuilding the man and/or html pages,
# e.g. because you've patched them.
RST2MAN=rst2man.py
RST2HTML=rst2html4.py
#
###
# Hopefully, no user-serviceable parts below this line.
PROJ=unsaver
# the .rst is the authoritative source for the version number.
VERSION=$(shell fgrep '.. |version| replace::' $(PROJ).rst | cut -d' ' -f4)
DEFINES=-DVERSION=\"$(VERSION)\" -DMAX_STICKS=$(MAX_STICKS) -DJSNODE=\"$(JSNODE)\" -DEVENTDIR=\"$(EVENTDIR)\" -DPROJ=\"$(PROJ)\"
CFLAGS+=$(shell pkg-config --cflags x11 xtst)
LDFLAGS+=$(shell pkg-config --libs x11 xtst)
CFLAGS=$(OPTFLAGS) $(DEFINES)
LDFLAGS+=$(LDEXTRA)
all: $(PROJ)
man: $(PROJ).1
html: $(PROJ).html
clean:
rm -f $(PROJ) core
%.1: %.rst
$(RST2MAN) $< > $@ || rm -f $@
%.html: %.rst
$(RST2HTML) $< > $@ || rm -f $@
ifeq ($(shell whoami),root)
CHOWN=chown
else
CHOWN=: chown
endif
install: all man html
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR)
cp $(PROJ) $(DESTDIR)$(BINDIR)
$(CHOWN) $(OWNER):$(GROUP) $(DESTDIR)$(BINDIR)/$(PROJ)
chmod 755 $(DESTDIR)$(BINDIR)/$(PROJ)
ifeq ($(STRIPBIN),y)
strip $(DESTDIR)$(BINDIR)/$(PROJ)
endif
cp $(PROJ).1 $(DESTDIR)$(MAN1DIR)
$(CHOWN) root:root $(DESTDIR)$(MAN1DIR)/$(PROJ).1
chmod 644 $(DESTDIR)$(MAN1DIR)/$(PROJ).1
ifeq ($(GZIPMAN),y)
gzip -9 $(DESTDIR)$(MAN1DIR)/$(PROJ).1
endif
cp README $(DESTDIR)$(DOCDIR)
chmod 644 $(DESTDIR)$(DOCDIR)/README
$(CHOWN) $(OWNER):$(GROUP) $(DESTDIR)$(DOCDIR)/README
push: all man html
git add $(PROJ).1 $(PROJ).html
git commit -m'auto-regenerate man/html pages' || true
git push
# don't forget to: git config tar.tar.xz.command "xz -c"
release:
git tag -a -m'$(VERSION) release' $(VERSION)
git archive --prefix=$(PROJ)-$(VERSION)/ -o $(PROJ)-$(VERSION).tar.xz $(VERSION)
.PHONY: all man clean html install push
|