summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 6ff3e1852760b7e60c5a6c35c128cac92a888986 (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
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

HDR =\
        common.h\
	large.h

BIN_ =\
	backlight\
	clock\
	counter\
	dice\
	stopwatch

OBJ =\
	common.o\
	$(BIN_:=.o)

BIN = $(BIN_:=.bin)
MAN1 = $(BIN_:=.1)


all: $(BIN)
$(OBJ): $(@:.o=.c) $(HDR)
$(BIN): $(@:.bin=.o) common.o

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

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

large.h: large.sh
	./large.sh > $@

install: $(BIN)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
	for f in $(BIN_); do\
		! test -d "$(DESTDIR)$(PREFIX)/bin/$$f" &&\
		cp -- "$$f.bin" "$(DESTDIR)$(PREFIX)/bin/$$f" || exit 1;\
	done
	cp -- $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"

post-install:
	chown -- '0:$(VIDEO_GROUP)' "$(DESTDIR)$(PREFIX)/bin/backlight"
	chmod -- 4754 "$(DESTDIR)$(PREFIX)/bin/backlight"

uninstall:
	-cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f -- $(BIN_)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f $(MAN1)

clean:
	-rm -rf -- *.o *.su *.bin large.h

.SUFFIXES:
.SUFFIXES: .bin .o .c

.PHONY: all install post-install uninstall clean