3 include $(TOPDIR)/common.mk
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 src/cmdparse.tab.c src/cmdparse.yy.c
7 FILES:=$(filter-out $(AUTOGENERATED),$(wildcard src/*.c))
9 HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h))
11 # Recursively generate loglevels.h by explicitly calling make
12 # We need this step because we need to ensure that loglevels.h will be
13 # updated if necessary, but we also want to save rebuilds of the object
14 # files, so we cannot let the object files depend on loglevels.h.
15 ifeq ($(MAKECMDGOALS),loglevels.h)
16 #UNUSED:=$(warning Generating loglevels.h)
18 UNUSED:=$(shell $(MAKE) loglevels.h)
21 SUBDIRS=i3-msg i3-input i3-nagbar i3-config-wizard i3bar
23 # Depend on the specific file (.c for each .o) and on all headers
24 src/%.o: src/%.c ${HEADERS}
26 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $<
30 i3: src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES}
32 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
35 for dir in $(SUBDIRS); do \
43 for file in $$(ls src/*.c src/*.y src/*.l | grep -v 'cfgparse.\(tab\|yy\).c'); \
45 echo $$(basename $$file .c); \
47 (echo "char *loglevels[] = {"; for file in $$(cat loglevels.tmp); \
49 echo "\"$$file\", "; \
51 echo "};") > include/loglevels.h;
53 src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS}
55 flex -i -o$(@:.o=.c) $<
56 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
58 src/cmdparse.yy.o: src/cmdparse.l src/cmdparse.y.o ${HEADERS}
60 flex -Pcmdyy -i -o$(@:.o=.c) $<
61 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
64 src/cfgparse.y.o: src/cfgparse.y ${HEADERS}
66 bison --debug --verbose -b $(basename $< .y) -d $<
67 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
69 src/cmdparse.y.o: src/cmdparse.y ${HEADERS}
71 bison -p cmdyy --debug --verbose -b $(basename $< .y) -d $<
72 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
77 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
78 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
79 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
80 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
81 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
82 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
83 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
84 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
85 $(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
86 $(INSTALL) -m 0644 i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/
87 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
88 for dir in $(SUBDIRS); do \
89 $(MAKE) -C $$dir install; \
93 [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
94 [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
96 cp i3-migrate-config-to-v4 i3.config.keycodes DEPENDS GOALS LICENSE PACKAGE-MAINTAINER TODO RELEASE-NOTES-${VERSION} i3.config i3.desktop i3.welcome pseudo-doc.doxygen i3-wsbar Makefile i3-${VERSION}
97 cp -r src i3-msg i3-nagbar i3-config-wizard i3bar yajl-fallback include man i3-${VERSION}
98 # Only copy toplevel documentation (important stuff)
99 mkdir i3-${VERSION}/docs
100 # Pre-generate documentation
103 # Cleanup τεχ output files
104 find docs -regex ".*\.\(aux\|out\|log\|toc\|bm\|dvi\|log\)" -exec rm '{}' \;
105 find docs -maxdepth 1 -type f ! \( -name "*.xcf" -or -name "*.svg" \) -exec cp '{}' i3-${VERSION}/docs \;
106 # Only copy source code from i3-input
107 mkdir i3-${VERSION}/i3-input
108 find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
109 sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION:=$(shell echo '${GIT_VERSION}' | sed 's/\\/\\\\/g')/g;s/^VERSION:=\(.*\)/VERSION:=${VERSION}/g' common.mk > i3-${VERSION}/common.mk
110 # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
112 cp man/*.1 i3-${VERSION}/man/
113 cp i3bar/doc/*.1 i3-${VERSION}/i3bar/doc/
114 tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
118 rm -f src/*.o src/*.gcno src/cfgparse.tab.{c,h} src/cfgparse.yy.c src/cfgparse.{output,dot} src/cmdparse.tab.{c,h} src/cmdparse.yy.c src/cmdparse.{output,dot} loglevels.tmp include/loglevels.h
119 (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true
120 $(MAKE) -C docs clean
122 for dir in $(SUBDIRS); do \
124 echo "CLEAN $$dir"; \
125 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
130 for dir in $(SUBDIRS); do \
132 echo "DISTCLEAN $$dir"; \
133 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
137 rm -f /tmp/i3-coverage.info
138 rm -rf /tmp/i3-coverage
139 lcov -d . -b . --capture -o /tmp/i3-coverage.info
140 genhtml -o /tmp/i3-coverage/ /tmp/i3-coverage.info