]> git.sur5r.net Git - i3/i3/blob - Makefile
Merge branch 'next'
[i3/i3] / Makefile
1 TOPDIR=$(shell pwd)
2
3 include $(TOPDIR)/common.mk
4
5 # Depend on the object files of all source-files in src/*.c and on all header files
6 AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c
7 FILES:=$(filter-out $(AUTOGENERATED),$(wildcard src/*.c))
8 FILES:=$(FILES:.c=.o)
9 HEADERS=$(wildcard include/*.h)
10
11 # Depend on the specific file (.c for each .o) and on all headers
12 src/%.o: src/%.c ${HEADERS}
13         echo "CC $<"
14         $(CC) $(CFLAGS) -c -o $@ $<
15
16 all: src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
17         echo "LINK i3"
18         $(CC) -o i3 ${FILES} src/cfgparse.y.o src/cfgparse.yy.o $(LDFLAGS)
19         echo ""
20         echo "SUBDIR i3-msg"
21         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg
22         echo "SUBDIR i3-input"
23         $(MAKE) TOPDIR=$(TOPDIR) -C i3-input
24
25 src/cfgparse.yy.o: src/cfgparse.l
26         echo "LEX $<"
27         flex -i -o$(@:.o=.c) $<
28         $(CC) $(CFLAGS) -c -o $@ $(@:.o=.c)
29
30 src/cfgparse.y.o: src/cfgparse.y
31         echo "YACC $<"
32         bison --debug --verbose -b $(basename $< .y) -d $<
33         $(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
34
35 install: all
36         echo "INSTALL"
37         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/bin
38         $(INSTALL) -d -m 0755 $(DESTDIR)/etc/i3
39         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/share/xsessions
40         $(INSTALL) -m 0755 i3 $(DESTDIR)/usr/bin/
41         test -e $(DESTDIR)/etc/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)/etc/i3/config
42         $(INSTALL) -m 0644 i3.welcome $(DESTDIR)/etc/i3/welcome
43         $(INSTALL) -m 0644 i3.desktop $(DESTDIR)/usr/share/xsessions/
44         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg install
45         $(MAKE) TOPDIR=$(TOPDIR) -C i3-input install
46
47 dist: distclean
48         [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
49         [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
50         mkdir i3-${VERSION}
51         cp DEPENDS GOALS LICENSE PACKAGE-MAINTAINER TODO RELEASE-NOTES-${VERSION} i3.config i3.desktop i3.welcome pseudo-doc.doxygen Makefile i3-${VERSION}
52         cp -r src i3-msg include man i3-${VERSION}
53         # Only copy toplevel documentation (important stuff)
54         mkdir i3-${VERSION}/docs
55         find docs -maxdepth 1 -type f ! -name "*.xcf" -exec cp '{}' i3-${VERSION}/docs \;
56         # Only copy source code from i3-input
57         mkdir i3-${VERSION}/i3-input
58         find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
59         sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION:=\(.*\)/VERSION=${VERSION}/g' common.mk > i3-${VERSION}/common.mk
60         # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
61         make -C man
62         cp man/*.1 i3-${VERSION}/man/
63         tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
64         rm -rf i3-${VERSION}
65
66 clean:
67         rm -f src/*.o src/cfgparse.tab.{c,h} src/cfgparse.yy.c
68         $(MAKE) -C docs clean
69         $(MAKE) -C man clean
70         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg clean
71         $(MAKE) TOPDIR=$(TOPDIR) -C i3-input clean
72
73 distclean: clean
74         rm -f i3
75         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg distclean
76         $(MAKE) TOPDIR=$(TOPDIR) -C i3-input distclean