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: libi3/libi3.a src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES}
32 $(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS)
38 for dir in $(SUBDIRS); do \
46 for file in $$(ls src/*.c src/*.y src/*.l | grep -v 'cfgparse.\(tab\|yy\).c'); \
48 echo $$(basename $$file .c); \
50 (echo "char *loglevels[] = {"; for file in $$(cat loglevels.tmp); \
52 echo "\"$$file\", "; \
54 echo "};") > include/loglevels.h;
56 src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS}
58 flex -i -o$(@:.o=.c) $<
59 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
61 src/cmdparse.yy.o: src/cmdparse.l src/cmdparse.y.o ${HEADERS}
63 flex -Pcmdyy -i -o$(@:.o=.c) $<
64 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
67 src/cfgparse.y.o: src/cfgparse.y ${HEADERS}
69 bison --debug --verbose -b $(basename $< .y) -d $<
70 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
72 src/cmdparse.y.o: src/cmdparse.y ${HEADERS}
74 bison -p cmdyy --debug --verbose -b $(basename $< .y) -d $<
75 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
80 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
81 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
82 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
83 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
84 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
85 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
86 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
87 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
88 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
89 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
90 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
91 $(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
92 $(INSTALL) -m 0644 i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/
93 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
94 for dir in $(SUBDIRS); do \
95 $(MAKE) -C $$dir install; \
99 [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
100 [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
102 cp i3-migrate-config-to-v4 i3-sensible-* 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}
103 cp -r src i3-msg i3-nagbar i3-config-wizard i3bar yajl-fallback include man i3-${VERSION}
104 # Only copy toplevel documentation (important stuff)
105 mkdir i3-${VERSION}/docs
106 # Pre-generate documentation
109 # Cleanup τεχ output files
110 find docs -regex ".*\.\(aux\|out\|log\|toc\|bm\|dvi\|log\)" -exec rm '{}' \;
111 find docs -maxdepth 1 -type f ! \( -name "*.xcf" -or -name "*.svg" \) -exec cp '{}' i3-${VERSION}/docs \;
112 # Only copy source code from i3-input
113 mkdir i3-${VERSION}/i3-input
114 find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
115 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
116 # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
118 cp man/*.1 i3-${VERSION}/man/
119 cp i3bar/doc/*.1 i3-${VERSION}/i3bar/doc/
120 tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
124 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
125 (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true
126 $(MAKE) -C libi3 clean
127 $(MAKE) -C docs clean
129 for dir in $(SUBDIRS); do \
131 echo "CLEAN $$dir"; \
132 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
137 for dir in $(SUBDIRS); do \
139 echo "DISTCLEAN $$dir"; \
140 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
144 rm -f /tmp/i3-coverage.info
145 rm -rf /tmp/i3-coverage
146 lcov -d . -b . --capture -o /tmp/i3-coverage.info
147 genhtml -o /tmp/i3-coverage/ /tmp/i3-coverage.info