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