forked from vivien/i3blocks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
93 lines (75 loc) · 2.18 KB
/
Makefile
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
RELEASE_VERSION = 1.5
ifndef PREFIX
PREFIX=/usr/local
endif
ifndef SYSCONFDIR
ifeq ($(PREFIX),/usr)
SYSCONFDIR=/etc
else
SYSCONFDIR=$(PREFIX)/etc
endif
endif
ifndef DATAROOTDIR
DATAROOTDIR=$(PREFIX)/share
endif
ifndef LIBEXECDIR
LIBEXECDIR=$(PREFIX)/libexec
endif
ifndef VERSION
VERSION = $(shell git describe --tags --always 2> /dev/null)
ifeq ($(strip $(VERSION)),)
VERSION = $(RELEASE_VERSION)
endif
endif
PROGRAM = i3blocks
UNAME_S:= $(shell uname -s)
CPPFLAGS += -DSYSCONFDIR=\"$(SYSCONFDIR)\"
CPPFLAGS += -DVERSION=\"${VERSION}\"
CFLAGS += -std=gnu99 -Iinclude -Wall -Werror=format-security
ifeq ($(UNAME_S),Linux)
OS:=Linux
else
OS:=BSD
endif
OBJS := $(sort $(wildcard src/*.c)) $(sort $(wildcard src/platform/${OS}/*.c))
OBJS := $(OBJS:.c=.o)
%.o: %.c %.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
@echo " CC $<"
all: $(PROGRAM)
debug: CPPFLAGS += -DDEBUG
debug: CFLAGS += -ggdb
debug: $(PROGRAM)
$(PROGRAM): ${OBJS}
$(CC) $(LDFLAGS) -o $@ $^
@echo " LD $@"
man: $(PROGRAM).1
$(PROGRAM).1: $(PROGRAM).1.md
pandoc --to man --standalone --output $@ $<
clean:
rm -f src/platform/{BSD,Linux}/*.o
rm -f src/*.o $(PROGRAM)
install: all
install -m 755 -d $(DESTDIR)$(PREFIX)/bin
install -m 755 -d $(DESTDIR)$(SYSCONFDIR)
install -m 755 -d $(DESTDIR)$(LIBEXECDIR)/$(PROGRAM)
install -m 755 $(PROGRAM) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
sed 's,$$SCRIPT_DIR,$(LIBEXECDIR)/$(PROGRAM),' $(PROGRAM).conf > $(DESTDIR)$(SYSCONFDIR)/$(PROGRAM).conf
chmod 644 $(DESTDIR)$(SYSCONFDIR)/$(PROGRAM).conf
install -m 755 scripts/$(OS)/* $(DESTDIR)$(LIBEXECDIR)/$(PROGRAM)/
install-man: man
install -m 755 -d $(DESTDIR)$(DATAROOTDIR)/man/man1
install -m 644 $(PROGRAM).1 $(DESTDIR)$(DATAROOTDIR)/man/man1
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
rm -f $(DESTDIR)$(SYSCONFDIR)/$(PROGRAM).conf
rm -rf $(DESTDIR)$(LIBEXECDIR)/$(PROGRAM)
uninstall-man:
rm -f $(DESTDIR)$(DATAROOTDIR)/man/man1/$(PROGRAM).1
dist: clean man
( git ls-files * ; ls $(PROGRAM).1 ) | \
tar -czT - --transform 's,^,$(PROGRAM)-$(VERSION)/,' \
-f $(PROGRAM)-$(VERSION).tar.gz
distclean: clean
rm -f $(PROGRAM).1 $(PROGRAM)-*.tar.gz
.PHONY: all clean install uninstall install-man uninstall-man