aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: beb62215b05808747edd03ec4b0dad5e41b214f2 (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
# Makefile for hcalc. Requires GNU make.

# Users and packagers, feel free to override these:
CC = gcc
CFLAGS = -Wall -g
LIBS =
DESTDIR =
PREFIX = /usr
BINDIR = $(PREFIX)/bin
SHAREDIR = $(PREFIX)/share
MANDIR = $(SHAREDIR)/man
MAN1DIR = $(MANDIR)/man1
DOCDIR = $(SHAREDIR)/doc/$(PROJ)
ICONDIR = $(SHAREDIR)/icons/hicolor
DESKTOPDIR = $(SHAREDIR)/applications
INSTALL = install
INSTALL_DATA = $(INSTALL) -m0644
INSTALL_PROG = $(INSTALL) -s -m0755
ifeq ($(shell whoami),root)
INSTALL_USER = -o root -g root
else
INSTALL_USER =
endif
MKDIR_P = mkdir -p
GZIP = gzip
# End of user-ovverideable stuff. No user-serviceable parts below this line.

# Notes:
# - VERSION, version.rst, version.h, and the man page (hcalc.1) are
#   generated files, but they're also checked into git. This is to
#   prevent a build-time dependency on rst2man.
# - clean does not delete any files that are in git.
# - realclean is a maintainer-only target, deletes generated files that are
#   in git.

PROJ = hcalc
VERSION = 1.2u1
MANPAGE = $(PROJ).1
DOCS = README CHANGES TODO COPYING
OBJS = \
	hcalc.o \
	input.o \
	setupx.o \
	images.o \
	draw.o \
	config.o

all: $(PROJ) $(MANPAGE)

hcalc.o: hcalc.c hcalc.h version.h

input.o: input.c hcalc.h version.h

setupx.o: setupx.c hcalc.h version.h

draw.o: draw.c hcalc.h version.h

config.o: config.c hcalc.h version.h

images.o: images.c hcalc.h xpm/*.xpm version.h

VERSION:
ifneq ($(shell cat VERSION 2>/dev/null),$(VERSION))
	echo "$(VERSION)" > VERSION
endif

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

version.h: VERSION
	echo '#define VERSION "$(VERSION)"' > version.h

$(PROJ): $(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS) -lXpm -lX11 $(LIBS)

$(MANPAGE): $(PROJ).rst version.rst
	rst2man $(PROJ).rst > $(MANPAGE)

clean:
	rm -f *.o *.d *~ \#* $(PROJ) core

realclean: clean
	rm -f VERSION version.h version.rst $(MANPAGE)

install: all
	$(MKDIR_P) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SHAREDIR) \
		$(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(DESKTOPDIR)
	$(INSTALL_PROG) $(INSTALL_USER) $(PROJ) $(DESTDIR)$(BINDIR)
	$(INSTALL_DATA) $(INSTALL_USER) $(MANPAGE) $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) $(INSTALL_USER) $(DOCS) $(DESTDIR)$(DOCDIR)
	$(INSTALL_DATA) $(INSTALL_USER) desktop/$(PROJ).desktop $(DESTDIR)$(DESKTOPDIR)
	for i in 16x16 22x22 32x32 48x48 64x64; do \
		$(MKDIR_P) $(DESTDIR)$(ICONDIR)/$$i/apps ; \
		$(INSTALL_DATA) $(INSTALL_USER) icons/$$i/apps/$(PROJ).png $(DESTDIR)$(ICONDIR)/$$i/apps ; \
	done
	$(GZIP) -9f $(DESTDIR)$(MAN1DIR)/$(MANPAGE)

.PHONY: all clean realclean install