]> git.sur5r.net Git - i3/i3/blob - Makefile
Cleanup makefiles, add version to i3 -v and i3 startup
[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 LDFLAGS += -lm
17 LDFLAGS += -lxcb-wm
18 #LDFLAGS += -lxcb-keysyms
19 LDFLAGS += -lxcb-xinerama
20 LDFLAGS += -lX11
21 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
22
23 ifeq ($(UNAME),NetBSD)
24 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
25 CFLAGS += -idirafter /usr/pkg/include
26 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
27 endif
28
29 ifeq ($(UNAME),Linux)
30 CFLAGS += -D_GNU_SOURCE
31 endif
32
33 ifeq ($(DEBUG),1)
34 # Extended debugging flags, macros shall be available in gcc
35 CFLAGS += -gdwarf-2
36 CFLAGS += -g3
37 else
38 CFLAGS += -O2
39 endif
40
41 # Don’t print command lines which are run
42 .SILENT:
43
44 # Always remake the following targets
45 .PHONY: install clean dist distclean
46
47 # Depend on the object files of all source-files in src/*.c and on all header files
48 FILES=$(patsubst %.c,%.o,$(wildcard src/*.c))
49 HEADERS=$(wildcard include/*.h)
50
51 # Depend on the specific file (.c for each .o) and on all headers
52 src/%.o: src/%.c ${HEADERS}
53         echo "CC $<"
54         $(CC) $(CFLAGS) -c -o $@ $<
55
56 all: ${FILES}
57         echo "LINK i3"
58         $(CC) -o i3 ${FILES} $(LDFLAGS)
59
60 install: all
61         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/bin
62         $(INSTALL) -d -m 0755 $(DESTDIR)/etc/i3
63         $(INSTALL) -m 0755 i3 $(DESTDIR)/usr/bin/
64         test -e $(DESTDIR)/etc/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)/etc/i3/config
65
66 dist: clean
67         [ ! -f i3-${VERSION} ] || rm -rf i3-${VERSION}
68         [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
69         mkdir i3-${VERSION}
70         cp Makefile DEPENDS GOALS LICENSE PACKAGE-MAINTAINER TODO i3.config i3-${VERSION}
71         cp -r src include docs man i3-${VERSION}
72         tar cf i3-${VERSION}.tar i3-${VERSION}
73         bzip2 -9 i3-${VERSION}.tar
74         rm -rf i3-${VERSION}
75
76 clean:
77         rm -f src/*.o
78         $(MAKE) -C docs clean
79         $(MAKE) -C man clean
80
81 distclean: clean
82         rm -f i3