]> git.sur5r.net Git - i3/i3/blob - Makefile
Remove MAKE=make from makefile to ensure recursive invocations work (i.e. clean target)
[i3/i3] / Makefile
1 UNAME=$(shell uname)
2 DEBUG=1
3 INSTALL=install
4 GIT_VERSION=$(shell git describe --tags --always)
5 VERSION=$(shell git describe --tags --abbrev=0)
6
7 CFLAGS += -std=c99
8 CFLAGS += -pipe
9 CFLAGS += -Wall
10 CFLAGS += -Wunused
11 CFLAGS += -Iinclude
12 CFLAGS += -I/usr/local/include
13 CFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
14
15 # Check if pkg-config is installed, because without pkg-config, the following
16 # check for the version of libxcb cannot be done.
17 ifeq ($(shell which pkg-config 2>/dev/null 1>/dev/null || echo 1),1)
18 $(error "pkg-config was not found")
19 endif
20
21 ifeq ($(shell pkg-config --exists xcb-keysyms || echo 1),1)
22 $(error "pkg-config could not find xcb-keysyms.pc")
23 endif
24
25 ifeq ($(shell pkg-config --exact-version=0.3.3 xcb-keysyms && echo 1),1)
26 # xcb-keysyms fixed API from 0.3.3 to 0.3.4, so for some months, we will
27 # have this here. Distributions should upgrade their libxcb in the meantime.
28 CFLAGS += -DOLD_XCB_KEYSYMS_API
29 endif
30
31 LDFLAGS += -lm
32 LDFLAGS += -lxcb-event
33 LDFLAGS += -lxcb-property
34 LDFLAGS += -lxcb-keysyms
35 LDFLAGS += -lxcb-atom
36 LDFLAGS += -lxcb-aux
37 LDFLAGS += -lxcb-icccm
38 LDFLAGS += -lxcb-xinerama
39 LDFLAGS += -lX11
40 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
41
42 ifeq ($(UNAME),NetBSD)
43 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
44 CFLAGS += -idirafter /usr/pkg/include
45 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
46 endif
47
48 ifeq ($(UNAME),FreeBSD)
49 LDFLAGS += -liconv
50 endif
51
52 ifeq ($(UNAME),Linux)
53 CFLAGS += -D_GNU_SOURCE
54 endif
55
56 ifeq ($(DEBUG),1)
57 # Extended debugging flags, macros shall be available in gcc
58 CFLAGS += -gdwarf-2
59 CFLAGS += -g3
60 else
61 CFLAGS += -O2
62 endif
63
64 # Don’t print command lines which are run
65 .SILENT:
66
67 # Always remake the following targets
68 .PHONY: install clean dist distclean
69
70 # Depend on the object files of all source-files in src/*.c and on all header files
71 FILES=$(patsubst %.c,%.o,$(wildcard src/*.c))
72 HEADERS=$(wildcard include/*.h)
73
74 # Depend on the specific file (.c for each .o) and on all headers
75 src/%.o: src/%.c ${HEADERS}
76         echo "CC $<"
77         $(CC) $(CFLAGS) -c -o $@ $<
78
79 all: ${FILES}
80         echo "LINK i3"
81         $(CC) -o i3 ${FILES} $(LDFLAGS)
82
83 install: all
84         echo "INSTALL"
85         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/bin
86         $(INSTALL) -d -m 0755 $(DESTDIR)/etc/i3
87         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/share/xsessions
88         $(INSTALL) -m 0755 i3 $(DESTDIR)/usr/bin/
89         test -e $(DESTDIR)/etc/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)/etc/i3/config
90         $(INSTALL) -m 0644 i3.desktop $(DESTDIR)/usr/share/xsessions/
91
92 dist: clean
93         [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
94         [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
95         mkdir i3-${VERSION}
96         cp DEPENDS GOALS LICENSE PACKAGE-MAINTAINER TODO RELEASE-* i3.config i3.desktop pseudo-doc.doxygen i3-${VERSION}
97         cp -r src include man i3-${VERSION}
98         # Only copy toplevel documentation (important stuff)
99         mkdir i3-${VERSION}/docs
100         find docs -maxdepth 1 -type f ! -name "*.xcf" -exec cp '{}' i3-${VERSION}/docs \;
101         sed -e 's/^GIT_VERSION=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION=\(.*\)/VERSION=${VERSION}/g' Makefile > i3-${VERSION}/Makefile
102         tar cf i3-${VERSION}.tar i3-${VERSION}
103         bzip2 -9 i3-${VERSION}.tar
104         rm -rf i3-${VERSION}
105
106 clean:
107         rm -f src/*.o
108         $(MAKE) -C docs clean
109         $(MAKE) -C man clean
110
111 distclean: clean
112         rm -f i3