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