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