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

PROJ = hcalc

CC = gcc
CFLAGS = -Wall -g

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

MANPAGE = $(PROJ).1
OBJS = \
	hcalc.o \
	input.o \
	setupx.o \
	images.o \
	draw.o \
	config.o

all: $(PROJ) $(MANPAGE)

hcalc.o: hcalc.c hcalc.h

input.o: input.c hcalc.h

setupx.o: setupx.c hcalc.h

draw.o: draw.c hcalc.h

config.o: config.c hcalc.h

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

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

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

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

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) README CHANGES TODO $(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 install