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:=$(wildcard include/*.h)
10 CMDPARSE_HEADERS:=include/GENERATED_call.h include/GENERATED_enums.h include/GENERATED_tokens.h
12 SUBDIRS:=i3-msg i3-input i3-nagbar i3-config-wizard i3bar i3-dump-log
14 # Depend on the specific file (.c for each .o) and on all headers
15 src/%.o: src/%.c ${HEADERS}
17 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
21 i3: libi3/libi3.a src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
23 $(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS)
29 for dir in $(SUBDIRS); do \
35 # The GENERATED_* files are actually all created from a single pass, so all
36 # files just depend on the first one.
37 include/GENERATED_call.h: generate-command-parser.pl parser-specs/commands.spec
38 echo "[i3] Generating command parser"
39 (cd include; ../generate-command-parser.pl)
40 include/GENERATED_enums.h: include/GENERATED_call.h
41 include/GENERATED_tokens.h: include/GENERATED_call.h
43 # This target compiles the command parser twice:
44 # Once with -DTEST_PARSER, creating a stand-alone executable used for tests,
45 # and once as an object file for i3.
46 src/commands_parser.o: src/commands_parser.c ${HEADERS} ${CMDPARSE_HEADERS}
48 $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DTEST_PARSER -o test.commands_parser $< $(LIBS)
49 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
51 src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS}
53 $(FLEX) -i -o$(@:.o=.c) $<
54 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(@:.o=.c)
57 src/cfgparse.y.o: src/cfgparse.y ${HEADERS}
59 $(BISON) --debug --verbose -b $(basename $< .y) -d $<
60 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
65 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
66 $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
67 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
68 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
69 $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
70 $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
71 $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
72 $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(PREFIX)/bin/
73 $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(PREFIX)/bin/
74 $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(PREFIX)/bin/
75 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
76 test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
77 $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
78 $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
79 $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
80 for dir in $(SUBDIRS); do \
81 $(MAKE) -C $$dir install; \
85 [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
86 [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
88 cp i3-migrate-config-to-v4 generate-command-parser.pl i3-sensible-* i3.config.keycodes DEPENDS LICENSE PACKAGE-MAINTAINER RELEASE-NOTES-${VERSION} i3.config i3.xsession.desktop i3.applications.desktop pseudo-doc.doxygen Makefile i3-${VERSION}
89 cp -r src libi3 i3-msg i3-nagbar i3-config-wizard i3bar i3-dump-log yajl-fallback include man parser-specs i3-${VERSION}
90 # Only copy toplevel documentation (important stuff)
91 mkdir i3-${VERSION}/docs
92 # Pre-generate documentation
95 # Cleanup τεχ output files
96 find docs -regex ".*\.\(aux\|out\|log\|toc\|bm\|dvi\|log\)" -exec rm '{}' \;
97 find docs -maxdepth 1 -type f ! \( -name "*.xcf" -or -name "*.svg" \) -exec cp '{}' i3-${VERSION}/docs \;
98 # Only copy source code from i3-input
99 mkdir i3-${VERSION}/i3-input
100 find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
101 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
102 # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
104 cp man/*.1 i3-${VERSION}/man/
105 cp i3bar/doc/*.1 i3-${VERSION}/i3bar/doc/
106 tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
110 rm -f src/*.o src/*.gcno src/cmdparse.* src/cfgparse.tab.{c,h} src/cfgparse.yy.c src/cfgparse.{output,dot} include/GENERATED_*
111 (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true
112 $(MAKE) -C libi3 clean
113 $(MAKE) -C docs clean
115 for dir in $(SUBDIRS); do \
117 echo "CLEAN $$dir"; \
118 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
123 for dir in $(SUBDIRS); do \
125 echo "DISTCLEAN $$dir"; \
126 $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
130 rm -f /tmp/i3-coverage.info
131 rm -rf /tmp/i3-coverage
132 lcov -d . -b . --capture -o /tmp/i3-coverage.info
133 genhtml -o /tmp/i3-coverage/ /tmp/i3-coverage.info