aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: f7d2c72cbdeb65973e85b57c361225a8772dcb71 (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
# Makefile for uxd, by B. Watson. WTFPL.
# Requires GNU make aka gmake. BSD make won't work, sorry.

### Override these variables as needed. Don't override CFLAGS; use
#   MYCFLAGS instead.
MYCFLAGS=-O2 -fPIC

#   These only affect the 'install' target (they don't get compiled
#   into the binary).
PREFIX=/usr
MANDIR=$(PREFIX)/man
MAN1DIR=$(MANDIR)/man1
BINDIR=$(PREFIX)/bin
DESTDIR=
INSTALL_DATA=install -m0644
INSTALL_PROGRAM=install -s -m0755
GZIP=gzip -9
GZIP_MAN=yes

#
### No user-serviceable parts below.

VERSION=0.1.0

DEFINES=-DVERSION='"$(VERSION)"'
WARNFLAGS=-std=c89 -Wall -pedantic -Wextra
CFLAGS=$(DEFINES) $(WARNFLAGS) $(MYCFLAGS)

.PHONY: all test man clean install g++ clang++ clang

all: uxd man

uxd: uxd.c getopt.c usage.c

usage.c: uxd.rst mkusage.pl
	perl mkusage.pl uxd.rst > usage.c

install: all
	mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) uxd.1 $(DESTDIR)$(MAN1DIR)
ifeq ($(GZIP_MAN),yes)
	$(GZIP) $(DESTDIR)$(MAN1DIR)/uxd.1
endif
	$(INSTALL_PROGRAM) uxd $(DESTDIR)$(BINDIR)

test: uxd
	./uxd

man: uxd.1

uxd.1: uxd.rst ver.rst
	rst2man uxd.rst > uxd.1

ver.rst:
	echo '.. |version| replace:: $(VERSION)' > ver.rst

clean:
	rm -f uxd

# the rest of the targets are for portability testing.

tcc: clean
	$(MAKE) CC=tcc

pcc: clean
	$(MAKE) CC=pcc

clang: clean
	$(MAKE) CC=clang

g++: clean
	$(MAKE) CC=g++ WARNFLAGS="-Wall -Wno-write-strings -xc++"

clang++: clean
	$(MAKE) CC=clang++ WARNFLAGS="-Wall -Wno-write-strings -xc++"