]> git.sur5r.net Git - i3/i3/blob - Makefile
Merge branch 'lex' into 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
23 src/cfgparse.yy.o: src/cfgparse.l
24         echo "LEX $<"
25         lex -i -o $(@:.o=.c) $<
26         $(CC) $(CFLAGS) -c -o $@ $(@:.o=.c)
27
28 src/cfgparse.y.o: src/cfgparse.y
29         echo "YACC $<"
30         yacc --debug --verbose -b $(basename $< .y) -d $<
31         $(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
32
33 install: all
34         echo "INSTALL"
35         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/bin
36         $(INSTALL) -d -m 0755 $(DESTDIR)/etc/i3
37         $(INSTALL) -d -m 0755 $(DESTDIR)/usr/share/xsessions
38         $(INSTALL) -m 0755 i3 $(DESTDIR)/usr/bin/
39         test -e $(DESTDIR)/etc/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)/etc/i3/config
40         $(INSTALL) -m 0644 i3.desktop $(DESTDIR)/usr/share/xsessions/
41         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg install
42
43 dist: distclean
44         [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
45         [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
46         mkdir i3-${VERSION}
47         cp DEPENDS GOALS LICENSE PACKAGE-MAINTAINER TODO RELEASE-NOTES-${VERSION} i3.config i3.desktop pseudo-doc.doxygen Makefile i3-${VERSION}
48         cp -r src i3-msg include man i3-${VERSION}
49         # Only copy toplevel documentation (important stuff)
50         mkdir i3-${VERSION}/docs
51         find docs -maxdepth 1 -type f ! -name "*.xcf" -exec cp '{}' i3-${VERSION}/docs \;
52         sed -e 's/^GIT_VERSION=\(.*\)/GIT_VERSION=${GIT_VERSION}/g;s/^VERSION=\(.*\)/VERSION=${VERSION}/g' common.mk > i3-${VERSION}/common.mk
53         # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
54         make -C man
55         cp man/i3.1 i3-${VERSION}/man/i3.1
56         tar cf i3-${VERSION}.tar i3-${VERSION}
57         bzip2 -9 i3-${VERSION}.tar
58         rm -rf i3-${VERSION}
59
60 clean:
61         rm -f src/*.o src/cfgparse.tab.{c,h} src/cfgparse.yy.c
62         $(MAKE) -C docs clean
63         $(MAKE) -C man clean
64         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg clean
65
66 distclean: clean
67         rm -f i3
68         $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg distclean