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
7 FILES:=$(filter-out $(AUTOGENERATED),$(wildcard src/*.c))
9 HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h))
10 CMDPARSE_HEADERS:=include/GENERATED_call.h include/GENERATED_enums.h include/GENERATED_tokens.h
12 # Recursively generate loglevels.h by explicitly calling make
13 # We need this step because we need to ensure that loglevels.h will be
14 # updated if necessary, but we also want to save rebuilds of the object
15 # files, so we cannot let the object files depend on loglevels.h.
16 ifeq ($(MAKECMDGOALS),loglevels.h)
17 #UNUSED:=$(warning Generating loglevels.h)
19 UNUSED:=$(shell $(MAKE) loglevels.h)
22 SUBDIRS:=i3-msg i3-input i3-nagbar i3-config-wizard i3bar i3-dump-log
24 # Depend on the specific file (.c for each .o) and on all headers
25 src/%.o: src/%.c ${HEADERS}
27 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $<
31 i3: libi3/libi3.a src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
33 $(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS)
39 for dir in $(SUBDIRS); do \
47 for file in $$(ls src/*.c src/*.y src/*.l | grep -v 'cfgparse.\(tab\|yy\).c'); \
49 echo $$(basename $$file .c); \
51 (echo "char *loglevels[] = {"; for file in $$(cat loglevels.tmp); \
53 echo "\"$$file\", "; \
55 echo "};") > include/loglevels.h;
57 # The GENERATED_* files are actually all created from a single pass, so all
58 # files just depend on the first one.
59 include/GENERATED_call.h: generate-command-parser.pl parser-specs/commands.spec
60 echo "[i3] Generating command parser"
61 (cd include; ../generate-command-parser.pl)
62 include/GENERATED_enums.h: include/GENERATED_call.h
63 include/GENERATED_tokens.h: include/GENERATED_call.h
65 # This target compiles the command parser twice:
66 # Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
67 # and once as an object file for i3.
68 src/commands_parser.o: src/commands_parser.c ${HEADERS} ${CMDPARSE_HEADERS}
70 $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DTEST_PARSER -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -o test.commands_parser $< $(LIBS)
71 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $<
73 src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS}
75 $(FLEX) -i -o$(@:.o=.c) $<
76 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
79 src/cfgparse.y.o: src/cfgparse.y ${HEADERS}
81 $(BISON) --debug --verbose -b $(basename $< .y) -d $<
82 $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
87 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
88 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
89 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
90 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
91 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
92 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
93 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
94 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
95 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
96 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
97 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
98 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
99 $(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
100 $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
101 $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
102 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
103 for dir in $(SUBDIRS); do \
104 $(MAKE) -C $$dir install; \
108 [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
109 [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
111 cp i3-migrate-config-to-v4 generate-command-parser.pl i3-sensible-* i3.config.keycodes DEPENDS GOALS LICENSE PACKAGE-MAINTAINER RELEASE-NOTES-${VERSION} i3.config i3.xsession.desktop i3.applications.desktop i3.welcome pseudo-doc.doxygen i3-wsbar Makefile i3-${VERSION}
112 cp -r src libi3 i3-msg i3-nagbar i3-config-wizard i3bar i3-dump-log yajl-fallback include man parser-specs i3-${VERSION}
113 # Only copy toplevel documentation (important stuff)
114 mkdir i3-${VERSION}/docs
115 # Pre-generate documentation
118 # Cleanup τεχ output files
119 find docs -regex ".*\.\(aux\|out\|log\|toc\|bm\|dvi\|log\)" -exec rm '{}' \;
120 find docs -maxdepth 1 -type f ! \( -name "*.xcf" -or -name "*.svg" \) -exec cp '{}' i3-${VERSION}/docs \;
121 # Only copy source code from i3-input
122 mkdir i3-${VERSION}/i3-input
123 find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
124 sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION:=$(shell /bin/echo '${GIT_VERSION}' | sed 's/\\/\\\\/g')/g;s/^VERSION:=\(.*\)/VERSION:=${VERSION}/g' common.mk > i3-${VERSION}/common.mk
125 # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
127 cp man/*.1 i3-${VERSION}/man/
128 cp i3bar/doc/*.1 i3-${VERSION}/i3bar/doc/
129 tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
133 rm -f src/*.o src/*.gcno src/cmdparse.* src/cfgparse.tab.{c,h} src/cfgparse.yy.c src/cfgparse.{output,dot} loglevels.tmp include/loglevels.h include/GENERATED_*
134 (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true
135 $(MAKE) -C libi3 clean
136 $(MAKE) -C docs clean
138 for dir in $(SUBDIRS); do \
140 echo "CLEAN $$dir"; \
141 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
146 for dir in $(SUBDIRS); do \
148 echo "DISTCLEAN $$dir"; \
149 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
153 rm -f /tmp/i3-coverage.info
154 rm -rf /tmp/i3-coverage
155 lcov -d . -b . --capture -o /tmp/i3-coverage.info
156 genhtml -o /tmp/i3-coverage/ /tmp/i3-coverage.info