]> git.sur5r.net Git - i3/i3status/blob - Makefile
DragonFlyBSD support added
[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 ifeq ($(shell uname),OpenBSD)
37 CFLAGS+=-I/usr/local/include/
38 LDFLAGS+=-L/usr/local/lib/
39 LIBS+=-lossaudio
40 endif
41
42 # This probably applies for any pkgsrc based system
43 ifeq ($(shell uname),DragonFly)
44 CFLAGS+=-I/usr/pkg/include/
45 LDFLAGS+=-L/usr/pkg/lib/
46 endif
47
48
49 CFLAGS+=$(EXTRA_CFLAGS)
50
51 # Fallback for libyajl 1 which did not include yajl_version.h. We need
52 # YAJL_MAJOR from that file to decide which code path should be used.
53 CFLAGS += -idirafter yajl-fallback
54
55 OBJS:=$(wildcard src/*.c *.c)
56 OBJS:=$(OBJS:.c=.o)
57
58 src/%.o: src/%.c
59         @$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
60         @echo " CC $<"
61
62 %.o: %.c include/%.h
63         @$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
64         @echo " CC $<"
65
66 all: i3status manpage
67
68 i3status: ${OBJS}
69         @$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
70         @echo " LD $@"
71
72 clean:
73         rm -f *.o src/*.o
74
75 distclean: clean
76         rm -f i3status man/i3status.1
77
78 manpage:
79         $(MAKE) -C man
80
81 install:
82         install -m 755 -d $(DESTDIR)$(PREFIX)/bin
83         install -m 755 -d $(DESTDIR)$(SYSCONFDIR)
84         install -m 755 -d $(DESTDIR)$(PREFIX)/share/man/man1
85         install -m 755 i3status $(DESTDIR)$(PREFIX)/bin/i3status
86         # Allow network configuration for getting the link speed
87         (which setcap && setcap cap_net_admin=ep $(DESTDIR)$(PREFIX)/bin/i3status) || true
88         install -m 644 i3status.conf $(DESTDIR)$(SYSCONFDIR)/i3status.conf
89         install -m 644 man/i3status.1 $(DESTDIR)$(PREFIX)/share/man/man1
90
91 release:
92         [ -f i3status-${VERSION} ] || rm -rf i3status-${VERSION}
93         mkdir i3status-${VERSION}
94         find . -maxdepth 1 -type f \( -regex ".*\.\(c\|conf\|h\)" -or -name "Makefile" -or -name "LICENSE" -or -name "CHANGELOG" \) -exec cp '{}' i3status-${VERSION} \;
95         mkdir i3status-${VERSION}/src
96         mkdir i3status-${VERSION}/man
97         find src -maxdepth 1 -type f \( -regex ".*\.\(c\|h\)" \) -exec cp '{}' i3status-${VERSION}/src \;
98         find man -maxdepth 1 -type f \( -regex ".*\.\(1\|man\|conf\)" -or -name "Makefile" \) -exec cp '{}' i3status-${VERSION}/man \;
99         cp -r include i3status-${VERSION}
100         cp -r yajl-fallback i3status-${VERSION}
101         cp -r contrib i3status-${VERSION}
102         sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION:=\(.*\)/VERSION=${VERSION}/g' Makefile > i3status-${VERSION}/Makefile
103         tar cjf i3status-${VERSION}.tar.bz2 i3status-${VERSION}
104         rm -rf i3status-${VERSION}