aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: c4141469f4267bbe9c99bdb1e37de1eddff28c14 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

PKGNAME = cg-tools

XOUT =\
	cg-brilliance\
	cg-darkroom\
	cg-gamma\
	cg-icc\
	cg-limits\
	cg-linear\
	cg-negative\
	cg-rainbow\
	cg-sleepmode\
	cg-shallow

XBIN =\
	cg-query\
	cg-remove

HDR =\
	arg.h\
	cg-base.h

BIN = $(XBIN) $(XOUT)
OUT = $(XOUT:=.out)
OBJ = $(BIN:=.o) cg-base.o
MAN1 = $(BIN:=.1)
MAN7 = cg-tools.7

all: $(XBIN) $(OUT)
$(OBJ): $(HDR)
$(OUT): cg-base.o

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

.o.out:
	$(CC) -o $@ $< cg-base.o $(LDFLAGS)

cg-query: cg-query.o
	$(CC) -o $@ $@.o $(LDFLAGS)

cg-remove: cg-remove.o
	$(CC) -o $@ $@.o $(LDFLAGS)

install: $(XBIN) $(OUT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
	cp -- $(XBIN) "$(DESTDIR)$(PREFIX)/bin"
	for x in $(XOUT); do cp -- "$$x.out" "$(DESTDIR)$(PREFIX)/bin/$$x" || exit 1; done
	cp -- $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
	cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"

uninstall:
	-cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f -- $(XBIN) $(XOUT)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f -- $(MAN1)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man7" && rm -f -- $(MAN7)

clean:
	-rm -f -- $(BIN) *.o *.su *.out

.SUFFIXES:
.SUFFIXES: .c .o .out

.PHONY: all install uninstall clean