aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: f1e51db45aedf7b6fc26810390583c64113b35a6 (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
# GNU Makefile for xdeadzone(1). May also work with BSD make, since I
# don't use any GNU-specific features.

# Optimization flags for $(CC)
OPTFLAGS=-O2 -fPIC

# Add any extra libraries you need here.
LIBS=

# Install locations (these don't affect the binary).
PREFIX = /usr
BINDIR = $(PREFIX)/bin
SHAREDIR = $(PREFIX)/share
MANDIR = $(SHAREDIR)/man
MAN1DIR = $(MANDIR)/man1
DOCDIR = $(SHAREDIR)/doc/$(PROJ)
INSTALL = install
INSTALL_DATA = $(INSTALL) -m0644
INSTALL_PROG = $(INSTALL) -s -m0755
MKDIR_P = mkdir -p
GZIP = gzip

# Shouldn't need to override these.
PROJ=xdeadzone
VERSION=0.1
CFLAGS=-Wall -DVERSION="\"$(VERSION)"\" $(OPTFLAGS)
LDFLAGS=-lX11 $(LIBS)

all: $(PROJ) $(PROJ).1

$(PROJ): $(PROJ).c

$(PROJ).1: $(PROJ).rst
	echo ".. |version| replace:: $(VERSION)" > version.rst
	rst2man $(PROJ).rst > $(PROJ).1

clean:
	rm -f $(PROJ) *.o core

realclean: clean
	rm -f $(PROJ).1 version.rst

install: all
	$(MKDIR_P) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SHAREDIR) \
		$(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR)
	$(INSTALL_PROG) $(PROJ) $(DESTDIR)$(BINDIR)
	$(INSTALL_DATA) $(PROJ).1 $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)
	$(GZIP) -9f $(DESTDIR)$(MAN1DIR)/$(PROJ).1

.PHONY: all clean realclean install