aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 6947d0da86c77ef011fecb0a932f54bd5005fef5 (plain) (blame)
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
PREFIX = /usr
BINDIR = $(PREFIX)/bin
DATADIR = $(PREFIX)/share
MANDIR = $(DATADIR)/man
MAN1DIR = $(MANDIR)/man1
LICENSEDIR = $(DATADIR)/licenses

PKGNAME = xtest
COMMAND = xtest

CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE
CFLAGS   = -std=c99 -Wall -pedantic

all: xtest

xtest: xtest.o

.o:
	$(CC) $(LDFLAGS) -o $@ $<

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<

install: install-base install-doc

install-base: install-cmd install-copyright

install-cmd: xtest
	mkdir -p -- "$(DESTDIR)$(BINDIR)"
	cp -f -- xtest "$(DESTDIR)$(BINDIR)/$(COMMAND)"
	chmod 755 -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"

install-copyright: install-license

install-license:
	mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
	cp -f -- LICENSE "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
	chmod 644 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"

install-doc: install-man

install-man: install-man1

install-man1:
	mkdir -p -- "$(DESTDIR)$(MAN1DIR)"
	cp -f -- xtest.1 "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1"
	chmod 644 -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1"

uninstall:
	rm -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1"
	rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
	rm -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
	rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"

.PHONY: all install install-base install-cmd install-copyright install-license \
        install-doc install-man install-man1 uninstall