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