]> git.sur5r.net Git - i3/i3status/blob - Makefile
Pass the "instance" JSON property key for tztime blocks
[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 OS:=$(shell uname)
25
26 ifeq ($(OS),Linux)
27 CPPFLAGS+=-DLINUX
28 CPPFLAGS+=-D_GNU_SOURCE
29 LIBS+=-liw
30 LIBS+=-lasound
31 endif
32
33 ifeq ($(OS),GNU/kFreeBSD)
34 LIBS+=-lbsd
35 endif
36
37 ifneq (, $(filter $(OS), DragonFly FreeBSD OpenBSD))
38 CFLAGS+=-I/usr/local/include/
39 LDFLAGS+=-L/usr/local/lib/
40 endif
41
42 ifeq ($(OS),OpenBSD)
43 LIBS+=-lossaudio
44 endif
45
46 ifeq ($(OS), NetBSD)
47 LIBS+= -lprop
48 endif
49
50 # This probably applies for any pkgsrc based system
51 ifneq (, $(filter $(OS), NetBSD DragonFly))
52 CFLAGS+=-I/usr/pkg/include/
53 LDFLAGS+=-L/usr/pkg/lib/
54 endif
55
56 V ?= 0
57 ifeq ($(V),0)
58 # Don’t print command lines which are run
59 .SILENT:
60 endif
61
62 CFLAGS+=$(EXTRA_CFLAGS)
63
64 # Fallback for libyajl 1 which did not include yajl_version.h. We need
65 # YAJL_MAJOR from that file to decide which code path should be used.
66 CFLAGS += -idirafter yajl-fallback
67
68 OBJS:=$(wildcard src/*.c *.c)
69 OBJS:=$(OBJS:.c=.o)
70
71 src/%.o: src/%.c include/i3status.h
72         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
73         @echo " CC $<"
74
75 %.o: %.c include/%.h
76         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
77         @echo " CC $<"
78
79 all: i3status manpage
80
81 i3status: ${OBJS}
82         $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
83         @echo " LD $@"
84
85 clean:
86         rm -f *.o src/*.o
87
88 distclean: clean
89         rm -f i3status man/i3status.1
90
91 manpage:
92         $(MAKE) -C man
93
94 install:
95         install -m 755 -d $(DESTDIR)$(PREFIX)/bin
96         install -m 755 -d $(DESTDIR)$(SYSCONFDIR)
97         install -m 755 -d $(DESTDIR)$(PREFIX)/share/man/man1
98         install -m 755 i3status $(DESTDIR)$(PREFIX)/bin/i3status
99         # Allow network configuration for getting the link speed
100         (which setcap && setcap cap_net_admin=ep $(DESTDIR)$(PREFIX)/bin/i3status) || true
101         install -m 644 i3status.conf $(DESTDIR)$(SYSCONFDIR)/i3status.conf
102         install -m 644 man/i3status.1 $(DESTDIR)$(PREFIX)/share/man/man1
103
104 release:
105         [ -f i3status-${VERSION} ] || rm -rf i3status-${VERSION}
106         mkdir i3status-${VERSION}
107         find . -maxdepth 1 -type f \( -regex ".*\.\(c\|conf\|h\)" -or -name "README" -or -name "Makefile" -or -name "LICENSE" -or -name "CHANGELOG" \) -exec cp '{}' i3status-${VERSION} \;
108         mkdir i3status-${VERSION}/src
109         mkdir i3status-${VERSION}/man
110         find src -maxdepth 1 -type f \( -regex ".*\.\(c\|h\)" \) -exec cp '{}' i3status-${VERSION}/src \;
111         find man -maxdepth 1 -type f \( -regex ".*\.\(1\|man\|conf\)" -or -name "Makefile" \) -exec cp '{}' i3status-${VERSION}/man \;
112         cp -r include i3status-${VERSION}
113         cp -r yajl-fallback i3status-${VERSION}
114         cp -r contrib i3status-${VERSION}
115         sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION:=\(.*\)/VERSION=${VERSION}/g' Makefile > i3status-${VERSION}/Makefile
116         tar cjf i3status-${VERSION}.tar.bz2 i3status-${VERSION}
117         rm -rf i3status-${VERSION}