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