]> git.sur5r.net Git - i3/i3status/blob - Makefile
da42640ea70c27c54158ffa885ba4a468c46e2ad
[i3/i3status] / Makefile
1 ifndef PREFIX
2   PREFIX=/usr
3 endif
4 ifndef SYSCONFDIR
5   ifeq ($(PREFIX),/usr)
6     SYSCONFDIR=/etc
7   else
8     SYSCONFDIR=$(PREFIX)/etc
9   endif
10 endif
11
12 CFLAGS+=-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
13 CFLAGS+=-g
14 CFLAGS+=-std=gnu99
15 CFLAGS+=-pedantic
16 CPPFLAGS+=-DSYSCONFDIR=\"$(SYSCONFDIR)\"
17 CPPFLAGS+=-DVERSION=\"${GIT_VERSION}\"
18 CFLAGS+=-Iinclude
19 LIBS+=-lconfuse
20 LIBS+=-lyajl
21
22 VERSION:=$(shell git describe --tags --abbrev=0)
23 GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
24
25 ifeq ($(shell uname),Linux)
26 CPPFLAGS+=-DLINUX
27 CPPFLAGS+=-D_GNU_SOURCE
28 LIBS+=-liw
29 LIBS+=-lasound
30 endif
31
32 ifeq ($(shell uname),GNU/kFreeBSD)
33 LIBS+=-lbsd
34 endif
35
36 CFLAGS+=$(EXTRA_CFLAGS)
37
38 OBJS:=$(wildcard src/*.c *.c)
39 OBJS:=$(OBJS:.c=.o)
40
41 src/%.o: src/%.c
42         @$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
43         @echo " CC $<"
44
45 %.o: %.c include/%.h
46         @$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
47         @echo " CC $<"
48
49 all: i3status manpage
50
51 i3status: ${OBJS}
52         @$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
53         @echo " LD $@"
54
55 clean:
56         rm -f *.o src/*.o
57
58 distclean: clean
59         rm -f i3status
60
61 manpage:
62         $(MAKE) -C man
63
64 install:
65         install -m 755 -d $(DESTDIR)$(PREFIX)/bin
66         install -m 755 -d $(DESTDIR)$(SYSCONFDIR)
67         install -m 755 -d $(DESTDIR)$(PREFIX)/share/man/man1
68         install -m 755 i3status $(DESTDIR)$(PREFIX)/bin/i3status
69         # Allow network configuration for getting the link speed
70         (which setcap && setcap cap_net_admin=ep $(DESTDIR)$(PREFIX)/bin/i3status) || true
71         install -m 644 i3status.conf $(DESTDIR)$(SYSCONFDIR)/i3status.conf
72         install -m 644 man/i3status.1 $(DESTDIR)$(PREFIX)/share/man/man1
73
74 release:
75         [ -f i3status-${VERSION} ] || rm -rf i3status-${VERSION}
76         mkdir i3status-${VERSION}
77         find . -maxdepth 1 -type f \( -regex ".*\.\(c\|conf\|h\)" -or -name "Makefile" -or -name "LICENSE" \) -exec cp '{}' i3status-${VERSION} \;
78         mkdir i3status-${VERSION}/src
79         mkdir i3status-${VERSION}/man
80         find src -maxdepth 1 -type f \( -regex ".*\.\(c\|h\)" \) -exec cp '{}' i3status-${VERSION}/src \;
81         find man -maxdepth 1 -type f \( -regex ".*\.\(1\|man\|conf\)" -or -name "Makefile" \) -exec cp '{}' i3status-${VERSION}/man \;
82         cp -r include i3status-${VERSION}
83         sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION:=\(.*\)/VERSION=${VERSION}/g' Makefile > i3status-${VERSION}/Makefile
84         tar cjf i3status-${VERSION}.tar.bz2 i3status-${VERSION}
85         rm -rf i3status-${VERSION}