-
Notifications
You must be signed in to change notification settings - Fork 2
/
GNUmakefile
43 lines (35 loc) · 1.29 KB
/
GNUmakefile
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
BINFILES = bin/insomnia
DATFILES = data/inputrc
LIBFILES = lib/insomnia-color lib/insomnia-input lib/insomnia-monitor \
lib/insomnia-monitor-bell lib/insomnia-output lib/insomnia-sort \
lib/insomnia-strftime lib/insomnia-strip-bell lib/insomnia-tail \
lib/insomnia-topic lib/insomnia-track-topic lib/insomnia-unix
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/libexec/insomnia
BINDIR ?= $(PREFIX)/bin
DOCDIR ?= $(PREFIX)/share/doc/insomnia
DATADIR ?= $(PREFIX)/share/insomnia
CFLAGS ?= -Werror -Os
CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L
CFLAGS += -Wpedantic -Wall -Wextra
ifeq ($(shell uname -s), OpenBSD)
# Needed for pledge(2) prototype in unistd.h.
CFLAGS += -D_BSD_SOURCE
endif
all: $(BINFILES) $(DATFILES) $(LIBFILES)
bin/%: bin/%.in
sed -e 's|@LIBDIR@|$(LIBDIR)|' \
-e 's|@DATADIR@|$(DATADIR)|' < $< > $@
chmod +x $@
lib/insomnia-tail: LDFLAGS += -pthread
lib/insomnia-%: lib/insomnia-%.c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
install: all
install -dm755 "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(LIBDIR)" "$(DESTDIR)$(DATADIR)"
install -Dm755 $(BINFILES) "$(DESTDIR)$(BINDIR)"
install -Dm755 $(LIBFILES) "$(DESTDIR)$(LIBDIR)"
install -Dm644 $(DATFILES) "$(DESTDIR)$(DATADIR)"
install -Dm644 README.md "$(DESTDIR)$(DOCDIR)/README.md"
clean:
@git clean -fdX
.PHONY: all install clean