]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2507 from stapelberg/autotools
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 25 Oct 2016 06:56:12 +0000 (08:56 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Oct 2016 06:56:12 +0000 (08:56 +0200)
Switch to autotools (GNU build system)

207 files changed:
.gitignore
.travis.yml
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
PACKAGE-MAINTAINER
common.mk [deleted file]
configure.ac [new file with mode: 0644]
debian/rules
docs/Makefile [deleted file]
docs/docs.mk [deleted file]
etc/config [new file with mode: 0644]
etc/config.keycodes [new file with mode: 0644]
i3-config-wizard/Makefile [deleted file]
i3-config-wizard/i3-config-wizard.mk [deleted file]
i3-config-wizard/main.c
i3-dump-log/Makefile [deleted file]
i3-dump-log/i3-dump-log.mk [deleted file]
i3-dump-log/main.c
i3-input/Makefile [deleted file]
i3-input/i3-input.h
i3-input/i3-input.mk [deleted file]
i3-input/main.c
i3-msg/Makefile [deleted file]
i3-msg/i3-msg.mk [deleted file]
i3-msg/main.c
i3-nagbar/Makefile [deleted file]
i3-nagbar/i3-nagbar.h
i3-nagbar/i3-nagbar.mk [deleted file]
i3-nagbar/main.c
i3-with-shmlog.xsession.desktop [deleted file]
i3.applications.desktop [deleted file]
i3.config [deleted file]
i3.config.keycodes [deleted file]
i3.xsession.desktop [deleted file]
i3bar/Makefile [deleted file]
i3bar/i3bar.mk [deleted file]
i3bar/include/child.h
i3bar/include/common.h
i3bar/include/config.h [deleted file]
i3bar/include/configuration.h [new file with mode: 0644]
i3bar/include/ipc.h
i3bar/include/mode.h
i3bar/include/outputs.h
i3bar/include/parse_json_header.h
i3bar/include/util.h
i3bar/include/workspaces.h
i3bar/include/xcb.h
i3bar/src/child.c
i3bar/src/config.c
i3bar/src/ipc.c
i3bar/src/main.c
i3bar/src/mode.c
i3bar/src/outputs.c
i3bar/src/parse_json_header.c
i3bar/src/workspaces.c
i3bar/src/xcb.c
include/all.h
include/assignments.h
include/bindings.h
include/click.h
include/cmdparse.h
include/commands.h
include/commands_parser.h
include/con.h
include/config.h [deleted file]
include/config_directives.h
include/config_parser.h
include/configuration.h [new file with mode: 0644]
include/data.h
include/debug.h
include/display_version.h
include/ewmh.h
include/fake_outputs.h
include/floating.h
include/handlers.h
include/i3.h
include/ipc.h
include/key_press.h
include/libi3.h
include/load_layout.h
include/log.h
include/main.h
include/manage.h
include/match.h
include/move.h
include/output.h
include/randr.h
include/regex.h
include/render.h
include/resize.h
include/restore_layout.h
include/scratchpad.h
include/shmlog.h
include/sighandler.h
include/startup.h
include/tree.h
include/util.h
include/window.h
include/workspace.h
include/x.h
include/xcb.h
include/xcursor.h
include/xinerama.h
include/yajl_utils.h
libi3/Makefile [deleted file]
libi3/dpi.c
libi3/draw_util.c
libi3/fake_configure_notify.c
libi3/font.c
libi3/format_placeholders.c
libi3/get_colorpixel.c
libi3/get_config_path.c
libi3/get_exe_path.c
libi3/get_mod_mask.c
libi3/get_process_filename.c
libi3/ipc_connect.c
libi3/ipc_recv_message.c
libi3/ipc_send_message.c
libi3/is_debug_build.c
libi3/libi3.mk [deleted file]
libi3/mkdirp.c
libi3/resolve_tilde.c
libi3/root_atom_contents.c
libi3/safewrappers.c
libi3/string.c
libi3/strndup.c
libi3/ucs2_conversion.c
m4/ax_append_flag.m4 [new file with mode: 0644]
m4/ax_cflags_warn_all.m4 [new file with mode: 0644]
m4/ax_check_compile_flag.m4 [new file with mode: 0644]
m4/ax_check_enable_debug.m4 [new file with mode: 0644]
m4/ax_check_gnu_make.m4 [new file with mode: 0644]
m4/ax_check_link_flag.m4 [new file with mode: 0644]
m4/ax_code_coverage.m4 [new file with mode: 0644]
m4/ax_configure_args.m4 [new file with mode: 0644]
m4/ax_enable_builddir.m4 [new file with mode: 0644]
m4/ax_extend_srcdir.m4 [new file with mode: 0644]
m4/ax_pthread.m4 [new file with mode: 0644]
m4/ax_require_defined.m4 [new file with mode: 0644]
m4/ax_sanitizers.m4 [new file with mode: 0644]
man/Makefile [deleted file]
man/asciidoc.conf [deleted file]
man/asciidoc.conf.in [new file with mode: 0644]
man/man.mk [deleted file]
release.sh
share/applications/i3.desktop [new file with mode: 0644]
share/xsessions/i3-with-shmlog.desktop [new file with mode: 0644]
share/xsessions/i3.desktop [new file with mode: 0644]
src/Makefile [deleted file]
src/assignments.c
src/click.c
src/commands.c
src/commands_parser.c
src/con.c
src/config.c
src/config_directives.c
src/config_parser.c
src/debug.c
src/display_version.c
src/ewmh.c
src/fake_outputs.c
src/floating.c
src/handlers.c
src/i3.mk [deleted file]
src/ipc.c
src/key_press.c
src/load_layout.c
src/log.c
src/main.c
src/manage.c
src/match.c
src/move.c
src/output.c
src/randr.c
src/regex.c
src/render.c
src/resize.c
src/restore_layout.c
src/scratchpad.c
src/sighandler.c
src/startup.c
src/tree.c
src/util.c
src/version.c
src/window.c
src/workspace.c
src/x.c
src/xcb.c
src/xcursor.c
src/xinerama.c
testcases/complete-run.pl [deleted file]
testcases/complete-run.pl.in [new file with mode: 0755]
testcases/lib/SocketActivation.pm
testcases/lib/TestWorker.pm
testcases/lib/i3test.pm [deleted file]
testcases/lib/i3test.pm.in [new file with mode: 0644]
testcases/t/171-config-migrate.t
testcases/t/175-startup-notification.t
testcases/t/187-commands-parser.t
testcases/t/196-randr-output-names.t
testcases/t/201-config-parser.t
testcases/t/207-shmlog.t
testcases/t/235-check-config-no-x.t
travis/check-spelling.pl
travis/clang-analyze.sh
travis/debian-build.sh
travis/run-tests.sh

index 617421ac1e92f3edc338c7b7c75d868e6696a608..c6fd81c8e3dcefc5b363f483bb309053c323c371 100644 (file)
@@ -34,3 +34,30 @@ i3-command-parser.stamp
 i3-config-parser.stamp
 .clang_complete
 LAST_VERSION
+
+################################################################################
+# https://raw.githubusercontent.com/github/gitignore/master/Autotools.gitignore
+################################################################################
+
+# http://www.gnu.org/software/automake
+
+Makefile.in
+/ar-lib
+/test-driver
+
+# http://www.gnu.org/software/autoconf
+
+/autom4te.cache
+/autoscan.log
+/autoscan-*.log
+/aclocal.m4
+/compile
+/config.h.in
+/config.guess
+/config.sub
+/configure
+/configure.scan
+/depcomp
+/install-sh
+/missing
+/stamp-h1
index f8a3de6f4ee02ce15c865c7ad3b233757db1e123..f97443355feb96b78683a5d9580db6fe158e21bc 100644 (file)
@@ -32,7 +32,7 @@ install:
 script:
   - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-safe-wrappers.sh
   - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-formatting.sh
-  - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC -e CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror" ${BASENAME} make all mans -j ASAN=1
+  - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${BASENAME} /bin/sh -c 'autoreconf -fi && mkdir -p build && cd build && (../configure || (cat config.log; false)) && make -j CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror"'
   - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/check-spelling.pl
   - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${BASENAME} ./travis/run-tests.sh
   - ./travis/skip-pkg.sh || docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${BASENAME} ./travis/debian-build.sh deb/debian-amd64/DIST
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index c08f277..0000000
--- a/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-TOPDIR=$(shell pwd)
-
-include $(TOPDIR)/common.mk
-
-SUBDIRS:=
-
-ALL_TARGETS =
-INSTALL_TARGETS =
-CLEAN_TARGETS =
-DISTCLEAN_TARGETS =
-
-all: real-all
-
-include libi3/libi3.mk
-include src/i3.mk
-include i3-config-wizard/i3-config-wizard.mk
-include i3-msg/i3-msg.mk
-include i3-input/i3-input.mk
-include i3-nagbar/i3-nagbar.mk
-include i3bar/i3bar.mk
-include i3-dump-log/i3-dump-log.mk
-include docs/docs.mk
-include man/man.mk
-
-# Update $(TOPDIR)/LAST_VERSION if it differs from $I3_VERSION
-CACHED_VERSION := '$(shell [ -f $(TOPDIR)/LAST_VERSION ] && cat $(TOPDIR)/LAST_VERSION)'
-ifneq ($(CACHED_VERSION),$(I3_VERSION))
-$(shell echo -n ${I3_VERSION} > $(TOPDIR)/LAST_VERSION)
-endif
-
-real-all: $(ALL_TARGETS)
-
-install: $(INSTALL_TARGETS)
-
-store_git_version:
-       echo -n ${I3_VERSION} > I3_VERSION
-
-dist: distclean
-       [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}
-       [ ! -e i3-${VERSION}.tar.bz2 ] || rm i3-${VERSION}.tar.bz2
-       mkdir i3-${VERSION}
-       cp i3-migrate-config-to-v4 i3-save-tree generate-command-parser.pl i3-sensible-* i3-dmenu-desktop i3.config.keycodes DEPENDS LICENSE PACKAGE-MAINTAINER RELEASE-NOTES-${VERSION} i3.config i3.xsession.desktop i3-with-shmlog.xsession.desktop i3.applications.desktop pseudo-doc.doxygen common.mk Makefile i3-${VERSION}
-       cp -r src libi3 i3-msg i3-nagbar i3-config-wizard i3bar i3-dump-log include man parser-specs testcases i3-${VERSION}
-       # Only copy toplevel documentation (important stuff)
-       mkdir i3-${VERSION}/docs
-       # Pre-generate documentation
-       $(MAKE) docs
-       # Cleanup τεχ output files
-       find docs -regex ".*\.\(aux\|out\|log\|toc\|bm\|dvi\|log\)" -exec rm '{}' \;
-       find docs -maxdepth 1 -type f ! \( -name "*.xcf" -or -name "*.svg" \) -exec cp '{}' i3-${VERSION}/docs \;
-       # Only copy source code from i3-input
-       mkdir i3-${VERSION}/i3-input
-       find i3-input -maxdepth 1 -type f \( -name "*.c" -or -name "*.mk" -or -name "*.h" -or -name "Makefile" \) -exec cp '{}' i3-${VERSION}/i3-input \;
-       cp I3_VERSION i3-${VERSION}/I3_VERSION
-       # Pre-generate a manpage to allow distributors to skip this step and save some dependencies
-       $(MAKE) mans
-       cp man/*.1 i3-${VERSION}/man/
-       tar cfj i3-${VERSION}.tar.bz2 i3-${VERSION}
-       rm -rf i3-${VERSION}
-
-clean: $(CLEAN_TARGETS)
-       (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true
-
-distclean: clean $(DISTCLEAN_TARGETS)
-
-coverage:
-       rm -f /tmp/i3-coverage.info
-       rm -rf /tmp/i3-coverage
-       lcov -d . -b . --capture -o /tmp/i3-coverage.info
-       genhtml -o /tmp/i3-coverage/ /tmp/i3-coverage.info
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..57d5b01
--- /dev/null
@@ -0,0 +1,563 @@
+@CODE_COVERAGE_RULES@
+
+echo-version:
+       @echo "@I3_VERSION@"
+
+bin_PROGRAMS = \
+       i3 \
+       i3bar/i3bar \
+       i3-config-wizard/i3-config-wizard \
+       i3-dump-log/i3-dump-log \
+       i3-input/i3-input \
+       i3-msg/i3-msg \
+       i3-nagbar/i3-nagbar
+
+install-exec-hook:
+       $(LN_S) -f i3 $(DESTDIR)$(bindir)/i3-with-shmlog
+
+uninstall-hook:
+       rm -f $(DESTDIR)$(bindir)/i3-with-shmlog
+
+i3includedir=$(includedir)/i3
+i3include_HEADERS = \
+       include/i3/ipc.h
+
+dist_bin_SCRIPTS = \
+       i3-dmenu-desktop \
+       i3-migrate-config-to-v4 \
+       i3-save-tree \
+       i3-sensible-editor \
+       i3-sensible-pager \
+       i3-sensible-terminal
+
+i3confdir = $(sysconfdir)/i3
+dist_i3conf_DATA = \
+       etc/config \
+       etc/config.keycodes
+
+applicationsdir = $(datarootdir)/applications
+xsessionsdir = $(datarootdir)/xsessions
+dist_applications_DATA = \
+       share/applications/i3.desktop
+dist_xsessions_DATA = \
+       share/xsessions/i3.desktop \
+       share/xsessions/i3-with-shmlog.desktop
+
+noinst_LIBRARIES = libi3.a
+
+check_PROGRAMS = test.commands_parser test.config_parser
+
+check_SCRIPTS = \
+       testcases/complete-run.pl
+
+clean-check:
+       rm -rf testsuite-* latest i3-cfg-for-* _Inline
+clean-local: clean-check
+
+TESTS = testcases/complete-run.pl
+
+EXTRA_DIST = \
+       $(dist_docs_toc_DATA:.html=) \
+       $(dist_docs_notoc_DATA:.html=) \
+       docs/asciidoc-git.conf \
+       docs/bigpicture.png \
+       docs/i3-pod2html \
+       docs/i3-sync.dia \
+       docs/i3-sync.png \
+       docs/i3-sync-working.dia \
+       docs/i3-sync-working.png \
+       docs/keyboard-layer1.png \
+       docs/keyboard-layer2.png \
+       docs/layout-saving-1.png \
+       docs/logo-30.png \
+       docs/modes.png \
+       docs/refcard.html \
+       docs/refcard_style.css \
+       docs/single_terminal.png \
+       docs/snapping.png \
+       docs/tree-layout1.png \
+       docs/tree-layout2.png \
+       docs/tree-shot1.png \
+       docs/tree-shot2.png \
+       docs/tree-shot3.png \
+       docs/tree-shot4.png \
+       docs/two_columns.png \
+       docs/two_terminals.png \
+       docs/wsbar.dia \
+       docs/wsbar.png \
+       i3bar/LICENSE \
+       libi3/README \
+       $(asciidoc_MANS:.1=.man) \
+       $(asciidoc_MANS:.1=.man) \
+       man/asciidoc.conf.in \
+       DEPENDS \
+       I3_VERSION \
+       LICENSE \
+       PACKAGE-MAINTAINER \
+       RELEASE-NOTES-4.12 \
+       generate-command-parser.pl \
+       parser-specs/commands.spec \
+       parser-specs/config.spec \
+       parser-specs/highlighting.vim \
+       pseudo-doc.doxygen \
+       testcases/complete-run.pl.in \
+       testcases/i3-test.config \
+       testcases/lib/i3test/Test.pm \
+       testcases/lib/i3test/Util.pm \
+       testcases/lib/i3test/XTEST.pm \
+       testcases/lib/i3test.pm.in \
+       testcases/lib/SocketActivation.pm \
+       testcases/lib/StartXServer.pm \
+       testcases/lib/StatusLine.pm \
+       testcases/lib/TestWorker.pm \
+       testcases/Makefile.PL \
+       testcases/new-test \
+       testcases/restart-state.golden \
+       testcases/t \
+       testcases/valgrind.supp
+
+# dirstamps contains directories which we want to be created in $(top_builddir)
+# so that our custom rules can store files in them.
+dirstamp = .dirstamp
+dirstamps = \
+       docs/$(dirstamp) \
+       man/$(dirstamp) \
+       parser/$(dirstamp)
+DISTCLEANFILES = $(dirstamps)
+
+$(dirstamps):
+       @stamp='$@'; $(MKDIR_P) "$${stamp%/*}"
+       @: > $@
+
+################################################################################
+# docs generation
+################################################################################
+
+docs_tocdir = ${docdir}
+docs_notocdir = ${docdir}
+docs_poddir = ${docdir}
+if BUILD_DOCS
+dist_docs_toc_DATA = \
+       docs/hacking-howto.html \
+       docs/userguide.html \
+       docs/ipc.html \
+       docs/multi-monitor.html \
+       docs/wsbar.html \
+       docs/testsuite.html \
+       docs/i3bar-protocol.html \
+       docs/layout-saving.html
+
+dist_docs_notoc_DATA = \
+       docs/debugging.html
+
+dist_docs_pod_DATA = \
+       docs/lib-i3test.html \
+       docs/lib-i3test-test.html
+
+$(dist_docs_toc_DATA): docs/%.html: docs/% docs/$(dirstamp)
+       $(AM_V_GEN) @PATH_ASCIIDOC@ -a toc -n -o $@ $<
+
+$(dist_docs_notoc_DATA): docs/%.html: docs/% docs/$(dirstamp)
+       $(AM_V_GEN) @PATH_ASCIIDOC@ -n -o $@ $<
+
+docs/lib-i3test.html: testcases/lib/i3test.pm docs/$(dirstamp)
+       $(AM_V_GEN) $(top_srcdir)/docs/i3-pod2html $< $@
+
+docs/lib-i3test-test.html: testcases/lib/i3test/Test.pm docs/$(dirstamp)
+       $(AM_V_GEN) $(top_srcdir)/docs/i3-pod2html $< $@
+
+else
+dist_docs_toc_DATA =
+dist_docs_notoc_DATA =
+dist_docs_pod_DATA =
+endif
+
+################################################################################
+# manpage generation
+################################################################################
+
+if BUILD_MANS
+dist_man1_MANS = \
+       $(asciidoc_MANS) \
+       $(pod_MANS)
+
+asciidoc_MANS = \
+       man/i3.1 \
+       man/i3bar.1 \
+       man/i3-msg.1 \
+       man/i3-input.1 \
+       man/i3-nagbar.1 \
+       man/i3-config-wizard.1 \
+       man/i3-migrate-config-to-v4.1 \
+       man/i3-sensible-editor.1 \
+       man/i3-sensible-pager.1 \
+       man/i3-sensible-terminal.1 \
+       man/i3-dump-log.1
+
+pod_MANS = \
+       man/i3-dmenu-desktop.1 \
+       man/i3-save-tree.1
+
+$(asciidoc_MANS): man/%.1: man/%.xml man/$(dirstamp)
+       $(AM_V_GEN) out='$@'; @PATH_XMLTO@ man -o "$${out%/*}" $<
+       @stamp='$@'; $(MKDIR_P) "$${stamp%/*}"
+
+man/%.xml: man/%.man man/asciidoc.conf man/$(dirstamp)
+       $(AM_V_GEN) @PATH_ASCIIDOC@ -d manpage -b docbook -f $(top_builddir)/man/asciidoc.conf -o $@ $<
+
+$(pod_MANS): man/%.1: % man/$(dirstamp)
+       $(AM_V_GEN) @PATH_POD2MAN@ --utf8 $< > $@
+else
+asciidoc_MANS =
+endif
+
+AM_CPPFLAGS = \
+       -I$(top_builddir)/parser \
+       -I$(top_srcdir)/include \
+       @AX_EXTEND_SRCDIR_CPPFLAGS@
+
+i3_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS) \
+       $(LIBSN_CFLAGS) \
+       $(XCB_CFLAGS) \
+       $(XCB_UTIL_CURSOR_CFLAGS) \
+       $(XCB_UTIL_KEYSYM_CFLAGS) \
+       $(XCB_UTIL_WM_CFLAGS) \
+       $(XCB_UTIL_XRM_CFLAGS) \
+       $(XKBCOMMON_CFLAGS) \
+       $(YAJL_CFLAGS) \
+       $(LIBPCRE_CFLAGS) \
+       $(PTHREAD_CFLAGS) \
+       $(CODE_COVERAGE_CFLAGS)
+
+i3_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(CODE_COVERAGE_CPPFLAGS)
+
+i3_LDADD = \
+       $(libi3_LIBS) \
+       $(LIBSN_LIBS) \
+       $(XCB_LIBS) \
+       $(XCB_UTIL_CURSOR_LIBS) \
+       $(XCB_UTIL_KEYSYMS_LIBS) \
+       $(XCB_UTIL_WM_LIBS) \
+       $(XCB_UTIL_XRM_LIBS) \
+       $(XKBCOMMON_LIBS) \
+       $(YAJL_LIBS) \
+       $(LIBPCRE_LIBS) \
+       $(PANGOCAIRO_LIBS) \
+       $(PTHREAD_LIBS) \
+       $(CODE_COVERAGE_LDFLAGS)
+
+libi3_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(XCB_CFLAGS) \
+       $(XCB_UTIL_CFLAGS) \
+       $(XCB_UTIL_XRM_CFLAGS) \
+       $(YAJL_CFLAGS) \
+       $(PANGOCAIRO_CFLAGS)
+
+libi3_LIBS = \
+       $(top_builddir)/libi3.a \
+       $(XCB_LIBS) \
+       $(XCB_UTIL_LIBS) \
+       $(XCB_UTIL_XRM_LIBS) \
+       $(YAJL_LIBS) \
+       $(PANGOCAIRO_LIBS)
+
+libi3_a_CFLAGS = \
+       $(libi3_CFLAGS)
+
+libi3_a_SOURCES = \
+       include/libi3.h \
+       libi3/dpi.c \
+       libi3/draw_util.c \
+       libi3/fake_configure_notify.c \
+       libi3/font.c \
+       libi3/format_placeholders.c \
+       libi3/get_colorpixel.c \
+       libi3/get_config_path.c \
+       libi3/get_exe_path.c \
+       libi3/get_mod_mask.c \
+       libi3/get_process_filename.c \
+       libi3/get_visualtype.c \
+       libi3/ipc_connect.c \
+       libi3/ipc_recv_message.c \
+       libi3/ipc_send_message.c \
+       libi3/is_debug_build.c \
+       libi3/mkdirp.c \
+       libi3/resolve_tilde.c \
+       libi3/root_atom_contents.c \
+       libi3/safewrappers.c \
+       libi3/string.c \
+       libi3/strndup.c \
+       libi3/ucs2_conversion.c
+
+i3_dump_log_i3_dump_log_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(PTHREAD_CFLAGS) \
+       $(libi3_CFLAGS)
+
+i3_dump_log_i3_dump_log_LDADD = \
+       $(PTHREAD_LIBS) \
+       $(libi3_LIBS)
+
+i3_dump_log_i3_dump_log_SOURCES = \
+       i3-dump-log/main.c
+
+i3_input_i3_input_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS)
+
+i3_input_i3_input_LDADD = \
+       $(libi3_LIBS) \
+       $(XCB_UTIL_KEYSYMS_LIBS)
+
+i3_input_i3_input_SOURCES = \
+       i3-input/i3-input.h \
+       i3-input/keysym2ucs.c \
+       i3-input/keysym2ucs.h \
+       i3-input/main.c
+
+i3_msg_i3_msg_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS)
+
+i3_msg_i3_msg_LDADD = \
+       $(libi3_LIBS)
+
+i3_msg_i3_msg_SOURCES = \
+       i3-msg/main.c
+
+i3_nagbar_i3_nagbar_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS)
+
+i3_nagbar_i3_nagbar_LDADD = \
+       $(libi3_LIBS) \
+       $(XCB_UTIL_CURSOR_LIBS)
+
+i3_nagbar_i3_nagbar_SOURCES = \
+       i3-nagbar/atoms.xmacro \
+       i3-nagbar/i3-nagbar.h \
+       i3-nagbar/main.c
+
+i3bar_i3bar_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(top_srcdir)/i3bar/include
+
+i3bar_i3bar_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS) \
+       $(XCB_CFLAGS) \
+       $(XKBCOMMON_CFLAGS) \
+       $(PANGOCAIRO_CFLAGS) \
+       $(YAJL_CFLAGS)
+
+i3bar_i3bar_LDADD = \
+       $(libi3_LIBS) \
+       $(XCB_LIBS) \
+       $(XCB_UTIL_CURSOR_LIBS) \
+       $(XKBCOMMON_LIBS) \
+       $(PANGOCAIRO_LIBS) \
+       $(YAJL_LIBS)
+
+i3bar_i3bar_SOURCES = \
+       i3bar/include/child.h \
+       i3bar/include/common.h \
+       i3bar/include/configuration.h \
+       i3bar/include/ipc.h \
+       i3bar/include/mode.h \
+       i3bar/include/outputs.h \
+       i3bar/include/parse_json_header.h \
+       i3bar/include/trayclients.h \
+       i3bar/include/util.h \
+       i3bar/include/workspaces.h \
+       i3bar/include/xcb_atoms.def \
+       i3bar/include/xcb.h \
+       i3bar/src/child.c \
+       i3bar/src/config.c \
+       i3bar/src/ipc.c \
+       i3bar/src/main.c \
+       i3bar/src/mode.c \
+       i3bar/src/outputs.c \
+       i3bar/src/parse_json_header.c \
+       i3bar/src/workspaces.c \
+       i3bar/src/xcb.c
+
+i3_config_wizard_i3_config_wizard_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(libi3_CFLAGS) \
+       $(XKBCOMMON_CFLAGS)
+
+i3_config_wizard_i3_config_wizard_LDADD = \
+       $(libi3_LIBS) \
+       $(XCB_UTIL_KEYSYMS_LIBS) \
+       $(XKBCOMMON_LIBS)
+
+i3_config_wizard_i3_config_wizard_SOURCES = \
+       i3-config-wizard/atoms.xmacro \
+       i3-config-wizard/main.c \
+       i3-config-wizard/xcb.h
+
+test_commands_parser_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -DTEST_PARSER
+
+test_commands_parser_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(i3_CFLAGS)
+
+test_commands_parser_SOURCES = \
+       src/commands_parser.c
+
+test_commands_parser_LDADD = \
+       $(i3_LDADD)
+
+test_config_parser_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -DTEST_PARSER
+
+test_config_parser_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(i3_CFLAGS)
+
+test_config_parser_SOURCES = \
+       src/config_parser.c
+
+test_config_parser_LDADD = \
+       $(i3_LDADD)
+
+command_parser_SOURCES = \
+       parser/GENERATED_command_enums.h \
+       parser/GENERATED_command_tokens.h \
+       parser/GENERATED_command_call.h
+
+config_parser_SOURCES = \
+       parser/GENERATED_config_enums.h \
+       parser/GENERATED_config_tokens.h \
+       parser/GENERATED_config_call.h
+
+i3_SOURCES = \
+       $(command_parser_SOURCES) \
+       $(config_parser_SOURCES) \
+       include/all.h \
+       include/assignments.h \
+       include/atoms_NET_SUPPORTED.xmacro \
+       include/atoms_rest.xmacro \
+       include/atoms.xmacro \
+       include/bindings.h \
+       include/click.h \
+       include/cmdparse.h \
+       include/commands.h \
+       include/commands_parser.h \
+       include/config_directives.h \
+       include/configuration.h \
+       include/config_parser.h \
+       include/con.h \
+       include/data.h \
+       include/debug.h \
+       include/display_version.h \
+       include/ewmh.h \
+       include/fake_outputs.h \
+       include/floating.h \
+       include/handlers.h \
+       include/i3.h \
+       include/ipc.h \
+       include/key_press.h \
+       include/load_layout.h \
+       include/log.h \
+       include/main.h \
+       include/manage.h \
+       include/match.h \
+       include/move.h \
+       include/output.h \
+       include/queue.h \
+       include/randr.h \
+       include/regex.h \
+       include/render.h \
+       include/resize.h \
+       include/restore_layout.h \
+       include/scratchpad.h \
+       include/sd-daemon.h \
+       include/shmlog.h \
+       include/sighandler.h \
+       include/startup.h \
+       include/tree.h \
+       include/util.h \
+       include/window.h \
+       include/workspace.h \
+       include/xcb.h \
+       include/xcursor.h \
+       include/x.h \
+       include/xinerama.h \
+       include/yajl_utils.h \
+       src/assignments.c \
+       src/bindings.c \
+       src/click.c \
+       src/commands.c \
+       src/commands_parser.c \
+       src/con.c \
+       src/config.c \
+       src/config_directives.c \
+       src/config_parser.c \
+       src/debug.c \
+       src/display_version.c \
+       src/ewmh.c \
+       src/fake_outputs.c \
+       src/floating.c \
+       src/handlers.c \
+       src/ipc.c \
+       src/key_press.c \
+       src/load_layout.c \
+       src/log.c \
+       src/main.c \
+       src/manage.c \
+       src/match.c \
+       src/move.c \
+       src/output.c \
+       src/randr.c \
+       src/regex.c \
+       src/render.c \
+       src/resize.c \
+       src/restore_layout.c \
+       src/scratchpad.c \
+       src/sd-daemon.c \
+       src/sighandler.c \
+       src/startup.c \
+       src/tree.c \
+       src/util.c \
+       src/version.c \
+       src/window.c \
+       src/workspace.c \
+       src/x.c \
+       src/xcb.c \
+       src/xcursor.c \
+       src/xinerama.c
+
+################################################################################
+# parser generation
+################################################################################
+
+$(command_parser_SOURCES): %.h: i3-command-parser.stamp
+
+$(config_parser_SOURCES): %.h: i3-config-parser.stamp
+
+src/i3-commands_parser.$(OBJEXT): i3-command-parser.stamp
+
+src/i3-config_parser.$(OBJEXT): i3-config-parser.stamp
+
+i3-command-parser.stamp: parser/$(dirstamp) generate-command-parser.pl parser-specs/commands.spec
+       $(AM_V_GEN) $(top_srcdir)/generate-command-parser.pl --input=$(top_srcdir)/parser-specs/commands.spec --prefix=command
+       $(AM_V_at) mv GENERATED_command_* $(top_builddir)/parser
+       $(AM_V_at) touch $@
+
+i3-config-parser.stamp: parser/$(dirstamp) generate-command-parser.pl parser-specs/config.spec
+       $(AM_V_GEN) $(top_srcdir)/generate-command-parser.pl --input=$(top_srcdir)/parser-specs/config.spec --prefix=config
+       $(AM_V_at) mv GENERATED_config_* $(top_builddir)/parser
+       $(AM_V_at) touch $@
+
+CLEANFILES = \
+       i3-command-parser.stamp \
+       i3-config-parser.stamp
index 5a922ee8b323aabfcd1e427dcc3183fe545f9abe..953fac5390c7e02b68fd417d5d9076a2d9c6ed1a 100644 (file)
@@ -23,14 +23,10 @@ x-terminal-emulator symlink in Debian, please use it in i3-sensible-terminal.
 
 On debian, compilation and installing the manpages looks like this:
 
-       # Compilation
-       $(MAKE)
-       $(MAKE) -C man
-
-       # Installation
-       $(MAKE) DESTDIR=$(CURDIR)/debian/i3-wm/ install
-       mkdir -p $(CURDIR)/debian/i3-wm/usr/share/man/man1
-       cp man/*.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1
+       autoreconf -fi
+       mkdir -p build && cd build
+       ../configure
+       make -j8 install
 
 Please make sure that i3-migrate-config-to-v4 and i3-config-wizard are
 installed with i3. The Perl script is necessary to (automatically) convert v3
diff --git a/common.mk b/common.mk
deleted file mode 100644 (file)
index 6032ce6..0000000
--- a/common.mk
+++ /dev/null
@@ -1,218 +0,0 @@
-UNAME=$(shell uname)
-DEBUG=1
-ASAN=0
-INSTALL=install
-LN=ln
-PKG_CONFIG=pkg-config
-ifndef PREFIX
-  PREFIX=/usr
-endif
-ifndef EXEC_PREFIX
-  EXEC_PREFIX=$(PREFIX)
-endif
-ifndef SYSCONFDIR
-  ifeq ($(PREFIX),/usr)
-    SYSCONFDIR=/etc
-  else
-    SYSCONFDIR=$(PREFIX)/etc
-  endif
-endif
-
-# In dist and snapshot tarballs, use the I3_VERSION and VERSION files. Otherwise use git information.
-ifeq ($(wildcard .git),)
-  # not in git repository
-  VERSION := $(shell [ -f $(TOPDIR)/I3_VERSION ] && cat $(TOPDIR)/I3_VERSION | cut -d '-' -f 1)
-  I3_VERSION := '$(shell [ -f $(TOPDIR)/I3_VERSION ] && cat $(TOPDIR)/I3_VERSION)'
-else
-  VERSION := $(shell git describe --tags --abbrev=0)
-  I3_VERSION := '$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch \"$(shell git describe --tags --always --all | sed s:heads/::)\")'
-endif
-
-MAJOR_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 1)
-MINOR_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 2)
-PATCH_VERSION := $(shell echo ${VERSION} | cut -d '.' -f 3)
-ifeq (${PATCH_VERSION},)
-PATCH_VERSION := 0
-endif
-
-## Generic flags
-
-# Default CFLAGS that users should be able to override
-ifeq ($(DEBUG),1)
-# Extended debugging flags, macros shall be available in gcc
-CFLAGS ?= -pipe -gdwarf-2 -g3
-else
-CFLAGS ?= -pipe -O2 -freorder-blocks-and-partition
-endif
-
-ifeq ($(ASAN),1)
-CFLAGS += -fsanitize=address -DI3_ASAN_ENABLED
-LDFLAGS += -fsanitize=address
-endif
-
-# Default LDFLAGS that users should be able to override
-LDFLAGS ?= $(as_needed_LDFLAG)
-
-# Common CFLAGS for all i3 related binaries
-I3_CFLAGS  = -std=c99
-I3_CFLAGS += -Wall
-# unused-function, unused-label, unused-variable are turned on by -Wall
-# We don’t want unused-parameter because of the use of many callbacks
-I3_CFLAGS += -Wunused-value
-I3_CFLAGS += -Iinclude
-
-I3_CPPFLAGS  = -DI3_VERSION=\"${I3_VERSION}\"
-I3_CPPFLAGS += -DMAJOR_VERSION=${MAJOR_VERSION}
-I3_CPPFLAGS += -DMINOR_VERSION=${MINOR_VERSION}
-I3_CPPFLAGS += -DPATCH_VERSION=${PATCH_VERSION}
-I3_CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
-I3_CPPFLAGS += -DI3__FILE__=__FILE__
-
-
-## Libraries flags
-
-ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null 1>/dev/null || echo 1),1)
-$(error "pkg-config was not found")
-endif
-
-# An easier way to get CFLAGS and LDFLAGS falling back in case there's
-# no pkg-config support for certain libraries.
-#
-# NOTE that you must not use a blank after comma when calling this:
-#     $(call ldflags_for_lib name, fallback) # bad
-#     $(call ldflags_for_lib name,fallback) # good
-# Otherwise, the compiler will get -l foo instead of -lfoo
-#
-# We redirect stderr to /dev/null because pkg-config prints an error if support
-# for gnome-config was enabled but gnome-config is not actually installed.
-cflags_for_lib = $(shell $(PKG_CONFIG) --silence-errors --cflags $(1) 2>/dev/null)
-ldflags_for_lib = $(shell $(PKG_CONFIG) --exists 2>/dev/null $(1) && $(PKG_CONFIG) --libs $(1) 2>/dev/null || echo -l$(2))
-
-# XCB common stuff
-XCB_CFLAGS  := $(call cflags_for_lib, xcb)
-XCB_CFLAGS  += $(call cflags_for_lib, xcb-event)
-XCB_LIBS    := $(call ldflags_for_lib, xcb,xcb)
-XCB_LIBS    += $(call ldflags_for_lib, xcb-event,xcb-event)
-XCB_CFLAGS  += $(call cflags_for_lib, xcb-util)
-XCB_LIBS    += $(call ldflags_for_lib, xcb-util)
-ifneq ($(shell $(PKG_CONFIG) --atleast-version=0.3.8 xcb-util 2>/dev/null && echo 1),1)
-$(error "xcb-util >= 0.3.8 not found")
-endif
-XCB_XKB_LIBS := $(call ldflags_for_lib, xcb-xkb,xcb-xkb)
-
-# XCB keyboard stuff
-XCB_KBD_CFLAGS := $(call cflags_for_lib, xcb-keysyms)
-XCB_KBD_LIBS   := $(call ldflags_for_lib, xcb-keysyms,xcb-keysyms)
-
-# XCB WM stuff
-XCB_WM_CFLAGS := $(call cflags_for_lib, xcb-icccm)
-XCB_WM_CFLAGS += $(call cflags_for_lib, xcb-xinerama)
-XCB_WM_CFLAGS += $(call cflags_for_lib, xcb-randr)
-XCB_WM_LIBS   := $(call ldflags_for_lib, xcb-icccm,xcb-icccm)
-XCB_WM_LIBS   += $(call ldflags_for_lib, xcb-xinerama,xcb-xinerama)
-XCB_WM_LIBS   += $(call ldflags_for_lib, xcb-randr,xcb-randr)
-
-# XCB cursor
-XCB_CURSOR_CFLAGS := $(call cflags_for_lib, xcb-cursor)
-XCB_CURSOR_LIBS   := $(call ldflags_for_lib, xcb-cursor,xcb-cursor)
-
-XKB_COMMON_CFLAGS := $(call cflags_for_lib, xkbcommon,xkbcommon)
-XKB_COMMON_LIBS := $(call ldflags_for_lib, xkbcommon,xkbcommon)
-XKB_COMMON_X11_CFLAGS := $(call cflags_for_lib, xkbcommon-x11,xkbcommon-x11)
-XKB_COMMON_X11_LIBS := $(call ldflags_for_lib, xkbcommon-x11,xkbcommon-x11)
-
-# XCB xrm
-XCB_XRM_CFLAGS := $(call cflags_for_lib, xcb-xrm)
-XCB_XRM_LIBS   := $(call ldflags_for_lib, xcb-xrm,xcb-xrm)
-
-# yajl
-YAJL_CFLAGS := $(call cflags_for_lib, yajl)
-YAJL_LIBS   := $(call ldflags_for_lib, yajl,yajl)
-
-#libev
-LIBEV_CFLAGS := $(call cflags_for_lib, libev)
-LIBEV_LIBS   := $(call ldflags_for_lib, libev,ev)
-
-# libpcre
-PCRE_CFLAGS := $(call cflags_for_lib, libpcre)
-ifneq ($(shell $(PKG_CONFIG) --atleast-version=8.10 libpcre 2>/dev/null && echo 1),1)
-$(error "libpcre >= 8.10 not found")
-endif
-PCRE_LIBS   := $(call ldflags_for_lib, libpcre,pcre)
-
-# startup-notification
-LIBSN_CFLAGS := $(call cflags_for_lib, libstartup-notification-1.0)
-LIBSN_LIBS   := $(call ldflags_for_lib, libstartup-notification-1.0,startup-notification-1)
-
-# Pango
-PANGO_CFLAGS := $(call cflags_for_lib, cairo)
-PANGO_CFLAGS += $(call cflags_for_lib, pangocairo)
-ifneq ($(shell $(PKG_CONFIG) --atleast-version=1.14.4 cairo 2>/dev/null && echo 1),1)
-$(error "cairo >= 1.14.4 missing")
-endif
-PANGO_LIBS   := $(call ldflags_for_lib, cairo)
-PANGO_LIBS   += $(call ldflags_for_lib, pangocairo)
-
-# libi3
-LIBS = -L$(TOPDIR) -li3 -lm
-
-## Platform-specific flags
-
-# Please test if -Wl,--as-needed works on your platform and send me a patch.
-# it is known not to work on Darwin (Mac OS X)
-ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
-as_needed_LDFLAG = -Wl,--as-needed
-endif
-
-ifeq ($(UNAME),NetBSD)
-# We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
-I3_CFLAGS += -idirafter /usr/pkg/include
-I3_LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
-endif
-
-ifeq ($(UNAME),OpenBSD)
-I3_CFLAGS += -I${X11BASE}/include
-LIBS += -liconv
-I3_LDFLAGS += -L${X11BASE}/lib
-endif
-
-ifeq ($(UNAME),FreeBSD)
-LIBS += -liconv
-endif
-
-ifeq ($(UNAME),Darwin)
-LIBS += -liconv
-else ifneq ($(UNAME),OpenBSD)
-# Darwin (Mac OS X) and OpenBSD do not have librt
-LIBS += -lrt
-endif
-
-ifeq ($(UNAME),SunOS)
-LIBS += -lsocket -liconv -lgen
-endif
-
-ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
-I3_CPPFLAGS += -D_GNU_SOURCE
-endif
-
-
-ifeq ($(COVERAGE),1)
-I3_CFLAGS += -fprofile-arcs -ftest-coverage
-LIBS += -lgcov
-endif
-
-V ?= 0
-ifeq ($(V),0)
-# Don’t print command lines which are run
-.SILENT:
-
-# echo-ing vars
-V_ASCIIDOC = echo ASCIIDOC $@;
-V_POD2HTML = echo POD2HTML $@;
-V_POD2MAN = echo POD2MAN $@;
-V_A2X = echo A2X $@;
-endif
-
-# Always remake the following targets
-.PHONY: install clean dist distclean
-
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..3c47c6b
--- /dev/null
@@ -0,0 +1,165 @@
+#                                               -*- Autoconf -*-
+# Run autoreconf -fi to generate a configure script from this file.
+
+AC_PREREQ([2.69])
+AC_INIT([i3], [4.12], [https://github.com/i3/i3/issues])
+# For AX_EXTEND_SRCDIR
+AX_ENABLE_BUILDDIR
+AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2])
+# Default to silent rules, use V=1 to get verbose compilation output.
+AM_SILENT_RULES([yes])
+# Make it possible to disable maintainer mode to disable re-generation of build
+# system files.
+AM_MAINTAINER_MODE([enable])
+AC_CONFIG_SRCDIR([libi3/ipc_recv_message.c])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+# Verify we are using GNU make because we use '%'-style pattern rules in
+# Makefile.am, which are a GNU make extension. Pull requests to replace
+# '%'-style pattern rules with a more portable alternative are welcome.
+AX_CHECK_GNU_MAKE
+AS_VAR_IF([_cv_gnu_make_command], [""], [AC_MSG_ERROR([the i3 Makefile.am requires GNU make])])
+
+AX_EXTEND_SRCDIR
+
+AS_IF([test -d ${srcdir}/.git],
+      [
+        VERSION="$(git describe --tags --abbrev=0)"
+        I3_VERSION="$(git describe --tags --always) ($(git log --pretty=format:%cd --date=short -n1), branch \\\"$(git describe --tags --always --all | sed s:heads/::)\\\")"
+        # Mirrors what libi3/is_debug_build.c does:
+        is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
+      ],
+      [
+        VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)"
+        I3_VERSION="$(cat ${srcdir}/I3_VERSION)"
+        is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)"
+      ])
+AC_SUBST([I3_VERSION], [$I3_VERSION])
+MAJOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 1)"
+MINOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 2)"
+PATCH_VERSION="$(echo ${VERSION} | cut -d '.' -f 3)"
+AS_IF([test "x${PATCH_VERSION}" = x], [PATCH_VERSION=0])
+AC_DEFINE_UNQUOTED([I3_VERSION], ["${I3_VERSION}"], [i3 version])
+AC_DEFINE_UNQUOTED([MAJOR_VERSION], [${MAJOR_VERSION}], [i3 major version])
+AC_DEFINE_UNQUOTED([MINOR_VERSION], [${MINOR_VERSION}], [i3 minor version])
+AC_DEFINE_UNQUOTED([PATCH_VERSION], [${PATCH_VERSION}], [i3 patch version])
+
+AX_CODE_COVERAGE
+
+dnl is_release must be lowercase because AX_CHECK_ENABLE_DEBUG calls m4_tolower
+dnl on its fourth argument.
+AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release])
+
+AC_PROG_CC_C99
+
+AC_DEFINE_UNQUOTED(SYSCONFDIR, "`eval echo $sysconfdir`", [Location of system configuration files])
+
+# For strnlen() and vasprintf().
+AC_USE_SYSTEM_EXTENSIONS
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+dnl The error message should include the specific type which could not be
+dnl found, but I do not see a way to achieve that.
+AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([cannot find required type])])
+
+# Checks for library functions.
+AC_FUNC_FORK
+AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+AC_FUNC_STRNLEN
+AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3 requires])])
+
+# Checks for libraries.
+
+AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])])
+
+# libev does not ship with a pkg-config file :(.
+AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
+
+AC_SEARCH_LIBS([shm_open], [rt])
+
+AX_PTHREAD
+
+dnl Each prefix corresponds to a source tarball which users might have
+dnl downloaded in a newer version and would like to overwrite.
+PKG_CHECK_MODULES([LIBSN], [libstartup-notification-1.0])
+PKG_CHECK_MODULES([XCB], [xcb xcb-xkb xcb-xinerama xcb-randr])
+PKG_CHECK_MODULES([XCB_UTIL], [xcb-event xcb-util])
+PKG_CHECK_MODULES([XCB_UTIL_CURSOR], [xcb-cursor])
+PKG_CHECK_MODULES([XCB_UTIL_KEYSYMS], [xcb-keysyms])
+PKG_CHECK_MODULES([XCB_UTIL_WM], [xcb-icccm])
+PKG_CHECK_MODULES([XCB_UTIL_XRM], [xcb-xrm])
+PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon xkbcommon-x11])
+PKG_CHECK_MODULES([YAJL], [yajl])
+PKG_CHECK_MODULES([LIBPCRE], [libpcre >= 8.10])
+PKG_CHECK_MODULES([PANGOCAIRO], [cairo >= 1.14.4 pangocairo])
+
+# Checks for programs.
+AC_PROG_AWK
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+AC_PROG_LN_S
+
+AC_PATH_PROG([PATH_ASCIIDOC], [asciidoc])
+AC_PATH_PROG([PATH_XMLTO], [xmlto])
+AC_PATH_PROG([PATH_POD2MAN], [pod2man])
+
+AM_CONDITIONAL([BUILD_MANS], [test x$PATH_ASCIIDOC != x && test x$PATH_XMLTO != x && test x$PATH_POD2MAN != x])
+AM_CONDITIONAL([BUILD_DOCS], [test x$PATH_ASCIIDOC != x])
+
+AM_PROG_AR
+
+AX_FLAGS_WARN_ALL
+AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
+AC_SUBST(AM_CFLAGS)
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h float.h inttypes.h limits.h locale.h netinet/in.h paths.h stddef.h stdint.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h unistd.h], , [AC_MSG_FAILURE([cannot find the $ac_header header, which i3 requires])])
+
+AC_CONFIG_FILES([Makefile testcases/lib/i3test.pm man/asciidoc.conf])
+AC_CONFIG_FILES([testcases/complete-run.pl], [chmod +x testcases/complete-run.pl])
+
+# Enable address sanitizer for non-release builds. The performance hit is a
+# 50% increase of wallclock time for the testsuite on my machine.
+if test x$is_release = xyes; then
+       default_sanitizers=
+else
+       default_sanitizers=address
+fi
+AX_SANITIZERS(, [$default_sanitizers], [AC_DEFINE([I3_ASAN_ENABLED], [], [Enable ASAN])])
+
+AC_OUTPUT
+
+if test -z "${BUILD_DOCS_TRUE}"; then
+       print_BUILD_DOCS=yes
+else
+       print_BUILD_DOCS=no
+fi
+
+
+if test -z "${BUILD_MANS_TRUE}"; then
+       print_BUILD_MANS=yes
+else
+       print_BUILD_MANS=no
+fi
+
+echo \
+"--------------------------------------------------------------------------------
+build configured:
+
+AS_HELP_STRING([i3 version:], [`echo ${I3_VERSION} | sed 's,\\\\,,g'`])
+AS_HELP_STRING([is release version:], [${is_release}])
+
+AS_HELP_STRING([build manpages:], [${print_BUILD_MANS}])
+AS_HELP_STRING([build docs:], [${print_BUILD_DOCS}])
+AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}])
+AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}])
+AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])
+
+To compile, run:
+
+  cd `pwd` && make -j8
+--------------------------------------------------------------------------------"
index 843655eec8a9ca959f51ac860ee42d2080de54a1..e119f26013f477d33e2eec84d93df067b4acc13b 100755 (executable)
@@ -4,14 +4,14 @@
 export V:=1
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
-override_dh_auto_build:
-       dh_auto_build -- all docs mans
-
 override_dh_installchangelogs:
        dh_installchangelogs RELEASE-NOTES-*
 
 override_dh_strip:
        dh_strip --dbg-package=i3-wm-dbg
 
+override_dh_auto_test:
+       # TODO: enable tests
+
 %:
-       dh $@ --parallel
+       dh $@ --parallel --builddirectory=build --with=autoreconf
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644 (file)
index d6e670c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-       $(MAKE) -C .. docs
-
-clean:
-       $(MAKE) -C .. clean-docs
-
-.PHONY: all clean
diff --git a/docs/docs.mk b/docs/docs.mk
deleted file mode 100644 (file)
index 050df97..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-DISTCLEAN_TARGETS += clean-docs
-
-# To pass additional parameters for asciidoc
-ASCIIDOC = asciidoc
-I3POD2HTML = ./docs/i3-pod2html
-
-ASCIIDOC_NOTOC_TARGETS = \
-       docs/debugging.html
-
-ASCIIDOC_TOC_TARGETS = \
-       docs/hacking-howto.html \
-       docs/userguide.html \
-       docs/ipc.html \
-       docs/multi-monitor.html \
-       docs/wsbar.html \
-       docs/testsuite.html \
-       docs/i3bar-protocol.html \
-       docs/layout-saving.html
-
-ASCIIDOC_TARGETS = \
-       $(ASCIIDOC_TOC_TARGETS) \
-       $(ASCIIDOC_NOTOC_TARGETS)
-
-ASCIIDOC_CALL = $(V_ASCIIDOC)$(ASCIIDOC) -n $(ASCIIDOC_FLAGS) -o $@ $<
-ASCIIDOC_TOC_CALL = $(V_ASCIIDOC)$(ASCIIDOC) -a toc -n $(ASCIIDOC_FLAGS) -o $@ $<
-
-POD2HTML_TARGETS = \
-       docs/lib-i3test.html \
-       docs/lib-i3test-test.html
-
-docs/lib-i3test.html: testcases/lib/i3test.pm
-       $(V_POD2HTML)$(I3POD2HTML) $< $@
-
-docs/lib-i3test-test.html: testcases/lib/i3test/Test.pm
-       $(V_POD2HTML)$(I3POD2HTML) $< $@
-
-docs: $(ASCIIDOC_TARGETS) $(POD2HTML_TARGETS)
-
-$(ASCIIDOC_TOC_TARGETS): docs/%.html: docs/%
-       $(ASCIIDOC_TOC_CALL)
-
-$(ASCIIDOC_NOTOC_TARGETS): docs/%.html: docs/%
-       $(ASCIIDOC_CALL)
-
-clean-docs:
-       rm -f $(ASCIIDOC_TARGETS) $(POD2HTML_TARGETS)
diff --git a/etc/config b/etc/config
new file mode 100644 (file)
index 0000000..f7722d3
--- /dev/null
@@ -0,0 +1,179 @@
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+#
+# This config file uses keycodes (bindsym) and was written for the QWERTY
+# layout.
+#
+# To get a config file with the same key positions, but for your current
+# layout, use the i3-config-wizard
+#
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+font pango:monospace 8
+
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+#font pango:DejaVu Sans Mono 8
+
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# use these keys for focus, movement, and resize directions when reaching for
+# the arrows is not convenient
+set $up l
+set $down k
+set $left j
+set $right semicolon
+
+# use Mouse+Mod1 to drag floating windows to their wanted position
+floating_modifier Mod1
+
+# start a terminal
+bindsym Mod1+Return exec i3-sensible-terminal
+
+# kill focused window
+bindsym Mod1+Shift+q kill
+
+# start dmenu (a program launcher)
+bindsym Mod1+d exec dmenu_run
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym Mod1+d exec --no-startup-id i3-dmenu-desktop
+
+# change focus
+bindsym Mod1+$left focus left
+bindsym Mod1+$down focus down
+bindsym Mod1+$up focus up
+bindsym Mod1+$right focus right
+
+# alternatively, you can use the cursor keys:
+bindsym Mod1+Left focus left
+bindsym Mod1+Down focus down
+bindsym Mod1+Up focus up
+bindsym Mod1+Right focus right
+
+# move focused window
+bindsym Mod1+Shift+$left move left
+bindsym Mod1+Shift+$down move down
+bindsym Mod1+Shift+$up move up
+bindsym Mod1+Shift+$right move right
+
+# alternatively, you can use the cursor keys:
+bindsym Mod1+Shift+Left move left
+bindsym Mod1+Shift+Down move down
+bindsym Mod1+Shift+Up move up
+bindsym Mod1+Shift+Right move right
+
+# split in horizontal orientation
+bindsym Mod1+h split h
+
+# split in vertical orientation
+bindsym Mod1+v split v
+
+# enter fullscreen mode for the focused container
+bindsym Mod1+f fullscreen toggle
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym Mod1+s layout stacking
+bindsym Mod1+w layout tabbed
+bindsym Mod1+e layout toggle split
+
+# toggle tiling / floating
+bindsym Mod1+Shift+space floating toggle
+
+# change focus between tiling / floating windows
+bindsym Mod1+space focus mode_toggle
+
+# focus the parent container
+bindsym Mod1+a focus parent
+
+# focus the child container
+#bindsym Mod1+d focus child
+
+# move the currently focused window to the scratchpad
+bindsym Mod1+Shift+minus move scratchpad
+
+# Show the next scratchpad window or hide the focused scratchpad window.
+# If there are multiple scratchpad windows, this command cycles through them.
+bindsym Mod1+minus scratchpad show
+
+# switch to workspace
+bindsym Mod1+1 workspace 1
+bindsym Mod1+2 workspace 2
+bindsym Mod1+3 workspace 3
+bindsym Mod1+4 workspace 4
+bindsym Mod1+5 workspace 5
+bindsym Mod1+6 workspace 6
+bindsym Mod1+7 workspace 7
+bindsym Mod1+8 workspace 8
+bindsym Mod1+9 workspace 9
+bindsym Mod1+0 workspace 10
+
+# move focused container to workspace
+bindsym Mod1+Shift+1 move container to workspace 1
+bindsym Mod1+Shift+2 move container to workspace 2
+bindsym Mod1+Shift+3 move container to workspace 3
+bindsym Mod1+Shift+4 move container to workspace 4
+bindsym Mod1+Shift+5 move container to workspace 5
+bindsym Mod1+Shift+6 move container to workspace 6
+bindsym Mod1+Shift+7 move container to workspace 7
+bindsym Mod1+Shift+8 move container to workspace 8
+bindsym Mod1+Shift+9 move container to workspace 9
+bindsym Mod1+Shift+0 move container to workspace 10
+
+# reload the configuration file
+bindsym Mod1+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym Mod1+Shift+r restart
+# exit i3 (logs you out of your X session)
+bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+        # These bindings trigger as soon as you enter the resize mode
+
+        # Pressing left will shrink the window’s width.
+        # Pressing right will grow the window’s width.
+        # Pressing up will shrink the window’s height.
+        # Pressing down will grow the window’s height.
+        bindsym $left       resize shrink width 10 px or 10 ppt
+        bindsym $down       resize grow height 10 px or 10 ppt
+        bindsym $up         resize shrink height 10 px or 10 ppt
+        bindsym $right      resize grow width 10 px or 10 ppt
+
+        # same bindings, but for the arrow keys
+        bindsym Left        resize shrink width 10 px or 10 ppt
+        bindsym Down        resize grow height 10 px or 10 ppt
+        bindsym Up          resize shrink height 10 px or 10 ppt
+        bindsym Right       resize grow width 10 px or 10 ppt
+
+        # back to normal: Enter or Escape
+        bindsym Return mode "default"
+        bindsym Escape mode "default"
+}
+
+bindsym Mod1+r mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+        status_command i3status
+}
+
+#######################################################################
+# automatically start i3-config-wizard to offer the user to create a
+# keysym-based config which used their favorite modifier (alt or windows)
+#
+# i3-config-wizard will not launch if there already is a config file
+# in ~/.i3/config.
+#
+# Please remove the following exec line:
+#######################################################################
+exec i3-config-wizard
diff --git a/etc/config.keycodes b/etc/config.keycodes
new file mode 100644 (file)
index 0000000..0c978d0
--- /dev/null
@@ -0,0 +1,155 @@
+# WARNING
+# WARNING: This configuration file is a template for the i3-config-wizard to
+# WARNING: generate a config which uses keysyms in your current layout. It does
+# WARNING: not get loaded by i3. Please do not change it.
+# WARNING
+
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+
+set $mod Mod1
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+font pango:monospace 8
+
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+#font pango:DejaVu Sans Mono 8
+
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal
+bindcode $mod+36 exec i3-sensible-terminal
+
+# kill focused window
+bindcode $mod+Shift+24 kill
+
+# start dmenu (a program launcher)
+bindcode $mod+40 exec dmenu_run
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
+
+# change focus
+bindcode $mod+44 focus left
+bindcode $mod+45 focus down
+bindcode $mod+46 focus up
+bindcode $mod+47 focus right
+
+# alternatively, you can use the cursor keys:
+bindcode $mod+113 focus left
+bindcode $mod+116 focus down
+bindcode $mod+111 focus up
+bindcode $mod+114 focus right
+
+# move focused window
+bindcode $mod+Shift+44 move left
+bindcode $mod+Shift+45 move down
+bindcode $mod+Shift+46 move up
+bindcode $mod+Shift+47 move right
+
+# alternatively, you can use the cursor keys:
+bindcode $mod+Shift+113 move left
+bindcode $mod+Shift+116 move down
+bindcode $mod+Shift+111 move up
+bindcode $mod+Shift+114 move right
+
+# split in horizontal orientation
+bindcode $mod+43 split h
+
+# split in vertical orientation
+bindcode $mod+55 split v
+
+# enter fullscreen mode for the focused container
+bindcode $mod+41 fullscreen toggle
+
+# change container layout (stacked, tabbed, toggle split)
+bindcode $mod+39 layout stacking
+bindcode $mod+25 layout tabbed
+bindcode $mod+26 layout toggle split
+
+# toggle tiling / floating
+bindcode $mod+Shift+65 floating toggle
+
+# change focus between tiling / floating windows
+bindcode $mod+65 focus mode_toggle
+
+# focus the parent container
+bindcode $mod+38 focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+# switch to workspace
+bindcode $mod+10 workspace 1
+bindcode $mod+11 workspace 2
+bindcode $mod+12 workspace 3
+bindcode $mod+13 workspace 4
+bindcode $mod+14 workspace 5
+bindcode $mod+15 workspace 6
+bindcode $mod+16 workspace 7
+bindcode $mod+17 workspace 8
+bindcode $mod+18 workspace 9
+bindcode $mod+19 workspace 10
+
+# move focused container to workspace
+bindcode $mod+Shift+10 move container to workspace 1
+bindcode $mod+Shift+11 move container to workspace 2
+bindcode $mod+Shift+12 move container to workspace 3
+bindcode $mod+Shift+13 move container to workspace 4
+bindcode $mod+Shift+14 move container to workspace 5
+bindcode $mod+Shift+15 move container to workspace 6
+bindcode $mod+Shift+16 move container to workspace 7
+bindcode $mod+Shift+17 move container to workspace 8
+bindcode $mod+Shift+18 move container to workspace 9
+bindcode $mod+Shift+19 move container to workspace 10
+
+# reload the configuration file
+bindcode $mod+Shift+54 reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindcode $mod+Shift+27 restart
+# exit i3 (logs you out of your X session)
+bindcode $mod+Shift+26 exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+        # These bindings trigger as soon as you enter the resize mode
+
+        # Pressing left will shrink the window’s width.
+        # Pressing right will grow the window’s width.
+        # Pressing up will shrink the window’s height.
+        # Pressing down will grow the window’s height.
+        bindcode 44 resize shrink width 10 px or 10 ppt
+        bindcode 45 resize grow height 10 px or 10 ppt
+        bindcode 46 resize shrink height 10 px or 10 ppt
+        bindcode 47 resize grow width 10 px or 10 ppt
+
+        # same bindings, but for the arrow keys
+        bindcode 113 resize shrink width 10 px or 10 ppt
+        bindcode 116 resize grow height 10 px or 10 ppt
+        bindcode 111 resize shrink height 10 px or 10 ppt
+        bindcode 114 resize grow width 10 px or 10 ppt
+
+        # back to normal: Enter or Escape
+        bindcode 36 mode "default"
+        bindcode 9 mode "default"
+}
+
+bindcode $mod+27 mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+        status_command i3status
+}
diff --git a/i3-config-wizard/Makefile b/i3-config-wizard/Makefile
deleted file mode 100644 (file)
index d5ac18c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3-config-wizard/i3-config-wizard
-
-install:
-       $(MAKE) -C .. install-i3-config-wizard
-
-clean:
-       $(MAKE) -C .. clean-i3-config-wizard
-
-.PHONY: all install clean
diff --git a/i3-config-wizard/i3-config-wizard.mk b/i3-config-wizard/i3-config-wizard.mk
deleted file mode 100644 (file)
index 9c01cdb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3-config-wizard/i3-config-wizard
-INSTALL_TARGETS += install-i3-config-wizard
-CLEAN_TARGETS += clean-i3-config-wizard
-
-i3_config_wizard_SOURCES           := $(wildcard i3-config-wizard/*.c)
-i3_config_wizard_HEADERS           := $(wildcard i3-config-wizard/*.h)
-i3_config_wizard_CFLAGS             = $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(PANGO_CFLAGS) $(XCB_XRM_CFLAGS) $(XKB_COMMON_CFLAGS) $(XKB_COMMON_X11_CFLAGS)
-i3_config_wizard_LIBS               = $(XCB_LIBS) $(XCB_KBD_LIBS) $(PANGO_LIBS) $(XCB_XRM_LIBS) $(XKB_COMMON_LIBS) $(XKB_COMMON_X11_LIBS)
-
-i3_config_wizard_OBJECTS := $(i3_config_wizard_SOURCES:.c=.o)
-
-
-i3-config-wizard/%.o: i3-config-wizard/%.c $(i3_config_wizard_HEADERS) i3-config-parser.stamp
-       echo "[i3-config-wizard] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_config_wizard_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-i3-config-wizard/i3-config-wizard: libi3.a $(i3_config_wizard_OBJECTS)
-       echo "[i3-config-wizard] Link i3-config-wizard"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_config_wizard_LIBS)
-
-install-i3-config-wizard: i3-config-wizard/i3-config-wizard
-       echo "[i3-config-wizard] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3-config-wizard/i3-config-wizard $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3-config-wizard:
-       echo "[i3-config-wizard] Clean"
-       rm -f $(i3_config_wizard_OBJECTS) $(i3_config_wizard_SOURCES_GENERATED) i3-config-wizard/i3-config-wizard i3-config-wizard/cfgparse.*
index 284f15fa2635276f5706e7496855b006c5fd774d..2bb43270e32d02d637a026b80ea613a12ec41353 100644 (file)
@@ -8,6 +8,8 @@
  *                   keysyms.
  *
  */
+#include <config.h>
+
 #if defined(__FreeBSD__)
 #include <sys/param.h>
 #endif
diff --git a/i3-dump-log/Makefile b/i3-dump-log/Makefile
deleted file mode 100644 (file)
index 2b9e4fe..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3-dump-log/i3-dump-log
-
-install:
-       $(MAKE) -C .. install-i3-dump-log
-
-clean:
-       $(MAKE) -C .. clean-i3-dump-log
-
-.PHONY: all install clean
diff --git a/i3-dump-log/i3-dump-log.mk b/i3-dump-log/i3-dump-log.mk
deleted file mode 100644 (file)
index 09a793f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3-dump-log/i3-dump-log
-INSTALL_TARGETS += install-i3-dump-log
-CLEAN_TARGETS += clean-i3-dump-log
-
-i3_dump_log_SOURCES := $(wildcard i3-dump-log/*.c)
-i3_dump_log_HEADERS := $(wildcard i3-dump-log/*.h)
-i3_dump_log_CFLAGS   = $(XCB_CFLAGS) $(PANGO_CFLAGS)
-i3_dump_log_LIBS     = $(XCB_LIBS)
-
-i3_dump_log_OBJECTS := $(i3_dump_log_SOURCES:.c=.o)
-
-
-i3-dump-log/%.o: i3-dump-log/%.c $(i3_dump_log_HEADERS)
-       echo "[i3-dump-log] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_dump_log_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-i3-dump-log/i3-dump-log: libi3.a $(i3_dump_log_OBJECTS)
-       echo "[i3-dump-log] Link i3-dump-log"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_dump_log_LIBS)
-
-install-i3-dump-log: i3-dump-log/i3-dump-log
-       echo "[i3-dump-log] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3-dump-log/i3-dump-log $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3-dump-log:
-       echo "[i3-dump-log] Clean"
-       rm -f $(i3_dump_log_OBJECTS) i3-dump-log/i3-dump-log
index d9b0613c3d7c944717300447a8209a186bbcd5dc..ec9e577ddee2c30dff42498f1f0349d2e9adef2b 100644 (file)
@@ -7,6 +7,8 @@
  * i3-dump-log/main.c: Dumps the i3 SHM log to stdout.
  *
  */
+#include <config.h>
+
 #include <stdio.h>
 #include <stdbool.h>
 #include <sys/types.h>
diff --git a/i3-input/Makefile b/i3-input/Makefile
deleted file mode 100644 (file)
index e1c8eae..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3-input/i3-input
-
-install:
-       $(MAKE) -C .. install-i3-input
-
-clean:
-       $(MAKE) -C .. clean-i3-input
-
-.PHONY: all install clean
index fcf9edc3d3138ac24a644cee60adb8f85b9e6bdf..d347506fe61e69907bc9c13fbc5672ff3fd8113c 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <config.h>
+
 #include <err.h>
 
 #define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
diff --git a/i3-input/i3-input.mk b/i3-input/i3-input.mk
deleted file mode 100644 (file)
index ce36f93..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3-input/i3-input
-INSTALL_TARGETS += install-i3-input
-CLEAN_TARGETS += clean-i3-input
-
-i3_input_SOURCES := $(wildcard i3-input/*.c)
-i3_input_HEADERS := $(wildcard i3-input/*.h)
-i3_input_CFLAGS   = $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(PANGO_CFLAGS) $(XCB_XRM_CFLAGS)
-i3_input_LIBS     = $(XCB_LIBS) $(XCB_KBD_LIBS) $(PANGO_LIBS) $(XCB_XRM_LIBS)
-
-i3_input_OBJECTS := $(i3_input_SOURCES:.c=.o)
-
-
-i3-input/%.o: i3-input/%.c $(i3_input_HEADERS)
-       echo "[i3-input] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_input_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-i3-input/i3-input: libi3.a $(i3_input_OBJECTS)
-       echo "[i3-input] Link i3-input"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_input_LIBS)
-
-install-i3-input: i3-input/i3-input
-       echo "[i3-input] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3-input/i3-input $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3-input:
-       echo "[i3-input] Clean"
-       rm -f $(i3_input_OBJECTS) i3-input/i3-input
index b467c4c37d86e867c747486097ce0b9c2761c4ff..97d574a220a051efda053e2433042c176859a267 100644 (file)
@@ -8,6 +8,8 @@
  *                  to i3.
  *
  */
+#include "libi3.h"
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <stdlib.h>
@@ -31,8 +33,6 @@
 
 #include "i3-input.h"
 
-#include "libi3.h"
-
 /* IPC format string. %s will be replaced with what the user entered, then
  * the command will be sent to i3 */
 static char *format;
diff --git a/i3-msg/Makefile b/i3-msg/Makefile
deleted file mode 100644 (file)
index fedb31e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3-msg/i3-msg
-
-install:
-       $(MAKE) -C .. install-i3-msg
-
-clean:
-       $(MAKE) -C .. clean-i3-msg
-
-.PHONY: all install clean
diff --git a/i3-msg/i3-msg.mk b/i3-msg/i3-msg.mk
deleted file mode 100644 (file)
index dfba4d2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3-msg/i3-msg
-INSTALL_TARGETS += install-i3-msg
-CLEAN_TARGETS += clean-i3-msg
-
-i3_msg_SOURCES := $(wildcard i3-msg/*.c)
-i3_msg_HEADERS := $(wildcard i3-msg/*.h)
-i3_msg_CFLAGS   = $(XCB_CFLAGS) $(PANGO_CFLAGS) $(YAJL_CFLAGS)
-i3_msg_LIBS     = $(XCB_LIBS) $(YAJL_LIBS)
-
-i3_msg_OBJECTS := $(i3_msg_SOURCES:.c=.o)
-
-
-i3-msg/%.o: i3-msg/%.c $(i3_msg_HEADERS)
-       echo "[i3-msg] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_msg_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-i3-msg/i3-msg: libi3.a $(i3_msg_OBJECTS)
-       echo "[i3-msg] Link i3-msg"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_msg_LIBS)
-
-install-i3-msg: i3-msg/i3-msg
-       echo "[i3-msg] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3-msg/i3-msg $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3-msg:
-       echo "[i3-msg] Clean"
-       rm -f $(i3_msg_OBJECTS) i3-msg/i3-msg
index 658c33b4d48ec118ab5d51eba24aa77c6840d8b0..5161245970d848ddbdd0579b2ab59228500e811a 100644 (file)
@@ -14,6 +14,8 @@
  * Additionally, it’s even useful sometimes :-).
  *
  */
+#include "libi3.h"
+
 #include <stdio.h>
 #include <stdbool.h>
 #include <sys/types.h>
@@ -34,7 +36,6 @@
 #include <xcb/xcb.h>
 #include <xcb/xcb_aux.h>
 
-#include "libi3.h"
 #include <i3/ipc.h>
 
 static char *socket_path;
diff --git a/i3-nagbar/Makefile b/i3-nagbar/Makefile
deleted file mode 100644 (file)
index 12748e2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3-nagbar/i3-nagbar
-
-install:
-       $(MAKE) -C .. install-i3-nagbar
-
-clean:
-       $(MAKE) -C .. clean-i3-nagbar
-
-.PHONY: all install clean
index fc076d728f8a099f80d9875c721d86eb42cc342d..c5e94cc6140fb554d3fa48f1f6b26c1c2107f1db 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <config.h>
+
 #include <err.h>
 
 #define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
diff --git a/i3-nagbar/i3-nagbar.mk b/i3-nagbar/i3-nagbar.mk
deleted file mode 100644 (file)
index c6c7a2e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3-nagbar/i3-nagbar
-INSTALL_TARGETS += install-i3-nagbar
-CLEAN_TARGETS += clean-i3-nagbar
-
-i3_nagbar_SOURCES := $(wildcard i3-nagbar/*.c)
-i3_nagbar_HEADERS := $(wildcard i3-nagbar/*.h)
-i3_nagbar_CFLAGS   = $(XCB_CFLAGS) $(XCB_CURSOR_CFLAGS) $(XCB_WM_CFLAGS) $(PANGO_CFLAGS) $(XCB_XRM_CFLAGS)
-i3_nagbar_LIBS     = $(XCB_LIBS) $(XCB_CURSOR_LIBS) $(XCB_WM_LIBS) $(PANGO_LIBS) $(XCB_XRM_LIBS)
-
-i3_nagbar_OBJECTS := $(i3_nagbar_SOURCES:.c=.o)
-
-
-i3-nagbar/%.o: i3-nagbar/%.c $(i3_nagbar_HEADERS)
-       echo "[i3-nagbar] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_nagbar_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-i3-nagbar/i3-nagbar: libi3.a $(i3_nagbar_OBJECTS)
-       echo "[i3-nagbar] Link i3-nagbar"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_nagbar_LIBS)
-
-install-i3-nagbar: i3-nagbar/i3-nagbar
-       echo "[i3-nagbar] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3-nagbar/i3-nagbar $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3-nagbar:
-       echo "[i3-nagbar] Clean"
-       rm -f $(i3_nagbar_OBJECTS) i3-nagbar/i3-nagbar
index 674fcb7d13bd5115a13ac978415ea6b91a1755bd..2e9e77d490fe3af6e36c9383fc91880d40874d27 100644 (file)
@@ -8,6 +8,8 @@
  * when the user has an error in their configuration file.
  *
  */
+#include "libi3.h"
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -30,7 +32,6 @@
 #include <xcb/randr.h>
 #include <xcb/xcb_cursor.h>
 
-#include "libi3.h"
 #include "i3-nagbar.h"
 
 /** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
diff --git a/i3-with-shmlog.xsession.desktop b/i3-with-shmlog.xsession.desktop
deleted file mode 100644 (file)
index 3c63450..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=i3 (with debug log)
-Comment=improved dynamic tiling window manager
-Exec=i3-with-shmlog
-Type=Application
-Keywords=tiling;wm;windowmanager;window;manager;
diff --git a/i3.applications.desktop b/i3.applications.desktop
deleted file mode 100644 (file)
index 2844592..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Type=Application
-Name=i3
-NoDisplay=true
-GenericName=A dynamic tiling window manager
-Comment=improved dynamic tiling window manager
-Exec=i3
-X-GNOME-WMName=i3
-X-GNOME-Autostart-Phase=WindowManager
-X-GNOME-Provides=windowmanager
-X-GNOME-Autostart-Notify=false
diff --git a/i3.config b/i3.config
deleted file mode 100644 (file)
index f7722d3..0000000
--- a/i3.config
+++ /dev/null
@@ -1,179 +0,0 @@
-# i3 config file (v4)
-#
-# Please see http://i3wm.org/docs/userguide.html for a complete reference!
-#
-# This config file uses keycodes (bindsym) and was written for the QWERTY
-# layout.
-#
-# To get a config file with the same key positions, but for your current
-# layout, use the i3-config-wizard
-#
-
-# Font for window titles. Will also be used by the bar unless a different font
-# is used in the bar {} block below.
-font pango:monospace 8
-
-# This font is widely installed, provides lots of unicode glyphs, right-to-left
-# text rendering and scalability on retina/hidpi displays (thanks to pango).
-#font pango:DejaVu Sans Mono 8
-
-# Before i3 v4.8, we used to recommend this one as the default:
-# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
-# The font above is very space-efficient, that is, it looks good, sharp and
-# clear in small sizes. However, its unicode glyph coverage is limited, the old
-# X core fonts rendering does not support right-to-left and this being a bitmap
-# font, it doesn’t scale on retina/hidpi displays.
-
-# use these keys for focus, movement, and resize directions when reaching for
-# the arrows is not convenient
-set $up l
-set $down k
-set $left j
-set $right semicolon
-
-# use Mouse+Mod1 to drag floating windows to their wanted position
-floating_modifier Mod1
-
-# start a terminal
-bindsym Mod1+Return exec i3-sensible-terminal
-
-# kill focused window
-bindsym Mod1+Shift+q kill
-
-# start dmenu (a program launcher)
-bindsym Mod1+d exec dmenu_run
-# There also is the (new) i3-dmenu-desktop which only displays applications
-# shipping a .desktop file. It is a wrapper around dmenu, so you need that
-# installed.
-# bindsym Mod1+d exec --no-startup-id i3-dmenu-desktop
-
-# change focus
-bindsym Mod1+$left focus left
-bindsym Mod1+$down focus down
-bindsym Mod1+$up focus up
-bindsym Mod1+$right focus right
-
-# alternatively, you can use the cursor keys:
-bindsym Mod1+Left focus left
-bindsym Mod1+Down focus down
-bindsym Mod1+Up focus up
-bindsym Mod1+Right focus right
-
-# move focused window
-bindsym Mod1+Shift+$left move left
-bindsym Mod1+Shift+$down move down
-bindsym Mod1+Shift+$up move up
-bindsym Mod1+Shift+$right move right
-
-# alternatively, you can use the cursor keys:
-bindsym Mod1+Shift+Left move left
-bindsym Mod1+Shift+Down move down
-bindsym Mod1+Shift+Up move up
-bindsym Mod1+Shift+Right move right
-
-# split in horizontal orientation
-bindsym Mod1+h split h
-
-# split in vertical orientation
-bindsym Mod1+v split v
-
-# enter fullscreen mode for the focused container
-bindsym Mod1+f fullscreen toggle
-
-# change container layout (stacked, tabbed, toggle split)
-bindsym Mod1+s layout stacking
-bindsym Mod1+w layout tabbed
-bindsym Mod1+e layout toggle split
-
-# toggle tiling / floating
-bindsym Mod1+Shift+space floating toggle
-
-# change focus between tiling / floating windows
-bindsym Mod1+space focus mode_toggle
-
-# focus the parent container
-bindsym Mod1+a focus parent
-
-# focus the child container
-#bindsym Mod1+d focus child
-
-# move the currently focused window to the scratchpad
-bindsym Mod1+Shift+minus move scratchpad
-
-# Show the next scratchpad window or hide the focused scratchpad window.
-# If there are multiple scratchpad windows, this command cycles through them.
-bindsym Mod1+minus scratchpad show
-
-# switch to workspace
-bindsym Mod1+1 workspace 1
-bindsym Mod1+2 workspace 2
-bindsym Mod1+3 workspace 3
-bindsym Mod1+4 workspace 4
-bindsym Mod1+5 workspace 5
-bindsym Mod1+6 workspace 6
-bindsym Mod1+7 workspace 7
-bindsym Mod1+8 workspace 8
-bindsym Mod1+9 workspace 9
-bindsym Mod1+0 workspace 10
-
-# move focused container to workspace
-bindsym Mod1+Shift+1 move container to workspace 1
-bindsym Mod1+Shift+2 move container to workspace 2
-bindsym Mod1+Shift+3 move container to workspace 3
-bindsym Mod1+Shift+4 move container to workspace 4
-bindsym Mod1+Shift+5 move container to workspace 5
-bindsym Mod1+Shift+6 move container to workspace 6
-bindsym Mod1+Shift+7 move container to workspace 7
-bindsym Mod1+Shift+8 move container to workspace 8
-bindsym Mod1+Shift+9 move container to workspace 9
-bindsym Mod1+Shift+0 move container to workspace 10
-
-# reload the configuration file
-bindsym Mod1+Shift+c reload
-# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
-bindsym Mod1+Shift+r restart
-# exit i3 (logs you out of your X session)
-bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
-
-# resize window (you can also use the mouse for that)
-mode "resize" {
-        # These bindings trigger as soon as you enter the resize mode
-
-        # Pressing left will shrink the window’s width.
-        # Pressing right will grow the window’s width.
-        # Pressing up will shrink the window’s height.
-        # Pressing down will grow the window’s height.
-        bindsym $left       resize shrink width 10 px or 10 ppt
-        bindsym $down       resize grow height 10 px or 10 ppt
-        bindsym $up         resize shrink height 10 px or 10 ppt
-        bindsym $right      resize grow width 10 px or 10 ppt
-
-        # same bindings, but for the arrow keys
-        bindsym Left        resize shrink width 10 px or 10 ppt
-        bindsym Down        resize grow height 10 px or 10 ppt
-        bindsym Up          resize shrink height 10 px or 10 ppt
-        bindsym Right       resize grow width 10 px or 10 ppt
-
-        # back to normal: Enter or Escape
-        bindsym Return mode "default"
-        bindsym Escape mode "default"
-}
-
-bindsym Mod1+r mode "resize"
-
-# Start i3bar to display a workspace bar (plus the system information i3status
-# finds out, if available)
-bar {
-        status_command i3status
-}
-
-#######################################################################
-# automatically start i3-config-wizard to offer the user to create a
-# keysym-based config which used their favorite modifier (alt or windows)
-#
-# i3-config-wizard will not launch if there already is a config file
-# in ~/.i3/config.
-#
-# Please remove the following exec line:
-#######################################################################
-exec i3-config-wizard
diff --git a/i3.config.keycodes b/i3.config.keycodes
deleted file mode 100644 (file)
index 0c978d0..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-# WARNING
-# WARNING: This configuration file is a template for the i3-config-wizard to
-# WARNING: generate a config which uses keysyms in your current layout. It does
-# WARNING: not get loaded by i3. Please do not change it.
-# WARNING
-
-# i3 config file (v4)
-#
-# Please see http://i3wm.org/docs/userguide.html for a complete reference!
-
-set $mod Mod1
-
-# Font for window titles. Will also be used by the bar unless a different font
-# is used in the bar {} block below.
-font pango:monospace 8
-
-# This font is widely installed, provides lots of unicode glyphs, right-to-left
-# text rendering and scalability on retina/hidpi displays (thanks to pango).
-#font pango:DejaVu Sans Mono 8
-
-# Before i3 v4.8, we used to recommend this one as the default:
-# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
-# The font above is very space-efficient, that is, it looks good, sharp and
-# clear in small sizes. However, its unicode glyph coverage is limited, the old
-# X core fonts rendering does not support right-to-left and this being a bitmap
-# font, it doesn’t scale on retina/hidpi displays.
-
-# Use Mouse+$mod to drag floating windows to their wanted position
-floating_modifier $mod
-
-# start a terminal
-bindcode $mod+36 exec i3-sensible-terminal
-
-# kill focused window
-bindcode $mod+Shift+24 kill
-
-# start dmenu (a program launcher)
-bindcode $mod+40 exec dmenu_run
-# There also is the (new) i3-dmenu-desktop which only displays applications
-# shipping a .desktop file. It is a wrapper around dmenu, so you need that
-# installed.
-# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
-
-# change focus
-bindcode $mod+44 focus left
-bindcode $mod+45 focus down
-bindcode $mod+46 focus up
-bindcode $mod+47 focus right
-
-# alternatively, you can use the cursor keys:
-bindcode $mod+113 focus left
-bindcode $mod+116 focus down
-bindcode $mod+111 focus up
-bindcode $mod+114 focus right
-
-# move focused window
-bindcode $mod+Shift+44 move left
-bindcode $mod+Shift+45 move down
-bindcode $mod+Shift+46 move up
-bindcode $mod+Shift+47 move right
-
-# alternatively, you can use the cursor keys:
-bindcode $mod+Shift+113 move left
-bindcode $mod+Shift+116 move down
-bindcode $mod+Shift+111 move up
-bindcode $mod+Shift+114 move right
-
-# split in horizontal orientation
-bindcode $mod+43 split h
-
-# split in vertical orientation
-bindcode $mod+55 split v
-
-# enter fullscreen mode for the focused container
-bindcode $mod+41 fullscreen toggle
-
-# change container layout (stacked, tabbed, toggle split)
-bindcode $mod+39 layout stacking
-bindcode $mod+25 layout tabbed
-bindcode $mod+26 layout toggle split
-
-# toggle tiling / floating
-bindcode $mod+Shift+65 floating toggle
-
-# change focus between tiling / floating windows
-bindcode $mod+65 focus mode_toggle
-
-# focus the parent container
-bindcode $mod+38 focus parent
-
-# focus the child container
-#bindsym $mod+d focus child
-
-# switch to workspace
-bindcode $mod+10 workspace 1
-bindcode $mod+11 workspace 2
-bindcode $mod+12 workspace 3
-bindcode $mod+13 workspace 4
-bindcode $mod+14 workspace 5
-bindcode $mod+15 workspace 6
-bindcode $mod+16 workspace 7
-bindcode $mod+17 workspace 8
-bindcode $mod+18 workspace 9
-bindcode $mod+19 workspace 10
-
-# move focused container to workspace
-bindcode $mod+Shift+10 move container to workspace 1
-bindcode $mod+Shift+11 move container to workspace 2
-bindcode $mod+Shift+12 move container to workspace 3
-bindcode $mod+Shift+13 move container to workspace 4
-bindcode $mod+Shift+14 move container to workspace 5
-bindcode $mod+Shift+15 move container to workspace 6
-bindcode $mod+Shift+16 move container to workspace 7
-bindcode $mod+Shift+17 move container to workspace 8
-bindcode $mod+Shift+18 move container to workspace 9
-bindcode $mod+Shift+19 move container to workspace 10
-
-# reload the configuration file
-bindcode $mod+Shift+54 reload
-# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
-bindcode $mod+Shift+27 restart
-# exit i3 (logs you out of your X session)
-bindcode $mod+Shift+26 exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
-
-# resize window (you can also use the mouse for that)
-mode "resize" {
-        # These bindings trigger as soon as you enter the resize mode
-
-        # Pressing left will shrink the window’s width.
-        # Pressing right will grow the window’s width.
-        # Pressing up will shrink the window’s height.
-        # Pressing down will grow the window’s height.
-        bindcode 44 resize shrink width 10 px or 10 ppt
-        bindcode 45 resize grow height 10 px or 10 ppt
-        bindcode 46 resize shrink height 10 px or 10 ppt
-        bindcode 47 resize grow width 10 px or 10 ppt
-
-        # same bindings, but for the arrow keys
-        bindcode 113 resize shrink width 10 px or 10 ppt
-        bindcode 116 resize grow height 10 px or 10 ppt
-        bindcode 111 resize shrink height 10 px or 10 ppt
-        bindcode 114 resize grow width 10 px or 10 ppt
-
-        # back to normal: Enter or Escape
-        bindcode 36 mode "default"
-        bindcode 9 mode "default"
-}
-
-bindcode $mod+27 mode "resize"
-
-# Start i3bar to display a workspace bar (plus the system information i3status
-# finds out, if available)
-bar {
-        status_command i3status
-}
diff --git a/i3.xsession.desktop b/i3.xsession.desktop
deleted file mode 100644 (file)
index 11a64e2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Desktop Entry]
-Name=i3
-Comment=improved dynamic tiling window manager
-Exec=i3
-TryExec=i3
-Type=Application
-X-LightDM-DesktopName=i3
-DesktopNames=i3
-Keywords=tiling;wm;windowmanager;window;manager;
diff --git a/i3bar/Makefile b/i3bar/Makefile
deleted file mode 100644 (file)
index cd23cd8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3bar/i3bar
-
-install:
-       $(MAKE) -C .. install-i3bar
-
-clean:
-       $(MAKE) -C .. clean-i3bar
-
-.PHONY: all install clean
diff --git a/i3bar/i3bar.mk b/i3bar/i3bar.mk
deleted file mode 100644 (file)
index 03c607d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-ALL_TARGETS += i3bar/i3bar
-INSTALL_TARGETS += install-i3bar
-CLEAN_TARGETS += clean-i3bar
-
-i3bar_SOURCES := $(wildcard i3bar/src/*.c)
-i3bar_HEADERS := $(wildcard i3bar/include/*.h)
-i3bar_CFLAGS   = $(XCB_CFLAGS) $(XCB_CURSOR_CFLAGS) $(PANGO_CFLAGS) $(XCB_XRM_CFLAGS) $(YAJL_CFLAGS) $(LIBEV_CFLAGS)
-i3bar_LIBS     = $(XCB_LIBS) $(XCB_CURSOR_LIBS) $(PANGO_LIBS) $(XCB_XRM_LIBS) $(YAJL_LIBS) $(LIBEV_LIBS) $(XCB_XKB_LIBS)
-
-i3bar_OBJECTS := $(i3bar_SOURCES:.c=.o)
-
-
-i3bar/src/%.o: i3bar/src/%.c $(i3bar_HEADERS)
-       echo "[i3bar] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3bar_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -Ii3bar/include -c -o $@ $<
-
-i3bar/i3bar: libi3.a $(i3bar_OBJECTS)
-       echo "[i3bar] Link i3bar"
-       $(CC) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3bar_LIBS)
-
-install-i3bar: i3bar/i3bar
-       echo "[i3bar] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -m 0755 i3bar/i3bar $(DESTDIR)$(EXEC_PREFIX)/bin/
-
-clean-i3bar:
-       echo "[i3bar] Clean"
-       rm -f $(i3bar_OBJECTS) i3bar/i3bar
index 873a34651a2a735248a96a549eb29fe327d52b0a..0871c7f49efa563529d22aacd56877d9483885fd 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdbool.h>
 
 #define STDIN_CHUNK_SIZE 1024
index 0d46ab6afa16b96174e46910476c07b3c758b811..0929e4082371ba91a029137d873e0365db1ca602 100644 (file)
@@ -7,6 +7,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdbool.h>
 #include <xcb/xcb.h>
 #include <xcb/xproto.h>
@@ -85,6 +87,6 @@ TAILQ_HEAD(statusline_head, status_block) statusline_head;
 #include "mode.h"
 #include "trayclients.h"
 #include "xcb.h"
-#include "config.h"
+#include "configuration.h"
 #include "libi3.h"
 #include "parse_json_header.h"
diff --git a/i3bar/include/config.h b/i3bar/include/config.h
deleted file mode 100644 (file)
index 2a05904..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * vim:ts=4:sw=4:expandtab
- *
- * i3bar - an xcb-based status- and ws-bar for i3
- * © 2010 Axel Wagner and contributors (see also: LICENSE)
- *
- * config.c: Parses the configuration (received from i3).
- *
- */
-#pragma once
-
-#include "common.h"
-
-typedef enum {
-    POS_NONE = 0,
-    POS_TOP,
-    POS_BOT
-} position_t;
-
-/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
-typedef enum { M_DOCK = 0,
-               M_HIDE = 1,
-               M_INVISIBLE = 2 } bar_display_mode_t;
-
-typedef struct binding_t {
-    int input_code;
-    char *command;
-
-    TAILQ_ENTRY(binding_t) bindings;
-} binding_t;
-
-typedef struct tray_output_t {
-    char *output;
-
-    TAILQ_ENTRY(tray_output_t) tray_outputs;
-} tray_output_t;
-
-typedef struct config_t {
-    int modifier;
-    TAILQ_HEAD(bindings_head, binding_t) bindings;
-    position_t position;
-    int verbose;
-    struct xcb_color_strings_t colors;
-    bool disable_binding_mode_indicator;
-    bool disable_ws;
-    bool strip_ws_numbers;
-    char *bar_id;
-    char *command;
-    char *fontname;
-    i3String *separator_symbol;
-    TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
-    int tray_padding;
-    int num_outputs;
-    char **outputs;
-
-    bar_display_mode_t hide_on_modifier;
-
-    /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
-    enum { S_HIDE = 0,
-           S_SHOW = 1 } hidden_state;
-} config_t;
-
-config_t config;
-
-/**
- * Start parsing the received bar configuration JSON string
- *
- */
-void parse_config_json(char *json);
-
-/**
- * free()s the color strings as soon as they are not needed anymore.
- *
- */
-void free_colors(struct xcb_color_strings_t *colors);
diff --git a/i3bar/include/configuration.h b/i3bar/include/configuration.h
new file mode 100644 (file)
index 0000000..c7c1f5e
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3bar - an xcb-based status- and ws-bar for i3
+ * © 2010 Axel Wagner and contributors (see also: LICENSE)
+ *
+ * config.c: Parses the configuration (received from i3).
+ *
+ */
+#pragma once
+
+#include <config.h>
+
+#include "common.h"
+
+typedef enum {
+    POS_NONE = 0,
+    POS_TOP,
+    POS_BOT
+} position_t;
+
+/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
+typedef enum { M_DOCK = 0,
+               M_HIDE = 1,
+               M_INVISIBLE = 2 } bar_display_mode_t;
+
+typedef struct binding_t {
+    int input_code;
+    char *command;
+
+    TAILQ_ENTRY(binding_t) bindings;
+} binding_t;
+
+typedef struct tray_output_t {
+    char *output;
+
+    TAILQ_ENTRY(tray_output_t) tray_outputs;
+} tray_output_t;
+
+typedef struct config_t {
+    int modifier;
+    TAILQ_HEAD(bindings_head, binding_t) bindings;
+    position_t position;
+    int verbose;
+    struct xcb_color_strings_t colors;
+    bool disable_binding_mode_indicator;
+    bool disable_ws;
+    bool strip_ws_numbers;
+    char *bar_id;
+    char *command;
+    char *fontname;
+    i3String *separator_symbol;
+    TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
+    int tray_padding;
+    int num_outputs;
+    char **outputs;
+
+    bar_display_mode_t hide_on_modifier;
+
+    /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
+    enum { S_HIDE = 0,
+           S_SHOW = 1 } hidden_state;
+} config_t;
+
+config_t config;
+
+/**
+ * Start parsing the received bar configuration JSON string
+ *
+ */
+void parse_config_json(char *json);
+
+/**
+ * free()s the color strings as soon as they are not needed anymore.
+ *
+ */
+void free_colors(struct xcb_color_strings_t *colors);
index 686c0322d31c9bd119f9df6627d44dda557df1e4..5056e5f37454f2c909422f04320d013f7bc3b5f8 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdint.h>
 
 /*
index 828d4906a695033aad2fe8fa2132b1b5a48fbfc1..5c87d904874f6728112d0cf9af4b043292bc9a09 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <xcb/xproto.h>
 
 #include "common.h"
index 63cfca7f12317ae0ed17e3133040e353776f93cd..3067581da0ab4dbd0db9b86d74fdac2c848707f0 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <xcb/xcb.h>
 #include <cairo/cairo-xcb.h>
 
index 41e97de2f994ef24a754148e9f676c12446efd60..d834fe0542e49b7d489edce3ac7830feb0d3f82d 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdint.h>
 
 /**
index dfbfd6bfd3c07f1756e33470e24c1dc506880746..3af79ed779c9704495b7fe400f5dacd482979420 100644 (file)
@@ -7,6 +7,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "queue.h"
 
 /* Get the maximum/minimum of x and y */
index 5ed84de86e426dc3f9f70dd318a3b4d79dbfb9c2..dde8b6e1689c718063c1cd28ddc9fa2208b89256 100644 (file)
@@ -9,10 +9,10 @@
  */
 #pragma once
 
-#include <xcb/xproto.h>
-
 #include "common.h"
 
+#include <xcb/xproto.h>
+
 typedef struct i3_ws i3_ws;
 
 TAILQ_HEAD(ws_head, i3_ws);
index e5af39fa3a14ab3466cad64a6aa12cdd83b8e980..7783e8778575b26e309c8415c1684985d68eb418 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdint.h>
 //#include "outputs.h"
 
index 1b2dc94c289c2d810649f50914005622aeb53c72..60ab462a5a73fba00e62b11e93f79439c86f265b 100644 (file)
@@ -7,6 +7,8 @@
  * child.c: Getting input for the statusline
  *
  */
+#include "common.h"
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -25,8 +27,6 @@
 #include <yajl/yajl_gen.h>
 #include <paths.h>
 
-#include "common.h"
-
 /* Global variables for child_*() */
 i3bar_child child;
 
@@ -105,7 +105,9 @@ __attribute__((format(printf, 1, 2))) static void set_statusline_error(const cha
     char *message;
     va_list args;
     va_start(args, format);
-    (void)vasprintf(&message, format, args);
+    if (vasprintf(&message, format, args) == -1) {
+        return;
+    }
 
     struct status_block *err_block = scalloc(1, sizeof(struct status_block));
     err_block->full_text = i3string_from_utf8("Error: ");
index 5c23bc78647775b4bb532dfcb966054ed1279555..d065ff4ce88ee6effd0d00cbdacfa0cc0afbdb8f 100644 (file)
@@ -7,6 +7,8 @@
  * config.c: Parses the configuration (received from i3).
  *
  */
+#include "common.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -17,8 +19,6 @@
 
 #include <X11/Xlib.h>
 
-#include "common.h"
-
 static char *cur_key;
 static bool parsing_bindings;
 static bool parsing_tray_outputs;
index 3489866301183377627a8d5555abf6d5251634b9..4a090ad794f16fac5339ff03a4401936496753b1 100644 (file)
@@ -7,6 +7,8 @@
  * ipc.c: Communicating with i3
  *
  */
+#include "common.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -21,8 +23,6 @@
 #include <sanitizer/lsan_interface.h>
 #endif
 
-#include "common.h"
-
 ev_io *i3_connection;
 
 const char *sock_path;
index 14e42a2bf425f9ec72a4689905ed0b145e9efc37..be684fc5d1f32b935f994e876dd1a203718bdc37 100644 (file)
@@ -5,6 +5,8 @@
  * © 2010 Axel Wagner and contributors (see also: LICENSE)
  *
  */
+#include "common.h"
+
 #include <stdio.h>
 #include <i3/ipc.h>
 #include <string.h>
@@ -15,8 +17,6 @@
 #include <getopt.h>
 #include <glob.h>
 
-#include "common.h"
-
 /*
  * Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
  *
index 3e52f0b197db9481533ca93410c30b7c6967e9f9..17e7b97eadbde2a1b2742b1556dd8d52b65a741f 100644 (file)
@@ -7,6 +7,8 @@
  * mode.c: Handle mode event and show current binding mode in the bar
  *
  */
+#include "common.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -14,8 +16,6 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 
-#include "common.h"
-
 /* A datatype to pass through the callbacks to save the state */
 struct mode_json_params {
     char *json;
index b53d8cc8517a023d0a8dfe6a17e9c4fe8615ab71..480c00be7dd90a1b9e500b3074e87888da64bcbc 100644 (file)
@@ -7,6 +7,8 @@
  * outputs.c: Maintaining the outputs list
  *
  */
+#include "common.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -15,8 +17,6 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 
-#include "common.h"
-
 /* A datatype to pass through the callbacks to save the state */
 struct outputs_json_params {
     struct outputs_head *outputs;
index 1cd951065c8e379f123d08671b12c769e8468e8f..3d4c2a67f2490652129d361197eeb7535e3849ed 100644 (file)
@@ -8,6 +8,8 @@
  *                      protocol version and features.
  *
  */
+#include "common.h"
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -25,8 +27,6 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 
-#include "common.h"
-
 static enum {
     KEY_VERSION,
     KEY_STOP_SIGNAL,
index 1187a946c3e0a81ec98a8ff8d1d6203995b8753b..233249893ecf10fc96e3d598d9cee64779b0837b 100644 (file)
@@ -7,6 +7,8 @@
  * workspaces.c: Maintaining the workspace lists
  *
  */
+#include "common.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -14,8 +16,6 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 
-#include "common.h"
-
 /* A datatype to pass through the callbacks to save the state */
 struct workspaces_json_params {
     struct ws_head *workspaces;
index 321874459579cbb7dff3d8ff871a9d40b7119d74..2715e44711cb327be871f07ec4653070a351b917 100644 (file)
@@ -7,6 +7,8 @@
  * xcb.c: Communicating with X
  *
  */
+#include "common.h"
+
 #include <xcb/xcb.h>
 #include <xcb/xkb.h>
 #include <xcb/xproto.h>
@@ -32,7 +34,6 @@
 #include <sanitizer/lsan_interface.h>
 #endif
 
-#include "common.h"
 #include "libi3.h"
 
 /** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
index e39e27b9fdf308b23ce659fd727e4ef9e31bb689..c26835b90ff07e6de3742175fbd9052a7551388e 100644 (file)
@@ -10,8 +10,9 @@
  * compile-time.
  *
  */
-#ifndef I3_ALL_H
-#define I3_ALL_H
+#pragma once
+
+#include <config.h>
 
 #include <assert.h>
 #include <stdbool.h>
@@ -51,7 +52,7 @@
 #include "click.h"
 #include "key_press.h"
 #include "floating.h"
-#include "config.h"
+#include "configuration.h"
 #include "handlers.h"
 #include "randr.h"
 #include "xinerama.h"
@@ -81,5 +82,3 @@
 #include "display_version.h"
 #include "restore_layout.h"
 #include "main.h"
-
-#endif
index 22ebafc345a4a38cf7a54921ef83b1157d46a63d..a4dc766b5e96e59b7be80a5799b58e9b7a1dab96 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Checks the list of assignments for the given window and runs all matching
  * ones (unless they have already been run for this specific window).
index d15598ea7cab863fa54ccaa28e4c2dbdb56d91e5..0fcc4df4c94f390d43648503c65fd27c95b1e303 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 extern pid_t command_error_nagbar_pid;
 
 /**
index 7ce80d97abcbf50f8edb998e31ce161943c38ed3..0d57abf7f6f7dbd3e2ce830461b0a53fd5f31b4f 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * The button press X callback. This function determines whether the floating
  * modifier is pressed and where the user clicked (decoration, border, inside
index 2ffa49b011e1b47043dd75bd03a8888f2e6c7e14..a2cbb17eafc54686664611b68f2f6556f4c76d1f 100644 (file)
@@ -9,4 +9,6 @@
  */
 #pragma once
 
+#include <config.h>
+
 char *parse_cmd(const char *new);
index 9f83cb218c56c239d85768db461a3288a966bd43..a57b2925e1cee52dd451ff1927ed7dd6db578f28 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "commands_parser.h"
 
 /** The beginning of the prototype for every cmd_ function. */
index 1acb7faebe791f999db86166b209dfe9b80636a5..88b3f6d09c6540972b701907fea56dcf071f8642 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <yajl/yajl_gen.h>
 
 /*
index 73ae0f38db239e4a84001a262abfc91a0c4e3aff..0c532207ba021d78427691e290fa376ba278ad90 100644 (file)
@@ -11,6 +11,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Create a new container (and attach it to the given parent, if not NULL).
  * This function only initializes the data structures.
diff --git a/include/config.h b/include/config.h
deleted file mode 100644 (file)
index 699cc88..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * vim:ts=4:sw=4:expandtab
- *
- * i3 - an improved dynamic tiling window manager
- * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
- *
- * include/config.h: Contains all structs/variables for the configurable
- * part of i3 as well as functions handling the configuration file (calling
- * the parser (src/config_parse.c) with the correct path, switching key
- * bindings mode).
- *
- */
-#pragma once
-
-#include <stdbool.h>
-#include "queue.h"
-#include "i3.h"
-#include "libi3.h"
-
-typedef struct Config Config;
-typedef struct Barconfig Barconfig;
-extern char *current_configpath;
-extern Config config;
-extern SLIST_HEAD(modes_head, Mode) modes;
-extern TAILQ_HEAD(barconfig_head, Barconfig) barconfigs;
-
-/**
- * Used during the config file lexing/parsing to keep the state of the lexer
- * in order to provide useful error messages in yyerror().
- *
- */
-struct context {
-    bool has_errors;
-    bool has_warnings;
-
-    int line_number;
-    char *line_copy;
-    const char *filename;
-
-    char *compact_error;
-
-    /* These are the same as in YYLTYPE */
-    int first_column;
-    int last_column;
-};
-
-/**
- * Part of the struct Config. It makes sense to group colors for background,
- * border and text as every element in i3 has them (window decorations, bar).
- *
- */
-struct Colortriple {
-    color_t border;
-    color_t background;
-    color_t text;
-    color_t indicator;
-    color_t child_border;
-};
-
-/**
- * Holds a user-assigned variable for parsing the configuration file. The key
- * is replaced by value in every following line of the file.
- *
- */
-struct Variable {
-    char *key;
-    char *value;
-    char *next_match;
-
-    SLIST_ENTRY(Variable) variables;
-};
-
-/**
- * The configuration file can contain multiple sets of bindings. Apart from the
- * default set (name == "default"), you can specify other sets and change the
- * currently active set of bindings by using the "mode <name>" command.
- *
- */
-struct Mode {
-    char *name;
-    bool pango_markup;
-    struct bindings_head *bindings;
-
-    SLIST_ENTRY(Mode) modes;
-};
-
-/**
- * Holds part of the configuration (the part which is not already in dedicated
- * structures in include/data.h).
- *
- */
-struct Config {
-    const char *terminal;
-    i3Font font;
-
-    char *ipc_socket_path;
-    char *restart_state_path;
-
-    layout_t default_layout;
-    int container_stack_limit;
-    int container_stack_limit_value;
-    int default_border_width;
-    int default_floating_border_width;
-
-    /** Default orientation for new containers */
-    int default_orientation;
-
-    /** By default, focus follows mouse. If the user explicitly wants to
-     * turn this off (and instead rely only on the keyboard for changing
-     * focus), we allow them to do this with this relatively special option.
-     * It is not planned to add any different focus models. */
-    bool disable_focus_follows_mouse;
-
-    /** By default, when switching focus to a window on a different output
-     * (e.g. focusing a window on workspace 3 on output VGA-1, coming from
-     * workspace 2 on LVDS-1), the mouse cursor is warped to the center of
-     * that window.
-     *
-     * With the mouse_warping option, you can control when the mouse cursor
-     * should be warped. "none" disables warping entirely, whereas "output"
-     * is the default behavior described above. */
-    warping_t mouse_warping;
-
-    /** Remove borders if they are adjacent to the screen edge.
-     * This is useful if you are reaching scrollbar on the edge of the
-     * screen or do not want to waste a single pixel of displayspace.
-     * By default, this is disabled. */
-    hide_edge_borders_mode_t hide_edge_borders;
-
-    /** By default, a workspace bar is drawn at the bottom of the screen.
-     * If you want to have a more fancy bar, it is recommended to replace
-     * the whole bar by dzen2, for example using the i3-wsbar script which
-     * comes with i3. Thus, you can turn it off entirely. */
-    bool disable_workspace_bar;
-
-    /** Think of the following layout: Horizontal workspace with a tabbed
-     * con on the left of the screen and a terminal on the right of the
-     * screen. You are in the second container in the tabbed container and
-     * focus to the right. By default, i3 will set focus to the terminal on
-     * the right. If you are in the first container in the tabbed container
-     * however, focusing to the left will wrap. This option forces i3 to
-     * always wrap, which will result in you having to use "focus parent"
-     * more often. */
-    bool force_focus_wrapping;
-
-    /** By default, use the RandR API for multi-monitor setups.
-     * Unfortunately, the nVidia binary graphics driver doesn't support
-     * this API. Instead, it only support the less powerful Xinerama API,
-     * which can be enabled by this option.
-     *
-     * Note: this option takes only effect on the initial startup (eg.
-     * reconfiguration is not possible). On startup, the list of screens
-     * is fetched once and never updated. */
-    bool force_xinerama;
-
-    /** Overwrites output detection (for testing), see src/fake_outputs.c */
-    char *fake_outputs;
-
-    /** Automatic workspace back and forth switching. If this is set, a
-     * switch to the currently active workspace will switch to the
-     * previously focused one instead, making it possible to fast toggle
-     * between two workspaces. */
-    bool workspace_auto_back_and_forth;
-
-    /** By default, urgency is cleared immediately when switching to another
-     * workspace leads to focusing the con with the urgency hint. When having
-     * multiple windows on that workspace, the user needs to guess which
-     * application raised the event. To prevent this, the reset of the urgency
-     * flag can be delayed using an urgency timer. */
-    float workspace_urgency_timer;
-
-    /** Behavior when a window sends a NET_ACTIVE_WINDOW message. */
-    enum {
-        /* Focus if the target workspace is visible, set urgency hint otherwise. */
-        FOWA_SMART,
-        /* Always set the urgency hint. */
-        FOWA_URGENT,
-        /* Always focus the window. */
-        FOWA_FOCUS,
-        /* Ignore the request (no focus, no urgency hint). */
-        FOWA_NONE
-    } focus_on_window_activation;
-
-    /** Specifies whether or not marks should be displayed in the window
-     * decoration. Marks starting with a "_" will be ignored either way. */
-    bool show_marks;
-
-    /** The default border style for new windows. */
-    border_style_t default_border;
-
-    /** The default border style for new floating windows. */
-    border_style_t default_floating_border;
-
-    /** The modifier which needs to be pressed in combination with your mouse
-     * buttons to do things with floating windows (move, resize) */
-    uint32_t floating_modifier;
-
-    /** Maximum and minimum dimensions of a floating window */
-    int32_t floating_maximum_width;
-    int32_t floating_maximum_height;
-    int32_t floating_minimum_width;
-    int32_t floating_minimum_height;
-
-    /* Color codes are stored here */
-    struct config_client {
-        color_t background;
-        struct Colortriple focused;
-        struct Colortriple focused_inactive;
-        struct Colortriple unfocused;
-        struct Colortriple urgent;
-        struct Colortriple placeholder;
-    } client;
-    struct config_bar {
-        struct Colortriple focused;
-        struct Colortriple unfocused;
-        struct Colortriple urgent;
-    } bar;
-
-    /** What should happen when a new popup is opened during fullscreen mode */
-    enum {
-        /* display (and focus) the popup when it belongs to the fullscreen
-         * window only. */
-        PDF_SMART = 0,
-
-        /* leave fullscreen mode unconditionally */
-        PDF_LEAVE_FULLSCREEN = 1,
-
-        /* just ignore the popup, that is, don’t map it */
-        PDF_IGNORE = 2,
-    } popup_during_fullscreen;
-
-    /* The number of currently parsed barconfigs */
-    int number_barconfigs;
-};
-
-/**
- * Holds the status bar configuration (i3bar). One of these structures is
- * created for each 'bar' block in the config.
- *
- */
-struct Barconfig {
-    /** Automatically generated ID for this bar config. Used by the bar process
-     * to request a specific configuration. */
-    char *id;
-
-    /** Number of outputs in the outputs array */
-    int num_outputs;
-    /** Outputs on which this bar should show up on. We use an array for
-     * simplicity (since we store just strings). */
-    char **outputs;
-
-    /* List of outputs on which the tray is allowed to be shown, in order.
-     * The special value "none" disables it (per default, it will be shown) and
-     * the special value "primary" enabled it on the primary output. */
-    TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
-
-    /* Padding around the tray icons. */
-    int tray_padding;
-
-    /** Path to the i3 IPC socket. This option is discouraged since programs
-     * can find out the path by looking for the I3_SOCKET_PATH property on the
-     * root window! */
-    char *socket_path;
-
-    /** Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
-    enum { M_DOCK = 0,
-           M_HIDE = 1,
-           M_INVISIBLE = 2 } mode;
-
-    /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
-    enum { S_HIDE = 0,
-           S_SHOW = 1 } hidden_state;
-
-    /** Bar modifier (to show bar when in hide mode). */
-    enum {
-        M_NONE = 0,
-        M_CONTROL = 1,
-        M_SHIFT = 2,
-        M_MOD1 = 3,
-        M_MOD2 = 4,
-        M_MOD3 = 5,
-        M_MOD4 = 6,
-        M_MOD5 = 7
-    } modifier;
-
-    TAILQ_HEAD(bar_bindings_head, Barbinding) bar_bindings;
-
-    /** Bar position (bottom by default). */
-    enum { P_BOTTOM = 0,
-           P_TOP = 1 } position;
-
-    /** Command that should be run to execute i3bar, give a full path if i3bar is not
-     * in your $PATH.
-     * By default just 'i3bar' is executed. */
-    char *i3bar_command;
-
-    /** Command that should be run to get a statusline, for example 'i3status'.
-     * Will be passed to the shell. */
-    char *status_command;
-
-    /** Font specification for all text rendered on the bar. */
-    char *font;
-
-    /** A custom separator to use instead of a vertical line. */
-    char *separator_symbol;
-
-    /** Hide workspace buttons? Configuration option is 'workspace_buttons no'
-     * but we invert the bool to get the correct default when initializing with
-     * zero. */
-    bool hide_workspace_buttons;
-
-    /** Strip workspace numbers? Configuration option is
-     * 'strip_workspace_numbers yes'. */
-    bool strip_workspace_numbers;
-
-    /** Hide mode button? Configuration option is 'binding_mode_indicator no'
-     * but we invert the bool for the same reason as hide_workspace_buttons.*/
-    bool hide_binding_mode_indicator;
-
-    /** Enable verbose mode? Useful for debugging purposes. */
-    bool verbose;
-
-    struct bar_colors {
-        char *background;
-        char *statusline;
-        char *separator;
-
-        char *focused_background;
-        char *focused_statusline;
-        char *focused_separator;
-
-        char *focused_workspace_border;
-        char *focused_workspace_bg;
-        char *focused_workspace_text;
-
-        char *active_workspace_border;
-        char *active_workspace_bg;
-        char *active_workspace_text;
-
-        char *inactive_workspace_border;
-        char *inactive_workspace_bg;
-        char *inactive_workspace_text;
-
-        char *urgent_workspace_border;
-        char *urgent_workspace_bg;
-        char *urgent_workspace_text;
-
-        char *binding_mode_border;
-        char *binding_mode_bg;
-        char *binding_mode_text;
-    } colors;
-
-    TAILQ_ENTRY(Barconfig) configs;
-};
-
-/**
- * Defines a mouse command to be executed instead of the default behavior when
- * clicking on the non-statusline part of i3bar.
- *
- */
-struct Barbinding {
-    /** The button to be used (e.g., 1 for "button1"). */
-    int input_code;
-
-    /** The command which is to be executed for this button. */
-    char *command;
-
-    TAILQ_ENTRY(Barbinding) bindings;
-};
-
-struct tray_output_t {
-    char *output;
-
-    TAILQ_ENTRY(tray_output_t) tray_outputs;
-};
-
-/**
- * Finds the configuration file to use (either the one specified by
- * override_configpath), the user’s one or the system default) and calls
- * parse_file().
- *
- * If you specify override_configpath, only this path is used to look for a
- * configuration file.
- *
- * If use_nagbar is false, don't try to start i3-nagbar but log the errors to
- * stdout/stderr instead.
- *
- */
-bool parse_configuration(const char *override_configpath, bool use_nagbar);
-
-/**
- * Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
- *
- * If you specify override_configpath, only this path is used to look for a
- * configuration file.
- *
- */
-void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
-
-/**
- * Ungrabs all keys, to be called before re-grabbing the keys because of a
- * mapping_notify event or a configuration file reload
- *
- */
-void ungrab_all_keys(xcb_connection_t *conn);
-
-/**
- * Sends the current bar configuration as an event to all barconfig_update listeners.
- *
- */
-void update_barconfig();
-
-/**
- * Kills the configerror i3-nagbar process, if any.
- *
- * Called when reloading/restarting.
- *
- * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
- * ev is assumed to handle it (reloading).
- *
- */
-void kill_configerror_nagbar(bool wait_for_it);
index bcbea111572094c56e8337729424d955b209e8e4..7f1bfe4a091e9613d5d21f0fa186da759107e87e 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "config_parser.h"
 
 /**
index 2ba79a68b8fa0f338a70b7f0919061f77fe839e1..ace4041dd2ab2e4169b838330e5ef54f690ce0ce 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <yajl/yajl_gen.h>
 
 SLIST_HEAD(variables_head, Variable);
diff --git a/include/configuration.h b/include/configuration.h
new file mode 100644 (file)
index 0000000..b7cdc80
--- /dev/null
@@ -0,0 +1,423 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ * include/configuration.h: Contains all structs/variables for the configurable
+ * part of i3 as well as functions handling the configuration file (calling
+ * the parser (src/config_parse.c) with the correct path, switching key
+ * bindings mode).
+ *
+ */
+#pragma once
+
+#include "libi3.h"
+
+#include <stdbool.h>
+#include "queue.h"
+#include "i3.h"
+
+typedef struct Config Config;
+typedef struct Barconfig Barconfig;
+extern char *current_configpath;
+extern Config config;
+extern SLIST_HEAD(modes_head, Mode) modes;
+extern TAILQ_HEAD(barconfig_head, Barconfig) barconfigs;
+
+/**
+ * Used during the config file lexing/parsing to keep the state of the lexer
+ * in order to provide useful error messages in yyerror().
+ *
+ */
+struct context {
+    bool has_errors;
+    bool has_warnings;
+
+    int line_number;
+    char *line_copy;
+    const char *filename;
+
+    char *compact_error;
+
+    /* These are the same as in YYLTYPE */
+    int first_column;
+    int last_column;
+};
+
+/**
+ * Part of the struct Config. It makes sense to group colors for background,
+ * border and text as every element in i3 has them (window decorations, bar).
+ *
+ */
+struct Colortriple {
+    color_t border;
+    color_t background;
+    color_t text;
+    color_t indicator;
+    color_t child_border;
+};
+
+/**
+ * Holds a user-assigned variable for parsing the configuration file. The key
+ * is replaced by value in every following line of the file.
+ *
+ */
+struct Variable {
+    char *key;
+    char *value;
+    char *next_match;
+
+    SLIST_ENTRY(Variable) variables;
+};
+
+/**
+ * The configuration file can contain multiple sets of bindings. Apart from the
+ * default set (name == "default"), you can specify other sets and change the
+ * currently active set of bindings by using the "mode <name>" command.
+ *
+ */
+struct Mode {
+    char *name;
+    bool pango_markup;
+    struct bindings_head *bindings;
+
+    SLIST_ENTRY(Mode) modes;
+};
+
+/**
+ * Holds part of the configuration (the part which is not already in dedicated
+ * structures in include/data.h).
+ *
+ */
+struct Config {
+    const char *terminal;
+    i3Font font;
+
+    char *ipc_socket_path;
+    char *restart_state_path;
+
+    layout_t default_layout;
+    int container_stack_limit;
+    int container_stack_limit_value;
+    int default_border_width;
+    int default_floating_border_width;
+
+    /** Default orientation for new containers */
+    int default_orientation;
+
+    /** By default, focus follows mouse. If the user explicitly wants to
+     * turn this off (and instead rely only on the keyboard for changing
+     * focus), we allow them to do this with this relatively special option.
+     * It is not planned to add any different focus models. */
+    bool disable_focus_follows_mouse;
+
+    /** By default, when switching focus to a window on a different output
+     * (e.g. focusing a window on workspace 3 on output VGA-1, coming from
+     * workspace 2 on LVDS-1), the mouse cursor is warped to the center of
+     * that window.
+     *
+     * With the mouse_warping option, you can control when the mouse cursor
+     * should be warped. "none" disables warping entirely, whereas "output"
+     * is the default behavior described above. */
+    warping_t mouse_warping;
+
+    /** Remove borders if they are adjacent to the screen edge.
+     * This is useful if you are reaching scrollbar on the edge of the
+     * screen or do not want to waste a single pixel of displayspace.
+     * By default, this is disabled. */
+    hide_edge_borders_mode_t hide_edge_borders;
+
+    /** By default, a workspace bar is drawn at the bottom of the screen.
+     * If you want to have a more fancy bar, it is recommended to replace
+     * the whole bar by dzen2, for example using the i3-wsbar script which
+     * comes with i3. Thus, you can turn it off entirely. */
+    bool disable_workspace_bar;
+
+    /** Think of the following layout: Horizontal workspace with a tabbed
+     * con on the left of the screen and a terminal on the right of the
+     * screen. You are in the second container in the tabbed container and
+     * focus to the right. By default, i3 will set focus to the terminal on
+     * the right. If you are in the first container in the tabbed container
+     * however, focusing to the left will wrap. This option forces i3 to
+     * always wrap, which will result in you having to use "focus parent"
+     * more often. */
+    bool force_focus_wrapping;
+
+    /** By default, use the RandR API for multi-monitor setups.
+     * Unfortunately, the nVidia binary graphics driver doesn't support
+     * this API. Instead, it only support the less powerful Xinerama API,
+     * which can be enabled by this option.
+     *
+     * Note: this option takes only effect on the initial startup (eg.
+     * reconfiguration is not possible). On startup, the list of screens
+     * is fetched once and never updated. */
+    bool force_xinerama;
+
+    /** Overwrites output detection (for testing), see src/fake_outputs.c */
+    char *fake_outputs;
+
+    /** Automatic workspace back and forth switching. If this is set, a
+     * switch to the currently active workspace will switch to the
+     * previously focused one instead, making it possible to fast toggle
+     * between two workspaces. */
+    bool workspace_auto_back_and_forth;
+
+    /** By default, urgency is cleared immediately when switching to another
+     * workspace leads to focusing the con with the urgency hint. When having
+     * multiple windows on that workspace, the user needs to guess which
+     * application raised the event. To prevent this, the reset of the urgency
+     * flag can be delayed using an urgency timer. */
+    float workspace_urgency_timer;
+
+    /** Behavior when a window sends a NET_ACTIVE_WINDOW message. */
+    enum {
+        /* Focus if the target workspace is visible, set urgency hint otherwise. */
+        FOWA_SMART,
+        /* Always set the urgency hint. */
+        FOWA_URGENT,
+        /* Always focus the window. */
+        FOWA_FOCUS,
+        /* Ignore the request (no focus, no urgency hint). */
+        FOWA_NONE
+    } focus_on_window_activation;
+
+    /** Specifies whether or not marks should be displayed in the window
+     * decoration. Marks starting with a "_" will be ignored either way. */
+    bool show_marks;
+
+    /** The default border style for new windows. */
+    border_style_t default_border;
+
+    /** The default border style for new floating windows. */
+    border_style_t default_floating_border;
+
+    /** The modifier which needs to be pressed in combination with your mouse
+     * buttons to do things with floating windows (move, resize) */
+    uint32_t floating_modifier;
+
+    /** Maximum and minimum dimensions of a floating window */
+    int32_t floating_maximum_width;
+    int32_t floating_maximum_height;
+    int32_t floating_minimum_width;
+    int32_t floating_minimum_height;
+
+    /* Color codes are stored here */
+    struct config_client {
+        color_t background;
+        struct Colortriple focused;
+        struct Colortriple focused_inactive;
+        struct Colortriple unfocused;
+        struct Colortriple urgent;
+        struct Colortriple placeholder;
+    } client;
+    struct config_bar {
+        struct Colortriple focused;
+        struct Colortriple unfocused;
+        struct Colortriple urgent;
+    } bar;
+
+    /** What should happen when a new popup is opened during fullscreen mode */
+    enum {
+        /* display (and focus) the popup when it belongs to the fullscreen
+         * window only. */
+        PDF_SMART = 0,
+
+        /* leave fullscreen mode unconditionally */
+        PDF_LEAVE_FULLSCREEN = 1,
+
+        /* just ignore the popup, that is, don’t map it */
+        PDF_IGNORE = 2,
+    } popup_during_fullscreen;
+
+    /* The number of currently parsed barconfigs */
+    int number_barconfigs;
+};
+
+/**
+ * Holds the status bar configuration (i3bar). One of these structures is
+ * created for each 'bar' block in the config.
+ *
+ */
+struct Barconfig {
+    /** Automatically generated ID for this bar config. Used by the bar process
+     * to request a specific configuration. */
+    char *id;
+
+    /** Number of outputs in the outputs array */
+    int num_outputs;
+    /** Outputs on which this bar should show up on. We use an array for
+     * simplicity (since we store just strings). */
+    char **outputs;
+
+    /* List of outputs on which the tray is allowed to be shown, in order.
+     * The special value "none" disables it (per default, it will be shown) and
+     * the special value "primary" enabled it on the primary output. */
+    TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
+
+    /* Padding around the tray icons. */
+    int tray_padding;
+
+    /** Path to the i3 IPC socket. This option is discouraged since programs
+     * can find out the path by looking for the I3_SOCKET_PATH property on the
+     * root window! */
+    char *socket_path;
+
+    /** Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
+    enum { M_DOCK = 0,
+           M_HIDE = 1,
+           M_INVISIBLE = 2 } mode;
+
+    /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
+    enum { S_HIDE = 0,
+           S_SHOW = 1 } hidden_state;
+
+    /** Bar modifier (to show bar when in hide mode). */
+    enum {
+        M_NONE = 0,
+        M_CONTROL = 1,
+        M_SHIFT = 2,
+        M_MOD1 = 3,
+        M_MOD2 = 4,
+        M_MOD3 = 5,
+        M_MOD4 = 6,
+        M_MOD5 = 7
+    } modifier;
+
+    TAILQ_HEAD(bar_bindings_head, Barbinding) bar_bindings;
+
+    /** Bar position (bottom by default). */
+    enum { P_BOTTOM = 0,
+           P_TOP = 1 } position;
+
+    /** Command that should be run to execute i3bar, give a full path if i3bar is not
+     * in your $PATH.
+     * By default just 'i3bar' is executed. */
+    char *i3bar_command;
+
+    /** Command that should be run to get a statusline, for example 'i3status'.
+     * Will be passed to the shell. */
+    char *status_command;
+
+    /** Font specification for all text rendered on the bar. */
+    char *font;
+
+    /** A custom separator to use instead of a vertical line. */
+    char *separator_symbol;
+
+    /** Hide workspace buttons? Configuration option is 'workspace_buttons no'
+     * but we invert the bool to get the correct default when initializing with
+     * zero. */
+    bool hide_workspace_buttons;
+
+    /** Strip workspace numbers? Configuration option is
+     * 'strip_workspace_numbers yes'. */
+    bool strip_workspace_numbers;
+
+    /** Hide mode button? Configuration option is 'binding_mode_indicator no'
+     * but we invert the bool for the same reason as hide_workspace_buttons.*/
+    bool hide_binding_mode_indicator;
+
+    /** Enable verbose mode? Useful for debugging purposes. */
+    bool verbose;
+
+    struct bar_colors {
+        char *background;
+        char *statusline;
+        char *separator;
+
+        char *focused_background;
+        char *focused_statusline;
+        char *focused_separator;
+
+        char *focused_workspace_border;
+        char *focused_workspace_bg;
+        char *focused_workspace_text;
+
+        char *active_workspace_border;
+        char *active_workspace_bg;
+        char *active_workspace_text;
+
+        char *inactive_workspace_border;
+        char *inactive_workspace_bg;
+        char *inactive_workspace_text;
+
+        char *urgent_workspace_border;
+        char *urgent_workspace_bg;
+        char *urgent_workspace_text;
+
+        char *binding_mode_border;
+        char *binding_mode_bg;
+        char *binding_mode_text;
+    } colors;
+
+    TAILQ_ENTRY(Barconfig) configs;
+};
+
+/**
+ * Defines a mouse command to be executed instead of the default behavior when
+ * clicking on the non-statusline part of i3bar.
+ *
+ */
+struct Barbinding {
+    /** The button to be used (e.g., 1 for "button1"). */
+    int input_code;
+
+    /** The command which is to be executed for this button. */
+    char *command;
+
+    TAILQ_ENTRY(Barbinding) bindings;
+};
+
+struct tray_output_t {
+    char *output;
+
+    TAILQ_ENTRY(tray_output_t) tray_outputs;
+};
+
+/**
+ * Finds the configuration file to use (either the one specified by
+ * override_configpath), the user’s one or the system default) and calls
+ * parse_file().
+ *
+ * If you specify override_configpath, only this path is used to look for a
+ * configuration file.
+ *
+ * If use_nagbar is false, don't try to start i3-nagbar but log the errors to
+ * stdout/stderr instead.
+ *
+ */
+bool parse_configuration(const char *override_configpath, bool use_nagbar);
+
+/**
+ * Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
+ *
+ * If you specify override_configpath, only this path is used to look for a
+ * configuration file.
+ *
+ */
+void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
+
+/**
+ * Ungrabs all keys, to be called before re-grabbing the keys because of a
+ * mapping_notify event or a configuration file reload
+ *
+ */
+void ungrab_all_keys(xcb_connection_t *conn);
+
+/**
+ * Sends the current bar configuration as an event to all barconfig_update listeners.
+ *
+ */
+void update_barconfig();
+
+/**
+ * Kills the configerror i3-nagbar process, if any.
+ *
+ * Called when reloading/restarting.
+ *
+ * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
+ * ev is assumed to handle it (reloading).
+ *
+ */
+void kill_configerror_nagbar(bool wait_for_it);
index 70edd2223da2206a801dbf837985ad8d9002fd43..a729b21ed8ac00d97063df55fa39dad63e68ce54 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include "libi3.h"
+
 #define SN_API_NOT_YET_FROZEN 1
 #include <libsn/sn-launcher.h>
 
@@ -17,7 +19,6 @@
 #include <pcre.h>
 #include <sys/time.h>
 
-#include "libi3.h"
 #include "queue.h"
 
 /*
index 3875ec6bbdc8d482d71cfad6944858655cae4559..ab5f38081f265467d1e33d2109c6cbd116b93b21 100644 (file)
@@ -10,4 +10,6 @@
  */
 #pragma once
 
+#include <config.h>
+
 int handle_event(void *ignored, xcb_connection_t *c, xcb_generic_event_t *e);
index b1a5a0e0f3176ccaed3ef222669717164744be57..d8dac30b8d5ea6b5d53327d5c4c0a4b9b66df762 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Connects to i3 to find out the currently running version. Useful since it
  * might be different from the version compiled into this binary (maybe the
index 2a55ab9fb4ba738b179e14a9b4414f836547b0a8..545e3a6bec081751ef42970eaefcae9cfa252cec 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Updates _NET_CURRENT_DESKTOP with the current desktop number.
  *
index 32b07fa97e30be5bf3dcaeb819ec92417a8ce558..27a0d41a15e87781779aeee5d0f3c8994c361551 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Creates outputs according to the given specification.
  * The specification must be in the format wxh+x+y, for example 1024x768+0+0,
index e187b98f7c257ebe2209f2c7cffdf1b244d052fc..babfafc9a583f3321dbe32c4394b9d4ca8e22070 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "tree.h"
 
 /** Callback for dragging */
index d80a24f8fdbbda1d1dc7fd98bee473cc562f3a90..1d5a386522bcbe229c1de411ecf7b5ceab4d5fe8 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <xcb/randr.h>
 
 extern int randr_base;
index 254c4d23358bafb62fcc566e91acb66256ebc3c9..4d13d448f1395fdd97e13e82a477178e28ee4ea0 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <sys/time.h>
 #include <sys/resource.h>
 
index e1c18816715e1fccddc199a19f736ed184e1b6e2..5c528a6def35dddb244192eb319670fc867bf6f4 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <ev.h>
 #include <stdbool.h>
 #include <yajl/yajl_gen.h>
@@ -16,7 +18,7 @@
 
 #include "data.h"
 #include "tree.h"
-#include "config.h"
+#include "configuration.h"
 
 #include "i3/ipc.h"
 
index bbfec83b4808d725451820e492d1896807963324..8f23854b0b34d6d9787c355bb8965befe625fbca 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * There was a key press. We compare this key code with our bindings table and pass
  * the bound action to parse_command().
index 5123ce01db6b151b86315fbc13a739e30293b206..11ca31273b828cbf38036e8358421040da64a1db 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdbool.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -89,7 +91,7 @@ void errorlog(char *fmt, ...)
 #if !defined(DLOG)
 void debuglog(char *fmt, ...)
     __attribute__((format(printf, 1, 2)));
-#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, STRIPPED__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
 #endif
 
 /**
index f8b7da20a6f7ac58144f8cc53e0a891351a015bc..0dd8131842ba2adb3f75f7b11a5151e6c41d406a 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 typedef enum {
     // We could not determine the content of the JSON file. This typically
     // means it’s unreadable or contains garbage.
index e7fc8acba1341c182078a83a9657f789d0354ef8..5c530231de76f08925e6457b1c6151da83ac82ee 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdarg.h>
 #include <stdbool.h>
 
@@ -27,7 +29,7 @@
    is, delete the preceding comma */
 #define LOG(fmt, ...) verboselog(fmt, ##__VA_ARGS__)
 #define ELOG(fmt, ...) errorlog("ERROR: " fmt, ##__VA_ARGS__)
-#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, STRIPPED__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
 
 extern char *errorfilename;
 extern char *shmlogname;
index 1ce539540be033a0eadbf3c5fd1c00fa09311a79..1f213ccee6b8d55334df4b7ecd8978e6b954b8d9 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Enable or disable the main X11 event handling function.
  * This is used by drag_pointer() which has its own, modal event handler, which
index 520f0c0666ddd835e17a516de6f79a70b8c72254..55b0a85b9a8d78d331c27cb796cee3f0284f71a6 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "data.h"
 
 /**
index 64a4f22bd8b4e5174d87ad228c228587970389f8..4ff8c485bbed18fd45a27e290b7a40368f382882 100644 (file)
@@ -13,6 +13,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /*
  * Initializes the Match data structure. This function is necessary because the
  * members representing boolean values (like dock) need to be initialized with
index 7debcf28e397c8b06877853de7f9e9cff51ed9ba..64b12b80cc7b937c8c2773989fa312a41b43adda 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Moves the given container in the given direction (TOK_LEFT, TOK_RIGHT,
  * TOK_UP, TOK_DOWN from cmdparse.l)
index 03a4fbcf28c75d5ebb8c444d96047645306ab908..b13c97283ff840cf5bc4eb7509118ef2d45565ea 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Returns the output container below the given output container.
  *
index 30dd955dabeafafee2453851786d95b9fa9d2b5e..55068316607e5e660b4b9e209280608f6a00ca5c 100644 (file)
@@ -11,6 +11,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "data.h"
 #include <xcb/randr.h>
 
index 2e2f22fd45f142e87af6079f1d2d9afbb00cdaad..abda3cd7f4370758d9909c79ade589d5da253d21 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Creates a new 'regex' struct containing the given pattern and a PCRE
  * compiled regular expression. Also, calls pcre_study because this regex will
index d32f0310cdd18d74597ca23bbf910c6d9534dbc0..750b7d310317901155a626656517db9102afedde 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /* This is used to keep a state to pass around when rendering a con in render_con(). */
 typedef struct render_params {
     /* A copy of the coordinates of the container which is being rendered. */
index 945678d98b6d518c31e2ab597d7e2bcc35255645..7b33de907fb397d8348bb70d1ee23558c9781271 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction);
 
 int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event);
index f952834c564939c557752e11f813effc5f32e5dc..98b257d90f83af099c9d5e18458735fa175bc8d1 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Opens a separate connection to X11 for placeholder windows when restoring
  * layouts. This is done as a safety measure (users can xkill a placeholder
index b385550cdbaf144274d3e4557445e9eaa9a550e2..241653c0dda82024aa9eb13651e6a1fad5f66216 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Moves the specified window to the __i3_scratch workspace, making it floating
  * and setting the appropriate scratchpad_state.
index 0216c8d66555e47f93166b8e2290dafef0273f10..b90211ef1a9ca5a612e71a3028eb65f984fb77ab 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <stdint.h>
 #if !defined(__OpenBSD__)
 #include <pthread.h>
index 56680bc48a2aaa84e3b252517ff415c2eb7ad5ce..20ede4eb95ee90538ec7295f40e97a0ffa99ffc0 100644 (file)
@@ -11,6 +11,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Setup signal handlers to safely handle SIGSEGV and SIGFPE
  *
index 9729cdc2fcd7c2c03eae53dc81419bbf13d82266..5da221e1679ca364da489db753145f0eb32266c8 100644 (file)
@@ -12,6 +12,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #define SN_API_NOT_YET_FROZEN 1
 #include <libsn/sn-monitor.h>
 
index c64c173d40c2584f4d2507fc95168ae38dd4ca60..62461def988bda0cf7e044b003c667098e75dad2 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 extern Con *croot;
 /* TODO: i am not sure yet how much access to the focused container should
  * be permitted to source files */
index 9915c1a87a551a42dde79bf0e60505f5c7a8635e..e5ba3341336e0ce6531bd5139b60e9091903bdd1 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <err.h>
 
 #include "data.h"
index d0b97f1dfee238343af53f75ea2c9f4fe6c6eab8..77e3f48f2b0caca04c08a1ecae328b88256c76f9 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /**
  * Frees an i3Window and all its members.
  *
index 8e5ff8411f71c553d6c5b8dc43a2fe9b92493f37..8d109e9e31726fe04ada3915501e64809c2dbadd 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "data.h"
 #include "tree.h"
 #include "randr.h"
index 39e0eb2f68e97725df869ad3cf35376bac63ffd7..3e81bc3646f36225a8d4f24d3495b5efa9654b7f 100644 (file)
@@ -10,6 +10,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 /** Stores the X11 window ID of the currently focused window */
 extern xcb_window_t focused_id;
 
index b7eed2cb3321c4d87a089da2bdf0dd7cdf0b8c5e..94f2945d2bc667deda3b3b36b3d7a9dba6238199 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "data.h"
 #include "xcursor.h"
 
index e0ee98138cfb2c1855037ab03b155683f13a1368..804e1f84c211a20c115942ee1e0c3ac33b54abe8 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <xcb/xcb_cursor.h>
 
 enum xcursor_cursor_t {
index 936b9653b98ae6b3eb2b2220f24657de22505dad..f01ee568cf35cea4ae3408cb6e4939eb77605720 100644 (file)
@@ -11,6 +11,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include "data.h"
 
 /**
index 93c63d8f7b641a14da94d61eb10841454721a97a..6ab1ff1c478bd44165dccf9d00a459fcc60b484a 100644 (file)
@@ -9,6 +9,8 @@
  */
 #pragma once
 
+#include <config.h>
+
 #include <yajl/yajl_gen.h>
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
diff --git a/libi3/Makefile b/libi3/Makefile
deleted file mode 100644 (file)
index 2c2f68a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-       $(MAKE) -C .. libi3.a
-
-clean:
-       $(MAKE) -C .. clean-libi3
-
-.PHONY: all clean
index f105ef9aed710189529b247433037df0d26a1bac..a832a689c40600b089ffbfdc2f5dd7421bb34ef5 100644 (file)
@@ -6,6 +6,7 @@
  *
  */
 #include "libi3.h"
+
 #include <math.h>
 #include <stdlib.h>
 #include <xcb/xcb_xrm.h>
index 56b1bce8db882ee666a4c2e6fd069ef63d986c81..e471405b1ae22b1b7ac1541e96fccbcbaf515075 100644 (file)
@@ -6,6 +6,8 @@
  * draw.c: Utility for drawing.
  *
  */
+#include "libi3.h"
+
 #include <stdlib.h>
 #include <err.h>
 #include <string.h>
@@ -13,8 +15,6 @@
 #include <xcb/xcb_aux.h>
 #include <cairo/cairo-xcb.h>
 
-#include "libi3.h"
-
 /* The default visual_type to use if none is specified when creating the surface. Must be defined globally. */
 xcb_visualtype_t *visual_type;
 
index 2c4d4559848ffd23d10632ebea4219459117ef69..145f4512248b7170c98d5a7ec450dcf29e6c4bd6 100644 (file)
@@ -5,14 +5,14 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdlib.h>
 #include <stdbool.h>
 
 #include <xcb/xcb.h>
 #include <xcb/xproto.h>
 
-#include "libi3.h"
-
 /*
  * Generates a configure_notify event and sends it to the given window
  * Applications need this to think they’ve configured themselves correctly.
index 7c305e25b6f992afaf27441d39445319193c6a69..fa8484813b472c3b9a28c7473da9f229effb2bb4 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -15,8 +17,6 @@
 #include <cairo/cairo-xcb.h>
 #include <pango/pangocairo.h>
 
-#include "libi3.h"
-
 static const i3Font *savedFont = NULL;
 
 static xcb_visualtype_t *root_visual_type;
index c9cbbea446274567c09e8c62927ef390884d6c8a..59e947811ec0fdce22abeddf3eca42aa38eec713 100644 (file)
@@ -5,12 +5,12 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 
-#include "libi3.h"
-
 #ifndef STARTS_WITH
 #define STARTS_WITH(string, needle) (strncasecmp((string), (needle), strlen((needle))) == 0)
 #endif
index dc6d774825ed53ff74f7d3434c9c2b2826b5b325..9bdd0a7191e7f151b49fe44df2b7922aeeb0c9dc 100644 (file)
@@ -5,13 +5,13 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 
 #include "queue.h"
-#include "libi3.h"
-
 struct Colorpixel {
     char hex[8];
     uint32_t pixel;
index bad75c4dd87d4d6f245fc0f3d243589983c18110..c47e6dd8b56775df0039621079c96db43d4a14ad 100644 (file)
@@ -6,6 +6,7 @@
  *
  */
 #include "libi3.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
index ef8f23bc25a1915385647f96656a9d4586cb6494..b9d35ea1f9ce8e510eac610c47ee12a3230aa861 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ */
+#include "libi3.h"
+
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
@@ -5,8 +14,6 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#include "libi3.h"
-
 /*
  * This function returns the absolute path to the executable it is running in.
  *
index ac71e6b23075fccbb62acb8c3c6918c417bb819b..98031d4ceed460ffbe3f7561a55b8e4b7bb15ae0 100644 (file)
@@ -5,13 +5,13 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <xcb/xcb.h>
 #include <xcb/xcb_keysyms.h>
 
-#include "libi3.h"
-
 /*
  * All-in-one function which returns the modifier mask (XCB_MOD_MASK_*) for the
  * given keysymbol, for example for XCB_NUM_LOCK (usually configured to mod2).
index a3dee9cd3ef84dddae60ac6d44cd2494ea3a4a93..7e2ecbd24a51cf00195d836a4309d596deac3488 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -17,8 +19,6 @@
 #include <unistd.h>
 #include <err.h>
 
-#include "libi3.h"
-
 /*
  * Returns the name of a temporary file with the specified prefix.
  *
index f493b4f11e6a6d118951afc058b9632c6621cd5b..2e6283425d47baf3853e4334f5837cd19d038496 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -14,8 +16,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#include "libi3.h"
-
 /*
  * Connects to the i3 IPC socket and returns the file descriptor for the
  * socket. die()s if anything goes wrong.
index 0ef4fced4f27b1fd1bf415727efb6f1bbdd14796..16dda90d89b8cbcd5ec540aff00b1c3aba86d46c 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -14,8 +16,6 @@
 
 #include <i3/ipc.h>
 
-#include "libi3.h"
-
 /*
  * Reads a message from the given socket file descriptor and stores its length
  * (reply_length) as well as a pointer to its contents (reply).
index a9ba31653e07cacc1b86ed030075eccccc509a52..c2cc0127d2a2f1131f049e311c3a536a656c7db9 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -14,8 +16,6 @@
 
 #include <i3/ipc.h>
 
-#include "libi3.h"
-
 /*
  * Formats a message (payload) of the given size and type and sends it to i3 via
  * the given socket file descriptor.
index 3173c122cd95c8af355b127a006edfce5ccb85b4..4e583622b3f78ec1050b1755cf40d2c908dc5faa 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ */
+#include "libi3.h"
+
 #include <string.h>
 #include <stdbool.h>
 
diff --git a/libi3/libi3.mk b/libi3/libi3.mk
deleted file mode 100644 (file)
index 16e1f14..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-CLEAN_TARGETS += clean-libi3
-
-libi3_SOURCES := $(wildcard libi3/*.c)
-libi3_HEADERS := $(wildcard libi3/*.h)
-libi3_CFLAGS   = $(PANGO_CFLAGS) $(XCB_XRM_CFLAGS)
-libi3_LIBS     =
-
-libi3_OBJECTS := $(libi3_SOURCES:.c=.o)
-
-
-libi3/%.o: libi3/%.c $(libi3_HEADERS)
-       echo "[libi3] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(libi3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-libi3.a: $(libi3_OBJECTS)
-       echo "[libi3] AR libi3.a"
-       $(AR) rcs $@ $^ $(libi3_LIBS)
-
-clean-libi3:
-       echo "[libi3] Clean"
-       rm -f $(libi3_OBJECTS) libi3/libi3.a libi3.a
index c64b80a3352b97de1ac5e1ec6f21558812e668b7..1fc8c34607222ad381b269fad2fed20e1ad81bdc 100644 (file)
@@ -1,4 +1,12 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ */
 #include "libi3.h"
+
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
index 7a4fb79bf3c2ddca62b9b9bf07a532f96c867f58..51d642db37ec37f3f1dc014f44d51b31dd324390 100644 (file)
@@ -5,8 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
-
 #include "libi3.h"
+
 #include <err.h>
 #include <glob.h>
 #include <stdlib.h>
index 8d26c307048d81a9827a1118a4195b64fb979592..d6394d4bf2f7631fef52cb89454f32ca3a705664 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
@@ -15,8 +17,6 @@
 #include <xcb/xcb.h>
 #include <xcb/xcb_aux.h>
 
-#include "libi3.h"
-
 /*
  * Try to get the contents of the given atom (for example I3_SOCKET_PATH) from
  * the X11 root window and return NULL if it doesn’t work.
index 0a233a1271f996272a50751c964e5ecf94b17015..94ad4ee6c60a73fa4a28ae6cb4d353d9f5bfff4b 100644 (file)
@@ -5,6 +5,8 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -13,8 +15,6 @@
 #include <err.h>
 #include <errno.h>
 
-#include "libi3.h"
-
 /*
  * The s* functions (safe) are wrappers around malloc, strdup, …, which exits if one of
  * the called functions returns NULL, meaning that there is no more memory available
index 19039a23564f4ac43948c3acba568900e3262f98..edd588da1492a26a0acb2dc6d2998af4392416cf 100644 (file)
@@ -9,14 +9,13 @@
  *           others want UTF-8 (Pango).
  *
  */
+#include "libi3.h"
 
 #include <stdlib.h>
 #include <string.h>
 
 #include <glib.h>
 
-#include "libi3.h"
-
 struct _i3String {
     char *utf8;
     xcb_char2b_t *ucs2;
index c4032dc5816130b01dd1689b819a7914219fc1fa..e17f843c32fc23154edd9ffbcddb09c2aa60bb48 100644 (file)
@@ -5,11 +5,11 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <sys/types.h>
 #include <string.h>
 
-#include "libi3.h"
-
 #if defined(__APPLE__)
 
 /*
index b583e32cd6a4f9ba667748d5bd423d994bb595c9..75cff78adbdf4a5739da0834438d3c792105eb0c 100644 (file)
@@ -5,14 +5,14 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <err.h>
 #include <errno.h>
 #include <iconv.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "libi3.h"
-
 static iconv_t utf8_conversion_descriptor = (iconv_t)-1;
 static iconv_t ucs2_conversion_descriptor = (iconv_t)-1;
 
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
new file mode 100644 (file)
index 0000000..08f2e07
--- /dev/null
@@ -0,0 +1,71 @@
+# ===========================================================================
+#      http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+#   FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+#   added in between.
+#
+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+#   CFLAGS) is used.  FLAGS-VARIABLE is not changed if it already contains
+#   FLAG.  If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+#   FLAG.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 6
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+  AS_CASE([" AS_VAR_GET(FLAGS) "],
+    [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+    [
+     AS_VAR_APPEND(FLAGS,[" $1"])
+     AC_RUN_LOG([: FLAGS="$FLAGS"])
+    ])
+  ],
+  [
+  AS_VAR_SET(FLAGS,[$1])
+  AC_RUN_LOG([: FLAGS="$FLAGS"])
+  ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4
new file mode 100644 (file)
index 0000000..1f07799
--- /dev/null
@@ -0,0 +1,122 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CFLAGS_WARN_ALL   [(shellvar [,default, [A/NA]])]
+#   AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+#   AX_FCFLAGS_WARN_ALL  [(shellvar [,default, [A/NA]])]
+#
+# DESCRIPTION
+#
+#   Try to find a compiler option that enables most reasonable warnings.
+#
+#   For the GNU compiler it will be -Wall (and -ansi -pedantic) The result
+#   is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
+#
+#   Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
+#   HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
+#   Intel compilers.  For a given compiler, the Fortran flags are much more
+#   experimental than their C equivalents.
+#
+#    - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
+#    - $2 add-value-if-not-found : nothing
+#    - $3 action-if-found : add value to shellvariable
+#    - $4 action-if-not-found : nothing
+#
+#   NOTE: These macros depend on AX_APPEND_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 15
+
+AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
+VAR,[VAR="no, unknown"
+ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-warn all  % -warn all"   dnl Intel
+   "-pedantic  % -Wall"       dnl GCC
+   "-xstrconst % -v"          dnl Solaris C
+   "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
+   "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
+   "-ansi -ansiE % -fullwarn" dnl IRIX
+   "+ESlit     % +w1"         dnl HP-UX C
+   "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
+   "-h conform % -h msglevel 2" dnl Cray C (Unicos)
+   #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+FLAGS="$ac_save_[]FLAGS"
+])
+AS_VAR_POPDEF([FLAGS])dnl
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+case ".$VAR" in
+     .ok|.ok,*) m4_ifvaln($3,$3) ;;
+   .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
+   *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+])dnl AX_FLAGS_WARN_ALL
+dnl  implementation tactics:
+dnl   the for-argument contains a list of options. The first part of
+dnl   these does only exist to detect the compiler - usually it is
+dnl   a global option to enable -ansi or -extrawarnings. All other
+dnl   compilers will fail about it. That was needed since a lot of
+dnl   compilers will give false positives for some option-syntax
+dnl   like -Woption or -Xoption as they think of it is a pass-through
+dnl   to later compile stages or something. The "%" is used as a
+dnl   delimiter. A non-option comment can be given after "%%" marks
+dnl   which will be shown but not added to the respective C/CXXFLAGS.
+
+AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
+
+AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C++])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([Fortran])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([Fortran])
+])
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
new file mode 100644 (file)
index 0000000..ca36397
--- /dev/null
@@ -0,0 +1,74 @@
+# ===========================================================================
+#   http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the current language's compiler
+#   or gives an error.  (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
+#   force the compiler to issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/m4/ax_check_enable_debug.m4 b/m4/ax_check_enable_debug.m4
new file mode 100644 (file)
index 0000000..f99d75f
--- /dev/null
@@ -0,0 +1,124 @@
+# ===========================================================================
+#   http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
+#
+# DESCRIPTION
+#
+#   Check for the presence of an --enable-debug option to configure, with
+#   the specified default value used when the option is not present.  Return
+#   the value in the variable $ax_enable_debug.
+#
+#   Specifying 'yes' adds '-g -O0' to the compilation flags for all
+#   languages. Specifying 'info' adds '-g' to the compilation flags.
+#   Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
+#   the linking flags. Otherwise, nothing is added.
+#
+#   Define the variables listed in the second argument if debug is enabled,
+#   defaulting to no variables.  Defines the variables listed in the third
+#   argument if debug is disabled, defaulting to NDEBUG.  All lists of
+#   variables should be space-separated.
+#
+#   If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
+#   Should be invoked prior to any AC_PROG_* compiler checks.
+#
+#   IS-RELEASE can be used to change the default to 'no' when making a
+#   release.  Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
+#   uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
+#   macro, there is no need to pass this parameter.
+#
+#     AX_IS_RELEASE([git-directory])
+#     AX_CHECK_ENABLE_DEBUG()
+#
+# LICENSE
+#
+#   Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
+#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+#serial 5
+
+AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
+    AC_BEFORE([$0],[AC_PROG_CC])dnl
+    AC_BEFORE([$0],[AC_PROG_CXX])dnl
+    AC_BEFORE([$0],[AC_PROG_F77])dnl
+    AC_BEFORE([$0],[AC_PROG_FC])dnl
+
+    AC_MSG_CHECKING(whether to enable debugging)
+
+    ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
+    ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
+                                                              [$ax_is_release],
+                                                              [$4])))
+
+    # If this is a release, override the default.
+    AS_IF([test "$ax_enable_debug_is_release" = "yes"],
+      [ax_enable_debug_default="no"])
+
+    m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
+    m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
+
+    AC_ARG_ENABLE(debug,
+       [AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
+       [],enable_debug=$ax_enable_debug_default)
+
+    # empty mean debug yes
+    AS_IF([test "x$enable_debug" = "x"],
+      [enable_debug="yes"])
+
+    # case of debug
+    AS_CASE([$enable_debug],
+      [yes],[
+       AC_MSG_RESULT(yes)
+       CFLAGS="${CFLAGS} -g -O0"
+       CXXFLAGS="${CXXFLAGS} -g -O0"
+       FFLAGS="${FFLAGS} -g -O0"
+       FCFLAGS="${FCFLAGS} -g -O0"
+       OBJCFLAGS="${OBJCFLAGS} -g -O0"
+      ],
+      [info],[
+       AC_MSG_RESULT(info)
+       CFLAGS="${CFLAGS} -g"
+       CXXFLAGS="${CXXFLAGS} -g"
+       FFLAGS="${FFLAGS} -g"
+       FCFLAGS="${FCFLAGS} -g"
+       OBJCFLAGS="${OBJCFLAGS} -g"
+      ],
+      [profile],[
+       AC_MSG_RESULT(profile)
+       CFLAGS="${CFLAGS} -g -pg"
+       CXXFLAGS="${CXXFLAGS} -g -pg"
+       FFLAGS="${FFLAGS} -g -pg"
+       FCFLAGS="${FCFLAGS} -g -pg"
+       OBJCFLAGS="${OBJCFLAGS} -g -pg"
+       LDFLAGS="${LDFLAGS} -pg"
+      ],
+      [
+       AC_MSG_RESULT(no)
+       dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
+       dnl by setting any unset environment flag variables
+       AS_IF([test "x${CFLAGS+set}" != "xset"],
+         [CFLAGS=""])
+       AS_IF([test "x${CXXFLAGS+set}" != "xset"],
+         [CXXFLAGS=""])
+       AS_IF([test "x${FFLAGS+set}" != "xset"],
+         [FFLAGS=""])
+       AS_IF([test "x${FCFLAGS+set}" != "xset"],
+         [FCFLAGS=""])
+       AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
+         [OBJCFLAGS=""])
+      ])
+
+    dnl Define various variables if debugging is disabled.
+    dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
+    AS_IF([test "x$enable_debug" = "xyes"],
+      [m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
+      [m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
+    ax_enable_debug=$enable_debug
+])
diff --git a/m4/ax_check_gnu_make.m4 b/m4/ax_check_gnu_make.m4
new file mode 100644 (file)
index 0000000..6762e9e
--- /dev/null
@@ -0,0 +1,84 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_GNU_MAKE()
+#
+# DESCRIPTION
+#
+#   This macro searches for a GNU version of make. If a match is found:
+#
+#     * The makefile variable `ifGNUmake' is set to the empty string, otherwise
+#       it is set to "#". This is useful for including a special features in a
+#       Makefile, which cannot be handled by other versions of make.
+#     * The variable `_cv_gnu_make_command` is set to the command to invoke
+#       GNU make if it exists, the empty string otherwise.
+#     * The variable `ax_cv_gnu_make_command` is set to the command to invoke
+#       GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
+#     * If GNU Make is found, its version is extracted from the output of
+#       `make --version` as the last field of a record of space-separated
+#       columns and saved into the variable `ax_check_gnu_make_version`.
+#
+#   Here is an example of its use:
+#
+#   Makefile.in might contain:
+#
+#     # A failsafe way of putting a dependency rule into a makefile
+#     $(DEPEND):
+#             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
+#
+#     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
+#     @ifGNUmake@ include $(DEPEND)
+#     @ifGNUmake@ endif
+#
+#   Then configure.in would normally contain:
+#
+#     AX_CHECK_GNU_MAKE()
+#     AC_OUTPUT(Makefile)
+#
+#   Then perhaps to cause gnu make to override any other make, we could do
+#   something like this (note that GNU make always looks for GNUmakefile
+#   first):
+#
+#     if  ! test x$_cv_gnu_make_command = x ; then
+#             mv Makefile GNUmakefile
+#             echo .DEFAULT: > Makefile ;
+#             echo \  $_cv_gnu_make_command \$@ >> Makefile;
+#     fi
+#
+#   Then, if any (well almost any) other make is called, and GNU make also
+#   exists, then the other make wraps the GNU make.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
+#   Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
+  [AC_PROG_AWK
+  AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
+    _cv_gnu_make_command="" ;
+dnl Search all the common names for GNU make
+    for a in "$MAKE" make gmake gnumake ; do
+      if test -z "$a" ; then continue ; fi ;
+      if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
+        _cv_gnu_make_command=$a ;
+        AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
+        ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
+        break ;
+      fi
+    done ;])
+dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
+  AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])],   [AS_VAR_SET([ifGNUmake], [""])])
+  AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])
+  AC_SUBST([ifGNUmake])
+])
diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4
new file mode 100644 (file)
index 0000000..eb01a6c
--- /dev/null
@@ -0,0 +1,74 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the linker or gives an error.
+#   (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_CHECK_LINK_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS $4 $1"
+  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  LDFLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_LINK_FLAGS
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
new file mode 100644 (file)
index 0000000..6c985eb
--- /dev/null
@@ -0,0 +1,273 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CODE_COVERAGE()
+#
+# DESCRIPTION
+#
+#   Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
+#   CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LDFLAGS which should be
+#   included in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LDFLAGS variables of
+#   every build target (program or library) which should be built with code
+#   coverage support. Also defines CODE_COVERAGE_RULES which should be
+#   substituted in your Makefile; and $enable_code_coverage which can be
+#   used in subsequent configure output. CODE_COVERAGE_ENABLED is defined
+#   and substituted, and corresponds to the value of the
+#   --enable-code-coverage option, which defaults to being disabled.
+#
+#   Test also for gcov program and create GCOV variable that could be
+#   substituted.
+#
+#   Note that all optimisation flags in CFLAGS must be disabled when code
+#   coverage is enabled.
+#
+#   Usage example:
+#
+#   configure.ac:
+#
+#     AX_CODE_COVERAGE
+#
+#   Makefile.am:
+#
+#     @CODE_COVERAGE_RULES@
+#     my_program_LIBS = ... $(CODE_COVERAGE_LDFLAGS) ...
+#     my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
+#     my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
+#     my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
+#
+#   This results in a "check-code-coverage" rule being added to any
+#   Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module
+#   has been configured with --enable-code-coverage). Running `make
+#   check-code-coverage` in that directory will run the module's test suite
+#   (`make check`) and build a code coverage report detailing the code which
+#   was touched, then print the URI for the report.
+#
+#   This code was derived from Makefile.decl in GLib, originally licenced
+#   under LGPLv2.1+.
+#
+# LICENSE
+#
+#   Copyright (c) 2012, 2016 Philip Withnall
+#   Copyright (c) 2012 Xan Lopez
+#   Copyright (c) 2012 Christian Persch
+#   Copyright (c) 2012 Paolo Borelli
+#   Copyright (c) 2012 Dan Winship
+#   Copyright (c) 2015 Bastien ROUCARIES
+#
+#   This library is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1 of the License, or (at
+#   your option) any later version.
+#
+#   This library is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License
+#   along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#serial 15
+
+AC_DEFUN([AX_CODE_COVERAGE],[
+       dnl Check for --enable-code-coverage
+       AC_REQUIRE([AC_PROG_SED])
+
+       # allow to override gcov location
+       AC_ARG_WITH([gcov],
+         [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
+         [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
+         [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
+
+       AC_MSG_CHECKING([whether to build with code coverage support])
+       AC_ARG_ENABLE([code-coverage],
+         AS_HELP_STRING([--enable-code-coverage],
+         [Whether to enable code coverage support]),,
+         enable_code_coverage=no)
+
+       AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes])
+       AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
+       AC_MSG_RESULT($enable_code_coverage)
+
+       AS_IF([ test "$enable_code_coverage" = "yes" ], [
+               # check for gcov
+               AC_CHECK_TOOL([GCOV],
+                 [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
+                 [:])
+               AS_IF([test "X$GCOV" = "X:"],
+                 [AC_MSG_ERROR([gcov is needed to do coverage])])
+               AC_SUBST([GCOV])
+
+               dnl Check if gcc is being used
+               AS_IF([ test "$GCC" = "no" ], [
+                       AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
+               ])
+
+               # List of supported lcov versions.
+               lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11 1.12"
+
+               AC_CHECK_PROG([LCOV], [lcov], [lcov])
+               AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
+
+               AS_IF([ test "$LCOV" ], [
+                       AC_CACHE_CHECK([for lcov version], ax_cv_lcov_version, [
+                               ax_cv_lcov_version=invalid
+                               lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+                               for lcov_check_version in $lcov_version_list; do
+                                       if test "$lcov_version" = "$lcov_check_version"; then
+                                               ax_cv_lcov_version="$lcov_check_version (ok)"
+                                       fi
+                               done
+                       ])
+               ], [
+                       lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+                       AC_MSG_ERROR([$lcov_msg])
+               ])
+
+               case $ax_cv_lcov_version in
+                       ""|invalid[)]
+                               lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+                               AC_MSG_ERROR([$lcov_msg])
+                               LCOV="exit 0;"
+                       ;;
+               esac
+
+               AS_IF([ test -z "$GENHTML" ], [
+                       AC_MSG_ERROR([Could not find genhtml from the lcov package])
+               ])
+
+               dnl Build the code coverage flags
+               CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
+               CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+               CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+               CODE_COVERAGE_LDFLAGS="-lgcov"
+
+               AC_SUBST([CODE_COVERAGE_CPPFLAGS])
+               AC_SUBST([CODE_COVERAGE_CFLAGS])
+               AC_SUBST([CODE_COVERAGE_CXXFLAGS])
+               AC_SUBST([CODE_COVERAGE_LDFLAGS])
+       ])
+
+[CODE_COVERAGE_RULES='
+# Code coverage
+#
+# Optional:
+#  - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
+#    Multiple directories may be specified, separated by whitespace.
+#    (Default: $(top_builddir))
+#  - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
+#    by lcov for code coverage. (Default:
+#    $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info)
+#  - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
+#    reports to be created. (Default:
+#    $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage)
+#  - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
+#    set to 0 to disable it and leave empty to stay with the default.
+#    (Default: empty)
+#  - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
+#    instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
+#  - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
+#    instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
+#  - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
+#  - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
+#    collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+#  - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
+#    instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+#  - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
+#    lcov instance. (Default: empty)
+#  - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
+#    instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
+#  - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
+#    genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
+#  - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
+#    instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
+#  - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
+#
+# The generated report will be titled using the $(PACKAGE_NAME) and
+# $(PACKAGE_VERSION). In order to add the current git hash to the title,
+# use the git-version-gen script, available online.
+
+# Optional variables
+CODE_COVERAGE_DIRECTORY ?= $(top_builddir)
+CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info
+CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage
+CODE_COVERAGE_BRANCH_COVERAGE ?=
+CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
+--rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
+CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
+CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)"
+CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
+CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
+CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
+$(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
+--rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
+CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULTS)
+CODE_COVERAGE_IGNORE_PATTERN ?=
+
+code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V))
+code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_lcov_cap_0 = @echo "  LCOV   --capture"\
+ $(CODE_COVERAGE_OUTPUT_FILE);
+code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V))
+code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_lcov_ign_0 = @echo "  LCOV   --remove /tmp/*"\
+ $(CODE_COVERAGE_IGNORE_PATTERN);
+code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V))
+code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_genhtml_0 = @echo "  GEN   " $(CODE_COVERAGE_OUTPUT_DIRECTORY);
+code_coverage_quiet = $(code_coverage_quiet_$(V))
+code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY))
+code_coverage_quiet_0 = --quiet
+
+# sanitizes the test-name: replaces with underscores: dashes and dots
+code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1)))
+
+# Use recursive makes in order to ignore errors during check
+check-code-coverage:
+ifeq ($(CODE_COVERAGE_ENABLED),yes)
+       -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check
+       $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
+else
+       @echo "Need to reconfigure with --enable-code-coverage"
+endif
+
+# Capture code coverage data
+code-coverage-capture: code-coverage-capture-hook
+ifeq ($(CODE_COVERAGE_ENABLED),yes)
+       $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS)
+       $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS)
+       -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp
+       $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS)
+       @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html"
+else
+       @echo "Need to reconfigure with --enable-code-coverage"
+endif
+
+# Hook rule executed before code-coverage-capture, overridable by the user
+code-coverage-capture-hook:
+
+ifeq ($(CODE_COVERAGE_ENABLED),yes)
+clean: code-coverage-clean
+code-coverage-clean:
+       -$(LCOV) --directory $(top_builddir) -z
+       -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY)
+       -find . -name "*.gcda" -o -name "*.gcov" -delete
+endif
+
+GITIGNOREFILES ?=
+GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY)
+
+A''M_DISTCHECK_CONFIGURE_FLAGS ?=
+A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage
+
+.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean
+']
+
+       AC_SUBST([CODE_COVERAGE_RULES])
+       m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])])
+])
diff --git a/m4/ax_configure_args.m4 b/m4/ax_configure_args.m4
new file mode 100644 (file)
index 0000000..0726b1b
--- /dev/null
@@ -0,0 +1,70 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_configure_args.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CONFIGURE_ARGS
+#
+# DESCRIPTION
+#
+#   Helper macro for AX_ENABLE_BUILDDIR.
+#
+#   The traditional way of starting a subdir-configure is running the script
+#   with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have
+#   to rely on eval'ing $ac_configure_args however some old autoconf
+#   versions do not provide that. To ensure maximum portability of autoconf
+#   extension macros this helper can be AC_REQUIRE'd so that
+#   $ac_configure_args will alsways be present.
+#
+#   Sadly, the traditional "exec $SHELL" of the enable_builddir macros is
+#   spoiled now and must be replaced by "eval + exit $?".
+#
+#   Example:
+#
+#     AC_DEFUN([AX_ENABLE_SUBDIR],[dnl
+#       AC_REQUIRE([AX_CONFIGURE_ARGS])dnl
+#       eval $SHELL $ac_configure_args || exit $?
+#       ...])
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 9
+
+AC_DEFUN([AX_CONFIGURE_ARGS],[
+   # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
+   if test "${ac_configure_args+set}" != "set" ; then
+      ac_configure_args=
+      for ac_arg in ${1+"[$]@"}; do
+         ac_configure_args="$ac_configure_args '$ac_arg'"
+      done
+   fi
+])
diff --git a/m4/ax_enable_builddir.m4 b/m4/ax_enable_builddir.m4
new file mode 100644 (file)
index 0000000..5f4ba32
--- /dev/null
@@ -0,0 +1,302 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])]
+#
+# DESCRIPTION
+#
+#   If the current configure was run within the srcdir then we move all
+#   configure-files into a subdir and let the configure steps continue
+#   there. We provide an option --disable-builddir to suppress the move into
+#   a separate builddir.
+#
+#   Defaults:
+#
+#     $1 = $host (overridden with $HOST)
+#     $2 = Makefile.mk
+#     $3 = -all
+#
+#   This macro must be called before AM_INIT_AUTOMAKE. It creates a default
+#   toplevel srcdir Makefile from the information found in the created
+#   toplevel builddir Makefile. It just copies the variables and
+#   rule-targets, each extended with a default rule-execution that recurses
+#   into the build directory of the current "HOST". You can override the
+#   auto-dection through `config.guess` and build-time of course, as in
+#
+#     make HOST=i386-mingw-cross
+#
+#   which can of course set at configure time as well using
+#
+#     configure --host=i386-mingw-cross
+#
+#   After the default has been created, additional rules can be appended
+#   that will not just recurse into the subdirectories and only ever exist
+#   in the srcdir toplevel makefile - these parts are read from the $2 =
+#   Makefile.mk file
+#
+#   The automatic rules are usually scanning the toplevel Makefile for lines
+#   like '#### $host |$builddir' to recognize the place where to recurse
+#   into. Usually, the last one is the only one used. However, almost all
+#   targets have an additional "*-all" rule which makes the script to
+#   recurse into _all_ variants of the current HOST (!!) setting. The "-all"
+#   suffix can be overriden for the macro as well.
+#
+#   a special rule is only given for things like "dist" that will copy the
+#   tarball from the builddir to the sourcedir (or $(PUB)) for reason of
+#   convenience.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 25
+
+AC_DEFUN([AX_ENABLE_BUILDDIR],[
+AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
+AC_REQUIRE([AC_CANONICAL_TARGET])[]dnl
+AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl
+AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+SUB="."
+AC_ARG_ENABLE([builddir], AS_HELP_STRING(
+  [--disable-builddir],[disable automatic build in subdir of sources])
+  ,[SUB="$enableval"], [SUB="auto"])
+if test ".$ac_srcdir_defaulted" != ".no" ; then
+if test ".$srcdir" = ".." ; then
+  if test -f config.status ; then
+    AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build)
+  else
+    test ".$SUB" = "."  && SUB="."
+    test ".$SUB" = ".no"  && SUB="."
+    test ".$TARGET" = "." && TARGET="$target"
+    test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])"
+    if test ".$SUB" != ".." ; then    # we know where to go and
+      AS_MKDIR_P([$SUB])
+      echo __.$SUB.__ > $SUB/conftest.tmp
+      cd $SUB
+      if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then
+        rm conftest.tmp
+        AC_MSG_RESULT([continue configure in default builddir "./$SUB"])
+      else
+        AC_MSG_ERROR([could not change to default builddir "./$SUB"])
+      fi
+      srcdir=`echo "$SUB" |
+              sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'`
+      # going to restart from subdirectory location
+      test -f $srcdir/config.log   && mv $srcdir/config.log   .
+      test -f $srcdir/confdefs.h   && mv $srcdir/confdefs.h   .
+      test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
+      test -f $srcdir/$cache_file  && mv $srcdir/$cache_file  .
+      AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"})
+      case "[$]0" in # restart
+       [[\\/]]* | ?:[[\\/]]*) # Asbolute name
+         eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+       *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+      esac ; exit $?
+    fi
+  fi
+fi fi
+test ".$SUB" = ".auto" && SUB="."
+dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec"
+AC_PATH_PROG(SED,gsed sed, sed)
+AUX="$am_aux_dir"
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SUB])dnl
+AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status ..............
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl
+AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+pushdef([END],[Makefile.mk])dnl
+pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl
+  SRC="$ax_enable_builddir_srcdir"
+  if test ".$SUB" = ".." ; then
+    if test -f "$TOP/Makefile" ; then
+      AC_MSG_NOTICE([skipping TOP/Makefile - left untouched])
+    else
+      AC_MSG_NOTICE([skipping TOP/Makefile - not created])
+    fi
+  else
+    if test -f "$SRC/Makefile" ; then
+      a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile`
+      test "$a" != "$b" && rm "$SRC/Makefile"
+    fi
+    if test -f "$SRC/Makefile" ; then
+       echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk
+       echo "  []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk
+      eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
+      if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null
+      then rm $SRC/Makefile ; fi
+      cp $tmp/conftemp.mk $SRC/makefiles.mk~      ## DEBUGGING
+    fi
+    if test ! -f "$SRC/Makefile" ; then
+      AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile])
+      x='`' ; cat >$tmp/conftemp.sed <<_EOF
+/^\$/n
+x
+/^\$/bS
+x
+/\\\\\$/{H;d;}
+{H;s/.*//;x;}
+bM
+:S
+x
+/\\\\\$/{h;d;}
+{h;s/.*//;x;}
+:M
+s/\\(\\n\\)    /\\1 /g
+/^     /d
+/^[[    ]]*[[\\#]]/d
+/^VPATH *=/d
+s/^srcdir *=.*/srcdir = ./
+s/^top_srcdir *=.*/top_srcdir = ./
+/[[:=]]/!d
+/^\\./d
+dnl Now handle rules (i.e. lines containing ":" but not " = ").
+/ = /b
+/ .= /b
+/:/!b
+s/:.*/:/
+s/ /  /g
+s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g
+s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/
+s/  / /g
+/^all all[]_ALL[[ :]]/i\\
+all-configured : all[]_ALL
+dnl dist-all exists... and would make for dist-all-all
+s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g
+/[]_ALL[]_ALL/d
+a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\
+       ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree)
+/dist[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
+       ; if test "\$\$found" -eq "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree)
+/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
+       ; if test "\$\$found" -eq "0" ; then : \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+       ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
+       ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "distclean" removes all local builddirs completely
+/distclean[]_ALL *:/a\\
+       @ HOST="\$(HOST)\" \\\\\\
+       ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+       ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
+       ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+       ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
+       ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
+       ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+       ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
+       ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
+       ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
+_EOF
+      cp "$tmp/conftemp.sed" "$SRC/makefile.sed~"            ## DEBUGGING
+      $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile
+      if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then
+        AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])])
+        cat $SRC/END >>$SRC/Makefile
+      fi ; xxxx="####"
+      echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile
+      # sanity check
+      if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then
+        AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts])
+        $SED -e '/^@ HOST=/s/^/        /' -e '/^; /s/^/        /' $SRC/Makefile \
+          >$SRC/Makefile~
+        (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null
+      fi
+    else
+      xxxx="\\#\\#\\#\\#"
+      # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
+      echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed
+      $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp
+        cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~"         ## DEBUGGING
+        cp "$tmp/mkfile.tmp"   "$SRC/makefiles.out~"         ## DEBUGGING
+      if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
+        AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure])
+        rm "$tmp/mkfile.tmp"
+      else
+        AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure])
+        mv "$tmp/mkfile.tmp" "$SRC/Makefile"
+      fi
+    fi
+    AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)])
+    xxxx="####"
+    echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile
+  fi
+popdef([END])dnl
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SRC])dnl
+AS_VAR_POPDEF([TOP])dnl
+AS_VAR_POPDEF([SUB])dnl
+],[dnl
+ax_enable_builddir_srcdir="$srcdir"                    # $srcdir
+ax_enable_builddir_host="$HOST"                        # $HOST / $host
+ax_enable_builddir_version="$VERSION"                  # $VERSION
+ax_enable_builddir_package="$PACKAGE"                  # $PACKAGE
+ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
+ax_enable_builddir_sed="$ax_enable_builddir_sed"       # $SED
+ax_enable_builddir="$ax_enable_builddir"               # $SUB
+])dnl
+])
diff --git a/m4/ax_extend_srcdir.m4 b/m4/ax_extend_srcdir.m4
new file mode 100644 (file)
index 0000000..a308d67
--- /dev/null
@@ -0,0 +1,86 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_extend_srcdir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_EXTEND_SRCDIR
+#
+# DESCRIPTION
+#
+#   The AX_EXTEND_SRCDIR macro extends $srcdir by one path component.
+#
+#   As an example, when working in /home/michael/i3-4.12/build and calling
+#   ../configure, your $srcdir is "..". After calling AX_EXTEND_SRCDIR,
+#   $srcdir will be set to "../../i3-4.12".
+#
+#   The result of extending $srcdir is that filenames (e.g. in the output of
+#   the "backtrace" gdb command) will include one more path component of the
+#   absolute source path. The additional path component makes it easy for
+#   users to recognize which files belong to the PACKAGE, and -- provided a
+#   dist tarball was unpacked -- which version of PACKAGE was used.
+#
+#   As an example, in "backtrace", you will see:
+#
+#     #0  main (argc=1, argv=0x7fffffff1fc8) at ../../i3-4.12/src/main.c:187
+#
+#   instead of:
+#
+#     #0  main (argc=1, argv=0x7fffffff1fc8) at ../src/main.c:187
+#
+#   In case your code uses the __FILE__ preprocessor directive to refer to
+#   the filename of the current source file (e.g. in debug messages), using
+#   the extended path might be undesirable. For this purpose,
+#   AX_EXTEND_SRCDIR defines the output variable AX_EXTEND_SRCDIR_CPPFLAGS,
+#   which can be added to AM_CPPFLAGS in Makefile.am in order to define the
+#   preprocessor directive STRIPPED__FILE__. As an example, when compiling
+#   the file "../../i3-4.12/src/main.c", STRIPPED__FILE__ evaluates to
+#   "main.c".
+#
+#   There are some caveats: When $srcdir is "." (i.e. when ./configure was
+#   called instead of ../configure in a separate build directory),
+#   AX_EXTEND_SRCDIR will still extend $srcdir, but the intended effect will
+#   not be achieved because of the way automake specifies file paths:
+#   automake defines COMPILE to use "`test -f '$source' || echo
+#   '\$(srcdir)/'`$source" in order to prefer files in the current directory
+#   over specifying $srcdir explicitly.
+#
+#   The AX_EXTEND_SRCDIR author is not aware of any way to influence this
+#   automake behavior. Patches very welcome.
+#
+#   To work around this issue, you can use AX_ENABLE_BUILDDIR i.e. by adding
+#   the following code to configure.ac:
+#
+#     AX_ENABLE_BUILDDIR
+#     dnl ...
+#     AX_EXTEND_SRCDIR
+#
+#   Then also add this bit to Makefile.am (if you wish to use
+#   STRIPPED__FILE__ in your code):
+#
+#     AM_CPPFLAGS = @AX_EXTEND_SRCDIR_CPPFLAGS@
+#
+# LICENSE
+#
+#   Copyright (c) 2016 Michael Stapelberg <michael@i3wm.org>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 3
+
+AC_DEFUN([AX_EXTEND_SRCDIR],
+[dnl
+AS_CASE([$srcdir],
+  [.|.*],
+  [
+    # pwd -P is specified in IEEE 1003.1 from 2004
+    as_dir=`cd "$srcdir" && pwd -P`
+    as_base=`AS_BASENAME([$as_dir])`
+    srcdir=${srcdir}/../${as_base}
+
+    AC_SUBST([AX_EXTEND_SRCDIR_CPPFLAGS], ["-DSTRIPPED__FILE__=AS_ESCAPE([\"$$(basename $<)\"])"])
+  ])
+])dnl AX_EXTEND_SRCDIR
diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
new file mode 100644 (file)
index 0000000..4c4051e
--- /dev/null
@@ -0,0 +1,485 @@
+# ===========================================================================
+#        http://www.gnu.org/software/autoconf-archive/ax_pthread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro figures out how to build C programs using POSIX threads. It
+#   sets the PTHREAD_LIBS output variable to the threads library and linker
+#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
+#   flags that are needed. (The user can also force certain compiler
+#   flags/libs to be tested by setting these environment variables.)
+#
+#   Also sets PTHREAD_CC to any special C compiler that is needed for
+#   multi-threaded programs (defaults to the value of CC otherwise). (This
+#   is necessary on AIX to use the special cc_r compiler alias.)
+#
+#   NOTE: You are assumed to not only compile your program with these flags,
+#   but also to link with them as well. For example, you might link with
+#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
+#
+#   If you are only building threaded programs, you may wish to use these
+#   variables in your default LIBS, CFLAGS, and CC:
+#
+#     LIBS="$PTHREAD_LIBS $LIBS"
+#     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+#     CC="$PTHREAD_CC"
+#
+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
+#   has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
+#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
+#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
+#   PTHREAD_CFLAGS.
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
+#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
+#   is not found. If ACTION-IF-FOUND is not specified, the default action
+#   will define HAVE_PTHREAD.
+#
+#   Please let the authors know if this macro fails on any platform, or if
+#   you have any other suggestions or comments. This macro was based on work
+#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
+#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
+#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
+#   grateful for the helpful feedback of numerous users.
+#
+#   Updated for Autoconf 2.68 by Daniel Richard G.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+#   Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 23
+
+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
+AC_DEFUN([AX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([AC_PROG_SED])
+AC_LANG_PUSH([C])
+ax_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on Tru64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
+        ax_pthread_save_CC="$CC"
+        ax_pthread_save_CFLAGS="$CFLAGS"
+        ax_pthread_save_LIBS="$LIBS"
+        AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
+        AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
+        AC_MSG_RESULT([$ax_pthread_ok])
+        if test "x$ax_pthread_ok" = "xno"; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        CC="$ax_pthread_save_CC"
+        CFLAGS="$ax_pthread_save_CFLAGS"
+        LIBS="$ax_pthread_save_LIBS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
+#           (Note: HP C rejects this with "bad form for `-t' option")
+# -pthreads: Solaris/gcc (Note: HP C also rejects)
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads and
+#      -D_REENTRANT too), HP C (must be checked before -lpthread, which
+#      is present but should not be used directly; and before -mthreads,
+#      because the compiler interprets this as "-mt" + "-hreads")
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case $host_os in
+
+        freebsd*)
+
+        # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+        # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+
+        ax_pthread_flags="-kthread lthread $ax_pthread_flags"
+        ;;
+
+        hpux*)
+
+        # From the cc(1) man page: "[-mt] Sets various -D flags to enable
+        # multi-threading and also sets -lpthread."
+
+        ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
+        ;;
+
+        openedition*)
+
+        # IBM z/OS requires a feature-test macro to be defined in order to
+        # enable POSIX threads at all, so give the user a hint if this is
+        # not set. (We don't define these ourselves, as they can affect
+        # other portions of the system API in unpredictable ways.)
+
+        AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
+            [
+#            if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
+             AX_PTHREAD_ZOS_MISSING
+#            endif
+            ],
+            [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
+        ;;
+
+        solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed. (N.B.: The stubs are missing
+        # pthread_cleanup_push, or rather a function called by this macro,
+        # so we could check for that, but who knows whether they'll stub
+        # that too in a future libc.)  So we'll check first for the
+        # standard Solaris way of linking pthreads (-mt -lpthread).
+
+        ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
+        ;;
+esac
+
+# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
+
+AS_IF([test "x$GCC" = "xyes"],
+      [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
+
+# The presence of a feature test macro requesting re-entrant function
+# definitions is, on some systems, a strong hint that pthreads support is
+# correctly enabled
+
+case $host_os in
+        darwin* | hpux* | linux* | osf* | solaris*)
+        ax_pthread_check_macro="_REENTRANT"
+        ;;
+
+        aix*)
+        ax_pthread_check_macro="_THREAD_SAFE"
+        ;;
+
+        *)
+        ax_pthread_check_macro="--"
+        ;;
+esac
+AS_IF([test "x$ax_pthread_check_macro" = "x--"],
+      [ax_pthread_check_cond=0],
+      [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
+
+# Are we compiling with Clang?
+
+AC_CACHE_CHECK([whether $CC is Clang],
+    [ax_cv_PTHREAD_CLANG],
+    [ax_cv_PTHREAD_CLANG=no
+     # Note that Autoconf sets GCC=yes for Clang as well as GCC
+     if test "x$GCC" = "xyes"; then
+        AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
+            [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
+#            if defined(__clang__) && defined(__llvm__)
+             AX_PTHREAD_CC_IS_CLANG
+#            endif
+            ],
+            [ax_cv_PTHREAD_CLANG=yes])
+     fi
+    ])
+ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
+
+ax_pthread_clang_warning=no
+
+# Clang needs special handling, because older versions handle the -pthread
+# option in a rather... idiosyncratic way
+
+if test "x$ax_pthread_clang" = "xyes"; then
+
+        # Clang takes -pthread; it has never supported any other flag
+
+        # (Note 1: This will need to be revisited if a system that Clang
+        # supports has POSIX threads in a separate library.  This tends not
+        # to be the way of modern systems, but it's conceivable.)
+
+        # (Note 2: On some systems, notably Darwin, -pthread is not needed
+        # to get POSIX threads support; the API is always present and
+        # active.  We could reasonably leave PTHREAD_CFLAGS empty.  But
+        # -pthread does define _REENTRANT, and while the Darwin headers
+        # ignore this macro, third-party headers might not.)
+
+        PTHREAD_CFLAGS="-pthread"
+        PTHREAD_LIBS=
+
+        ax_pthread_ok=yes
+
+        # However, older versions of Clang make a point of warning the user
+        # that, in an invocation where only linking and no compilation is
+        # taking place, the -pthread option has no effect ("argument unused
+        # during compilation").  They expect -pthread to be passed in only
+        # when source code is being compiled.
+        #
+        # Problem is, this is at odds with the way Automake and most other
+        # C build frameworks function, which is that the same flags used in
+        # compilation (CFLAGS) are also used in linking.  Many systems
+        # supported by AX_PTHREAD require exactly this for POSIX threads
+        # support, and in fact it is often not straightforward to specify a
+        # flag that is used only in the compilation phase and not in
+        # linking.  Such a scenario is extremely rare in practice.
+        #
+        # Even though use of the -pthread flag in linking would only print
+        # a warning, this can be a nuisance for well-run software projects
+        # that build with -Werror.  So if the active version of Clang has
+        # this misfeature, we search for an option to squash it.
+
+        AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
+            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
+            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
+             # Create an alternate version of $ac_link that compiles and
+             # links in two steps (.c -> .o, .o -> exe) instead of one
+             # (.c -> exe), because the warning occurs only in the second
+             # step
+             ax_pthread_save_ac_link="$ac_link"
+             ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
+             ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
+             ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
+             ax_pthread_save_CFLAGS="$CFLAGS"
+             for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
+                AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
+                CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
+                ac_link="$ax_pthread_save_ac_link"
+                AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
+                    [ac_link="$ax_pthread_2step_ac_link"
+                     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
+                         [break])
+                    ])
+             done
+             ac_link="$ax_pthread_save_ac_link"
+             CFLAGS="$ax_pthread_save_CFLAGS"
+             AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
+             ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
+            ])
+
+        case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
+                no | unknown) ;;
+                *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
+        esac
+
+fi # $ax_pthread_clang = yes
+
+if test "x$ax_pthread_ok" = "xno"; then
+for ax_pthread_try_flag in $ax_pthread_flags; do
+
+        case $ax_pthread_try_flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -mt,pthread)
+                AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
+                PTHREAD_CFLAGS="-mt"
+                PTHREAD_LIBS="-lpthread"
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
+                PTHREAD_CFLAGS="$ax_pthread_try_flag"
+                ;;
+
+                pthread-config)
+                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
+                AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
+                PTHREAD_CFLAGS="`pthread-config --cflags`"
+                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+                ;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
+                PTHREAD_LIBS="-l$ax_pthread_try_flag"
+                ;;
+        esac
+
+        ax_pthread_save_CFLAGS="$CFLAGS"
+        ax_pthread_save_LIBS="$LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
+#                       if $ax_pthread_check_cond
+#                        error "$ax_pthread_check_macro must be defined"
+#                       endif
+                        static void routine(void *a) { a = 0; }
+                        static void *start_routine(void *a) { return a; }],
+                       [pthread_t th; pthread_attr_t attr;
+                        pthread_create(&th, 0, start_routine, 0);
+                        pthread_join(th, 0);
+                        pthread_attr_init(&attr);
+                        pthread_cleanup_push(routine, 0);
+                        pthread_cleanup_pop(0) /* ; */])],
+            [ax_pthread_ok=yes],
+            [])
+
+        CFLAGS="$ax_pthread_save_CFLAGS"
+        LIBS="$ax_pthread_save_LIBS"
+
+        AC_MSG_RESULT([$ax_pthread_ok])
+        AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$ax_pthread_ok" = "xyes"; then
+        ax_pthread_save_CFLAGS="$CFLAGS"
+        ax_pthread_save_LIBS="$LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+        AC_CACHE_CHECK([for joinable pthread attribute],
+            [ax_cv_PTHREAD_JOINABLE_ATTR],
+            [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
+             for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+                 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
+                                                 [int attr = $ax_pthread_attr; return attr /* ; */])],
+                                [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
+                                [])
+             done
+            ])
+        AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
+               test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
+               test "x$ax_pthread_joinable_attr_defined" != "xyes"],
+              [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
+                                  [$ax_cv_PTHREAD_JOINABLE_ATTR],
+                                  [Define to necessary symbol if this constant
+                                   uses a non-standard name on your system.])
+               ax_pthread_joinable_attr_defined=yes
+              ])
+
+        AC_CACHE_CHECK([whether more special flags are required for pthreads],
+            [ax_cv_PTHREAD_SPECIAL_FLAGS],
+            [ax_cv_PTHREAD_SPECIAL_FLAGS=no
+             case $host_os in
+             solaris*)
+             ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
+             ;;
+             esac
+            ])
+        AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
+               test "x$ax_pthread_special_flags_added" != "xyes"],
+              [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
+               ax_pthread_special_flags_added=yes])
+
+        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
+            [ax_cv_PTHREAD_PRIO_INHERIT],
+            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
+                                             [[int i = PTHREAD_PRIO_INHERIT;]])],
+                            [ax_cv_PTHREAD_PRIO_INHERIT=yes],
+                            [ax_cv_PTHREAD_PRIO_INHERIT=no])
+            ])
+        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
+               test "x$ax_pthread_prio_inherit_defined" != "xyes"],
+              [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
+               ax_pthread_prio_inherit_defined=yes
+              ])
+
+        CFLAGS="$ax_pthread_save_CFLAGS"
+        LIBS="$ax_pthread_save_LIBS"
+
+        # More AIX lossage: compile with *_r variant
+        if test "x$GCC" != "xyes"; then
+            case $host_os in
+                aix*)
+                AS_CASE(["x/$CC"],
+                    [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+                    [#handle absolute path differently from PATH based program lookup
+                     AS_CASE(["x$CC"],
+                         [x/*],
+                         [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+                         [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+                ;;
+            esac
+        fi
+fi
+
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
+AC_SUBST([PTHREAD_LIBS])
+AC_SUBST([PTHREAD_CFLAGS])
+AC_SUBST([PTHREAD_CC])
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test "x$ax_pthread_ok" = "xyes"; then
+        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
+        :
+else
+        ax_pthread_ok=no
+        $2
+fi
+AC_LANG_POP
+])dnl AX_PTHREAD
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
new file mode 100644 (file)
index 0000000..cae1111
--- /dev/null
@@ -0,0 +1,37 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+#   AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+#   been defined and thus are available for use.  This avoids random issues
+#   where a macro isn't expanded.  Instead the configure script emits a
+#   non-fatal:
+#
+#     ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+#   It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+#   Here's an example:
+#
+#     AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+  m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
diff --git a/m4/ax_sanitizers.m4 b/m4/ax_sanitizers.m4
new file mode 100644 (file)
index 0000000..836d4af
--- /dev/null
@@ -0,0 +1,130 @@
+# ===========================================================================
+#      http://www.gnu.org/software/autoconf-archive/ax_sanitizers.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_SANITIZERS([SANITIZERS], [ENABLED-BY-DEFAULT], [ACTION-SUCCESS])
+#
+# DESCRIPTION
+#
+#   Offers users to enable one or more sanitizers (see
+#   https://github.com/google/sanitizers) with the corresponding
+#   --enable-<sanitizer>-sanitizer option.
+#
+#   SANITIZERS is a whitespace-separated list of sanitizers to offer via
+#   --enable-<sanitizer>-sanitizer options, e.g. "address memory" for the
+#   address sanitizer and the memory sanitizer. If SANITIZERS is not specified,
+#   all known sanitizers to AX_SANITIZERS will be offered, which at the time of
+#   writing are "address memory undefined".
+#   NOTE that SANITIZERS is expanded at autoconf time, not at configure time,
+#   i.e. you cannot use shell variables in SANITIZERS.
+#
+#   ENABLED-BY-DEFAULT is a whitespace-separated list of sanitizers which
+#   should be enabled by default, e.g. "memory undefined". Note that not all
+#   sanitizers can be combined, e.g. memory sanitizer cannot be enabled when
+#   address sanitizer is already enabled.
+#   Set ENABLED-BY-DEFAULT to a single whitespace in order to disable all
+#   sanitizers by default.
+#   ENABLED-BY-DEFAULT is expanded at configure time, so you can use shell
+#   variables.
+#
+#   ACTION-SUCCESS allows to specify shell commands to execute on success, i.e.
+#   when one of the sanitizers was successfully enabled. This is a good place
+#   to call AC_DEFINE for any precompiler constants you might need to make your
+#   code play nice with sanitizers.
+#
+#   The variable ax_enabled_sanitizers contains a whitespace-separated list of
+#   all enabled sanitizers, so that you can print them at the end of configure,
+#   if you wish.
+#
+#   The additional --enable-sanitizers option allows users to enable/disable
+#   all sanitizers, effectively overriding ENABLED-BY-DEFAULT.
+#
+# EXAMPLES
+#
+#   AX_SANITIZERS([address])
+#     dnl offer users to enable address sanitizer via --enable-address-sanitizer
+#
+#   is_debug_build=…
+#   if test "x$is_debug_build" = "xyes"; then
+#     default_sanitizers="address memory"
+#   else
+#     default_sanitizers=
+#   fi
+#   AX_SANITIZERS([address memory], [$default_sanitizers])
+#     dnl enable address sanitizer and memory sanitizer by default for debug
+#     dnl builds, e.g. when building from git instead of a dist tarball.
+#
+#   AX_SANITIZERS(, , [
+#     AC_DEFINE([SANITIZERS_ENABLED],
+#               [],
+#               [At least one sanitizer was enabled])])
+#     dnl enable all sanitizers known to AX_SANITIZERS by default and set the
+#     dnl SANITIZERS_ENABLED precompiler constant.
+#
+#   AX_SANITIZERS(, [ ])
+#     dnl provide all sanitizers, but enable none by default.
+#
+# LICENSE
+#
+#   Copyright (c) 2016 Michael Stapelberg <michael@i3wm.org>
+#
+#   Copying and distribution of this file, with or without modification,
+#   are permitted in any medium without royalty provided the copyright
+#   notice and this notice are preserved.  This file is offered as-is,
+#   without any warranty.
+
+AC_DEFUN([AX_SANITIZERS],
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+AC_ARG_ENABLE(sanitizers,
+  AS_HELP_STRING(
+    [--enable-sanitizers],
+    [enable all known sanitizers]),
+  [ax_sanitizers_default=$enableval],
+  [ax_sanitizers_default=])
+ax_enabled_sanitizers=
+m4_foreach_w([mysan], m4_default($1, [address memory undefined]), [
+  dnl If ax_sanitizers_default is unset, i.e. the user neither explicitly
+  dnl enabled nor explicitly disabled all sanitizers, we get the default value
+  dnl for this sanitizer based on whether it is listed in ENABLED-BY-DEFAULT.
+  AS_IF([test "x$ax_sanitizers_default" = "x"], [dnl
+          ax_sanitizer_default=
+          for mycheck in m4_default([$2], [address memory undefined]); do
+            AS_IF([test "x$mycheck" = "x[]mysan"], [ax_sanitizer_default=yes])
+          done
+          AS_IF([test "x$ax_sanitizer_default" = "x"], [ax_sanitizer_default=no])
+        ],
+        [ax_sanitizer_default=$ax_sanitizers_default])
+  AC_ARG_ENABLE(mysan[]-sanitizer,
+    AS_HELP_STRING(
+      [--enable-[]mysan[]-sanitizer],
+      [enable -fsanitize=mysan]),
+    [ax_sanitizer_enabled=$enableval],
+    [ax_sanitizer_enabled=$ax_sanitizer_default])
+
+AS_IF([test "x$ax_sanitizer_enabled" = "xyes"], [
+dnl Not using AX_APPEND_COMPILE_FLAGS and AX_APPEND_LINK_FLAGS because they
+dnl lack the ability to specify ACTION-SUCCESS.
+  AX_CHECK_COMPILE_FLAG([-fsanitize=[]mysan], [
+    AX_CHECK_LINK_FLAG([-fsanitize=[]mysan], [
+      AX_APPEND_FLAG([-fsanitize=[]mysan], [])
+dnl If and only if libtool is being used, LDFLAGS needs to contain -Wc,-fsanitize=….
+dnl See e.g. https://sources.debian.net/src/systemd/231-7/configure.ac/?hl=128#L135
+dnl TODO: how can recognize that situation and add -Wc,?
+      AX_APPEND_FLAG([-fsanitize=[]mysan], [LDFLAGS])
+dnl TODO: add -fPIE -pie for memory
+      # -fno-omit-frame-pointer results in nicer stack traces in error
+      # messages, see http://clang.llvm.org/docs/AddressSanitizer.html#usage
+      AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], [
+        AX_APPEND_FLAG([-fno-omit-frame-pointer], [])])
+dnl TODO: at least for clang, we should specify exactly -O1, not -O2 or -O0, so that performance is reasonable but stacktraces are not tampered with (due to inlining), see http://clang.llvm.org/docs/AddressSanitizer.html#usage
+      m4_default([$3], :)
+      ax_enabled_sanitizers="[]mysan $ax_enabled_sanitizers"
+    ])
+  ])
+])
+])dnl
+])dnl AX_SANITIZERS
diff --git a/man/Makefile b/man/Makefile
deleted file mode 100644 (file)
index e4cee0c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-       $(MAKE) -C .. mans
-
-clean:
-       $(MAKE) -C .. clean-mans
-
-.PHONY: all clean
diff --git a/man/asciidoc.conf b/man/asciidoc.conf
deleted file mode 100644 (file)
index 11e7650..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-ifdef::doctype-manpage[]
-ifdef::backend-docbook[]
-[header]
-template::[header-declarations]
-<refentry>
-<refmeta>
-<refentrytitle>{mantitle}</refentrytitle>
-<manvolnum>{manvolnum}</manvolnum>
-<refmiscinfo class="source">i3</refmiscinfo>
-<refmiscinfo class="version">4.12</refmiscinfo>
-<refmiscinfo class="manual">i3 Manual</refmiscinfo>
-</refmeta>
-<refnamediv>
-  <refname>{manname}</refname>
-  <refpurpose>{manpurpose}</refpurpose>
-</refnamediv>
-endif::backend-docbook[]
-endif::doctype-manpage[]
diff --git a/man/asciidoc.conf.in b/man/asciidoc.conf.in
new file mode 100644 (file)
index 0000000..e9a9ea2
--- /dev/null
@@ -0,0 +1,18 @@
+ifdef::doctype-manpage[]
+ifdef::backend-docbook[]
+[header]
+template::[header-declarations]
+<refentry>
+<refmeta>
+<refentrytitle>{mantitle}</refentrytitle>
+<manvolnum>{manvolnum}</manvolnum>
+<refmiscinfo class="source">i3</refmiscinfo>
+<refmiscinfo class="version">@PACKAGE_VERSION@</refmiscinfo>
+<refmiscinfo class="manual">i3 Manual</refmiscinfo>
+</refmeta>
+<refnamediv>
+  <refname>{manname}</refname>
+  <refpurpose>{manpurpose}</refpurpose>
+</refnamediv>
+endif::backend-docbook[]
+endif::doctype-manpage[]
diff --git a/man/man.mk b/man/man.mk
deleted file mode 100644 (file)
index e0df386..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-DISTCLEAN_TARGETS += clean-mans
-
-A2X = a2x
-POD2MAN = pod2man
-
-A2X_MAN_CALL = $(V_A2X)$(A2X) -f manpage --asciidoc-opts="-f man/asciidoc.conf" $(A2X_FLAGS) $<
-POD2MAN_CALL = $(V_POD2MAN)$(POD2MAN) --utf8 $< > $@
-
-MANS_ASCIIDOC = \
-       man/i3.1 \
-       man/i3bar.1 \
-       man/i3-msg.1 \
-       man/i3-input.1 \
-       man/i3-nagbar.1 \
-       man/i3-config-wizard.1 \
-       man/i3-migrate-config-to-v4.1 \
-       man/i3-sensible-editor.1 \
-       man/i3-sensible-pager.1 \
-       man/i3-sensible-terminal.1 \
-       man/i3-dump-log.1
-
-MANS_POD = \
-       man/i3-dmenu-desktop.1 \
-       man/i3-save-tree.1
-
-MANS = \
-       $(MANS_ASCIIDOC) \
-       $(MANS_POD)
-
-mans: $(MANS)
-
-$(MANS_ASCIIDOC): %.1: %.man man/asciidoc.conf
-       $(A2X_MAN_CALL)
-
-$(MANS_POD): man/%.1: %
-       $(POD2MAN_CALL)
-
-clean-mans:
-       for file in $(notdir $(MANS)); \
-       do \
-               rm -f man/$${file} man/$${file%.*}.html man/$${file%.*}.xml; \
-       done
index cc59d6a2af7ce033fdd565eace9e277446e8f59b..9101332c100761bc841e2367e2c8ec88138b40fc 100755 (executable)
@@ -55,13 +55,17 @@ git checkout -b release-${RELEASE_VERSION}
 cp "${STARTDIR}/RELEASE-NOTES-${RELEASE_VERSION}" "RELEASE-NOTES-${RELEASE_VERSION}"
 git add RELEASE-NOTES-${RELEASE_VERSION}
 git rm RELEASE-NOTES-${PREVIOUS_VERSION}
-sed -i "s,<refmiscinfo class=\"version\">[^<]*</refmiscinfo>,<refmiscinfo class=\"version\">${RELEASE_VERSION}</refmiscinfo>,g" man/asciidoc.conf
+sed -i "s,RELEASE-NOTES-${PREVIOUS_VERSION},RELEASE-NOTES-${RELEASE_VERSION},g" Makefile.am
+sed -i "s/AC_INIT(\[i3\], \[${PREVIOUS_VERSION}\]/AC_INIT([i3], [${RELEASE_VERSION}]/" configure.ac
 echo "${RELEASE_VERSION} ($(date +%F))" > I3_VERSION
 git add I3_VERSION
 git commit -a -m "release i3 ${RELEASE_VERSION}"
 git tag "${RELEASE_VERSION}" -m "release i3 ${RELEASE_VERSION}" --sign --local-user=0x4AC8EE1D
 
-make dist
+autoreconf -fi
+mkdir build
+(cd build && ../configure && make dist-bzip2 -j8)
+cp build/i3-${RELEASE_VERSION}.tar.bz2 .
 
 echo "Differences in the release tarball file lists:"
 
@@ -157,7 +161,7 @@ git add downloads/RELEASE-NOTES-${RELEASE_VERSION}.txt
 sed -i "s,<h2>Documentation for i3 v[^<]*</h2>,<h2>Documentation for i3 v${RELEASE_VERSION}</h2>,g" docs/index.html
 sed -i "s,<span style=\"margin-left: 2em; color: #c0c0c0\">[^<]*</span>,<span style=\"margin-left: 2em; color: #c0c0c0\">${RELEASE_VERSION}</span>,g" index.html
 sed -i "s,The current stable version is .*$,The current stable version is ${RELEASE_VERSION}.,g" downloads/index.html
-sed -i "s,<tbody>,<tbody>\n  <tr>\n    <td>${RELEASE_VERSION}</td>\n    <td><a href=\"/downloads/i3-${RELEASE_VERSION}.tar.bz2\">i3-${RELEASE_VERSION}.tar.bz2</a></td>\n    <td>$(ls -lh ../i3/i3-${RELEASE_VERSION}.tar.bz2 | awk -F " " {'print $5'} | sed 's/K$/ KiB/g')</td>\n    <td><a href=\"/downloads/i3-${RELEASE_VERSION}.tar.bz2.asc\">signature</a></td>\n    <td>$(date +'%Y-%m-%d')</td>\n    <td><a href=\"/downloads/RELEASE-NOTES-${RELEASE_VERSION}.txt\">release notes</a></td>\n  </tr>\n,g" downloads/index.html
+sed -i "s,<tbody>,<tbody>\n  <tr>\n    <td>${RELEASE_VERSION}</td>\n    <td><a href=\"/downloads/i3-${RELEASE_VERSION}.tar.bz2\">i3-${RELEASE_VERSION}.tar.bz2</a></td>\n    <td>$(LC_ALL=en_US.UTF-8 ls -lh ../i3/i3-${RELEASE_VERSION}.tar.bz2 | awk -F " " {'print $5'} | sed 's/K$/ KiB/g' | sed 's/M$/ MiB/g')</td>\n    <td><a href=\"/downloads/i3-${RELEASE_VERSION}.tar.bz2.asc\">signature</a></td>\n    <td>$(date +'%Y-%m-%d')</td>\n    <td><a href=\"/downloads/RELEASE-NOTES-${RELEASE_VERSION}.txt\">release notes</a></td>\n  </tr>\n,g" downloads/index.html
 
 git commit -a -m "add ${RELEASE_VERSION} release"
 
diff --git a/share/applications/i3.desktop b/share/applications/i3.desktop
new file mode 100644 (file)
index 0000000..2844592
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=i3
+NoDisplay=true
+GenericName=A dynamic tiling window manager
+Comment=improved dynamic tiling window manager
+Exec=i3
+X-GNOME-WMName=i3
+X-GNOME-Autostart-Phase=WindowManager
+X-GNOME-Provides=windowmanager
+X-GNOME-Autostart-Notify=false
diff --git a/share/xsessions/i3-with-shmlog.desktop b/share/xsessions/i3-with-shmlog.desktop
new file mode 100644 (file)
index 0000000..3c63450
--- /dev/null
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=i3 (with debug log)
+Comment=improved dynamic tiling window manager
+Exec=i3-with-shmlog
+Type=Application
+Keywords=tiling;wm;windowmanager;window;manager;
diff --git a/share/xsessions/i3.desktop b/share/xsessions/i3.desktop
new file mode 100644 (file)
index 0000000..11a64e2
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=i3
+Comment=improved dynamic tiling window manager
+Exec=i3
+TryExec=i3
+Type=Application
+X-LightDM-DesktopName=i3
+DesktopNames=i3
+Keywords=tiling;wm;windowmanager;window;manager;
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644 (file)
index 6a37f56..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
-       $(MAKE) -C .. i3
-
-install:
-       $(MAKE) -C .. install-i3
-
-clean:
-       $(MAKE) -C .. clean-i3
-
-.PHONY: all install clean
index 6c563357d14c5adb6fabd100a0230d4f7bf565f4..a0f5d5a747b79f02c23d1dfe478b5ef59c9e03ae 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "assignments.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 788c10f2253ed6605d735010cbfda77084640ebe..913741b4fd96cdfd3484fd3d55f9c8c9a738297e 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "click.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 58641d6ad627bcd36ade1ae766aba4d1487d814f..b91c71a47c76389c193e5ad7ab5ed0f16d71a63e 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "commands.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -9,6 +7,8 @@
  * commands.c: all command functions (see commands_parser.c)
  *
  */
+#include "all.h"
+
 #include <stdint.h>
 #include <float.h>
 #include <stdarg.h>
@@ -17,7 +17,6 @@
 #include <sanitizer/lsan_interface.h>
 #endif
 
-#include "all.h"
 #include "shmlog.h"
 
 // Macros to make the YAJL API a bit easier to use.
index cdd35e459b904d7241cb599eb4abb55ef0e2e271..98f0665907dd36d759abebd4a55b09024a2f55c6 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "commands_parser.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -25,6 +23,8 @@
  * instead of actually calling any function).
  *
  */
+#include "all.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -32,8 +32,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include "all.h"
-
 // Macros to make the YAJL API a bit easier to use.
 #define y(x, ...) (command_output.json_gen != NULL ? yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__) : 0)
 #define ystr(str) (command_output.json_gen != NULL ? yajl_gen_string(command_output.json_gen, (unsigned char *)str, strlen(str)) : 0)
index a104028bf831c7d21d7295b210cbeb3c99d08959..362254151b01397fb66a1b06fb92ff65a9bf2da6 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "con.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -12,6 +10,7 @@
  *
  */
 #include "all.h"
+
 #include "yajl_utils.h"
 
 static void con_on_remove_child(Con *con);
index c2824ca2cdeec4fd72830a44c8deb980bdc057be..d4441d5dfec8da61c64f1f6e92ee60ab20ef861b 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "config.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -11,6 +9,7 @@
  *
  */
 #include "all.h"
+
 #include <xkbcommon/xkbcommon.h>
 
 char *current_configpath = NULL;
index 05c19c70628b1d0fff12e286a45e97c63b4f0352..6b5464f19575985365d0e577f131f5664b9e64c4 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "config_directives.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -9,11 +7,11 @@
  * config_directives.c: all config storing functions (see config_parser.c)
  *
  */
+#include "all.h"
+
 #include <float.h>
 #include <stdarg.h>
 
-#include "all.h"
-
 /*******************************************************************************
  * Criteria functions.
  ******************************************************************************/
index 2a8847300340ea1a5ed44f99d02c9fc05b924cb0..a82658698e943b37c9a635c148ca3f729f30f532 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "config_parser.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -25,6 +23,8 @@
  *    nearest <error> token.
  *
  */
+#include "all.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -37,8 +37,6 @@
 #include <fcntl.h>
 #include <xcb/xcb_xrm.h>
 
-#include "all.h"
-
 // Macros to make the YAJL API a bit easier to use.
 #define y(x, ...) yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__)
 #define ystr(str) yajl_gen_string(command_output.json_gen, (unsigned char *)str, strlen(str))
index bb880b2f52e1ff67b7fe6c4e82510c51afdb6c75..ea4ca9970b938ccf32bde42926a42d5c2db62508 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "debug.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -10,6 +8,8 @@
  *          events.  This code is from xcb-util.
  *
  */
+#include <config.h>
+
 #include <stdio.h>
 #include <xcb/xcb.h>
 
index c82610ed38ff2856975a8ae37838b947a4f23e1b..0e650e817378174f39a7bd5def167b144a508769 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "key_press.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -10,6 +8,8 @@
  *                    i3 --moreversion.
  *
  */
+#include "all.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
@@ -17,7 +17,6 @@
 #include <sys/un.h>
 #include <fcntl.h>
 #include <time.h>
-#include "all.h"
 
 static bool human_readable_key, loaded_config_file_name_key;
 static char *human_readable_version, *loaded_config_file_name;
index 5459c7e922ea9c93437d6de94886d902cdc32e9a..f4bb049ae6c35c60ff3508bbed2b0fd126dd7681 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "ewmh.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 3df0e246a28661a0d0a0d29504928442bbeff3ef..b898ce987db9120498870056eb1e2ab15fb72b86 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "fake_outputs.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index e9c7a80177611f8e383d8df018ed2e9ccc39b83f..616602c02253a77c1459dbcabe8ca0037a6f2dca 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "floating.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index bd391176517cf7881cdd1b0605cb646bf21b0915..7dfacef78f5b56a6c17e5481dbc81a5e6f117956 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "handlers.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
diff --git a/src/i3.mk b/src/i3.mk
deleted file mode 100644 (file)
index de3f684..0000000
--- a/src/i3.mk
+++ /dev/null
@@ -1,102 +0,0 @@
-ALL_TARGETS += i3 test-tools
-INSTALL_TARGETS += install-i3
-CLEAN_TARGETS += clean-i3
-
-i3_SOURCES           := $(filter-out $(i3_SOURCES_GENERATED),$(wildcard src/*.c))
-i3_HEADERS_CMDPARSER := $(wildcard include/GENERATED_*.h)
-i3_HEADERS           := $(filter-out $(i3_HEADERS_CMDPARSER),$(wildcard include/*.h))
-i3_CFLAGS             = $(XKB_COMMON_CFLAGS) $(XKB_COMMON_X11_CFLAGS) $(XCB_CFLAGS) $(XCB_KBD_CFLAGS) $(XCB_WM_CFLAGS) $(XCB_CURSOR_CFLAGS) $(XCB_XRM_CFLAGS) $(PANGO_CFLAGS) $(YAJL_CFLAGS) $(LIBEV_CFLAGS) $(PCRE_CFLAGS) $(LIBSN_CFLAGS)
-i3_LIBS               = $(XKB_COMMON_LIBS) $(XKB_COMMON_X11_LIBS) $(XCB_LIBS) $(XCB_XKB_LIBS) $(XCB_KBD_LIBS) $(XCB_WM_LIBS) $(XCB_CURSOR_LIBS) $(XCB_XRM_LIBS) $(PANGO_LIBS) $(YAJL_LIBS) $(LIBEV_LIBS) $(PCRE_LIBS) $(LIBSN_LIBS) -lm
-ifneq ($(UNAME),OpenBSD)
-i3_LIBS               += -lpthread
-endif
-
-# When using clang, we use pre-compiled headers to speed up the build. With
-# gcc, this actually makes the build slower.
-ifeq ($(CC),clang)
-i3_HEADERS_DEP       := $(i3_HEADERS) include/all.h.pch
-PCH_FLAGS            := -include include/all.h
-else
-i3_HEADERS_DEP       := $(i3_HEADERS)
-PCH_FLAGS            :=
-endif
-
-i3_OBJECTS := $(i3_SOURCES_GENERATED:.c=.o) $(i3_SOURCES:.c=.o)
-
-# The basename/pwd calls are for canonicalizing the path: Instead
-# of src/main.c, we will see something like ../i3-4.2/src/main.c in
-# debugger backtraces, making it clearer which code belongs to i3 and
-# which code doesn’t.
-# We only do this for src/ since all the other subdirectories contain i3 in
-# their name already.
-canonical_path := ../$(shell basename $(shell pwd -P))
-
-include/all.h.pch: $(i3_HEADERS)
-       echo "[i3] PCH all.h"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -x c-header include/all.h -o include/all.h.pch
-
-src/version.o: src/version.c LAST_VERSION $(i3_HEADERS_DEP)
-       echo "[i3] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(PCH_FLAGS) -c -o $@ ${canonical_path}/$<
-
-src/%.o: src/%.c $(i3_HEADERS_DEP)
-       echo "[i3] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(PCH_FLAGS) -c -o $@ ${canonical_path}/$<
-
-test-tools: test.commands_parser test.config_parser
-
-test.commands_parser: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp libi3.a
-       echo "[i3] Link test.commands_parser"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -g -o test.commands_parser $< $(LIBS) $(i3_LIBS)
-
-test.config_parser: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stamp libi3.a
-       echo "[i3] Link test.config_parser"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -DTEST_PARSER -g -o test.config_parser $< $(LIBS) $(i3_LIBS)
-
-src/commands_parser.o: src/commands_parser.c $(i3_HEADERS_DEP) i3-command-parser.stamp
-       echo "[i3] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
-
-src/config_parser.o: src/config_parser.c $(i3_HEADERS_DEP) i3-config-parser.stamp
-       echo "[i3] CC $<"
-       $(CC) $(I3_CPPFLAGS) $(CPPFLAGS) $(i3_CFLAGS) $(I3_CFLAGS) $(CFLAGS) -c -o $@ ${canonical_path}/$<
-
-i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
-       echo "[i3] Generating command parser"
-       (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/commands.spec --prefix=command)
-       touch $@
-
-i3-config-parser.stamp: generate-command-parser.pl parser-specs/config.spec
-       echo "[i3] Generating config parser"
-       (cd $(TOPDIR)/include; ../generate-command-parser.pl --input=../parser-specs/config.spec --prefix=config)
-       touch $@
-
-i3: libi3.a $(i3_OBJECTS)
-       echo "[i3] Link i3"
-       $(CC) $(CFLAGS) $(I3_LDFLAGS) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS) $(i3_LIBS)
-
-install-i3: i3
-       echo "[i3] Install"
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/bin
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/i3
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(EXEC_PREFIX)/include/i3
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
-       $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/applications
-       $(INSTALL) -m 0755 i3 $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(LN) -sf i3 $(DESTDIR)$(EXEC_PREFIX)/bin/i3-with-shmlog
-       $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(INSTALL) -m 0755 i3-sensible-editor $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(INSTALL) -m 0755 i3-sensible-pager $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(INSTALL) -m 0755 i3-sensible-terminal $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(INSTALL) -m 0755 i3-save-tree $(DESTDIR)$(EXEC_PREFIX)/bin/
-       $(INSTALL) -m 0755 i3-dmenu-desktop $(DESTDIR)$(EXEC_PREFIX)/bin/
-       test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
-       test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
-       $(INSTALL) -m 0644 i3.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3.desktop
-       $(INSTALL) -m 0644 i3-with-shmlog.xsession.desktop $(DESTDIR)$(PREFIX)/share/xsessions/i3-with-shmlog.desktop
-       $(INSTALL) -m 0644 i3.applications.desktop $(DESTDIR)$(PREFIX)/share/applications/i3.desktop
-       $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(EXEC_PREFIX)/include/i3/
-
-clean-i3:
-       echo "[i3] Clean"
-       rm -f $(i3_OBJECTS) $(i3_SOURCES_GENERATED) $(i3_HEADERS_CMDPARSER) include/loglevels.h loglevels.tmp include/all.h.pch i3-command-parser.stamp i3-config-parser.stamp i3 test.config_parser test.commands_parser src/*.gcno src/cfgparse.* src/cmdparse.* LAST_VERSION
index ddc09294c8a435414d155c2c09c4a38d7d66f3b0..c0dfb1ecb7dd1e6eaa5e878693d64c4d11c18521 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "ipc.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -10,6 +8,7 @@
  *
  */
 #include "all.h"
+
 #include "yajl_utils.h"
 
 #include <stdint.h>
index 6760e35bc5219b4389bccbf3b0713f1cacc0749c..d16174f8c8f00a2488852c6176da5a163d7dfc3c 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "key_press.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index a3b447563ab23157cd83a6b928ebdb63c85c3ede..7004a85970b8752b1ecc8d918e7f4993a47c0c10 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "load_layout.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index e9a1160db17e56a204ca62b718760f44a9d91e70..1c33649a52d176283999a324e0c1ee6a5ef165c0 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "log.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -9,6 +7,8 @@
  * log.c: Logging functions.
  *
  */
+#include <config.h>
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
index f94a8941b3c0c602ef861703731d017995a7f120..4d9fd5a51c20c800d712e53a75ac1fd499a775e7 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "main.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -9,6 +7,8 @@
  * main.c: Initialization, main loop
  *
  */
+#include "all.h"
+
 #include <ev.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -19,7 +19,6 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <libgen.h>
-#include "all.h"
 #include "shmlog.h"
 
 #include "sd-daemon.h"
index fd9226e4978191bd177a94f7768c2d6e5f6dad2d..81ee16fdcc7fc9f0ef77f00084659f7b1b080168 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "manage.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -10,6 +8,7 @@
  *
  */
 #include "all.h"
+
 #include "yajl_utils.h"
 
 #include <yajl/yajl_gen.h>
index ac9ddaf98168a3b3af0eed29e73c6023b27c3067..4d87c560e6425f525d19e3074ce9cf713ee4c042 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "match.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 25c658ce1a2f9aa715b4d5ce5737c10f57d8317a..70c8c7885521c52724eaa29c1ec3724ad535ed85 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "move.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 1a9f6129ef392ac6e6e84f53f174800174b6bf13..0f2bd61726d3930194ac5a7edf4d420db3fde9db 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "output.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 512e0d2833f9c5bb8d6ba326e9469a91b598a3da..51255619698fb7226b5b07d2293a0d57ea9ed136 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "randr.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 12c0b67f01175a6ac616e03ffd6c50714dfc8726..296b91dd10cf24b03966779c522a5627f3250036 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "regex.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 7ee501f01cc93b16cb784f2df3c49fc0f1aea8cf..85548f26051307b6fb3a7906713750700dce214d 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "render.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 5d9eb2eba52b608788c7c048b1f0870e3a2b71ee..f07fcec6a169fb9e478d48d8161a9d3ac3bc2ea0 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "resize.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index da018b9eb2a5ed5928712dd4844552a07b34e75a..131196e9eb4f65d430c1cd571b6b3d1f4558638c 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "restore_layout.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 6d83a558ccdc738e42941588536b45806ff82714..9018ad3ffc233c0037b000eb40837f58cf8a3f41 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "scratchpad.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 400cd5a59d88d478f87b94e4800f77e7f8ac5096..79f90d9a72a0f8aa8953c57710c8f8e0f65ff91e 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "sighandler.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 2a6bc0026a06a29dd2c4c04996f8066a3cdf6995..166842e07c04e8471123ec331012837ffe189220 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "startup.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -13,6 +11,7 @@
  *
  */
 #include "all.h"
+
 #include "sd-daemon.h"
 
 #include <sys/types.h>
index e848a6ac4eb322732bd6bdec97c917acee4391de..6e128363913319decb436054d39526ec2b104b75 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "tree.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 15796d887cb95edfd2595718835ed9aad72c4c9d..cfe4c953db029c1333e4f9ed90396cb8d79c58a6 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "util.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 6e385ada754e9dac38c9d9242adc6983fa89c59a..1244711ad8b8f370b9bfa8706cead773920dcb0a 100644 (file)
@@ -8,4 +8,6 @@
  * and used dynamically without recompiling every object file.
  *
  */
+#include <config.h>
+
 const char *i3_version = I3_VERSION;
index d10811f587811d6d585b7f439673a06fe57bf195..db6215d0cffcd93f15b696d264d39d5419ee3568 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "window.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 0da0a3780520583c2416a36357964775d16480ae..d7f2ce7c55e8ce631b18a2f41aede336dc48983c 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "workspace.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
diff --git a/src/x.c b/src/x.c
index 9a387749569e87092c1cc5709cdf0d2a99b37087..8d7d3dd803098ca61ca021c43aeed3805f2b591a 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "x.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 630c68f9cf6ccb847aa236a57378342948354e92..900840a20a419b19832680d4d9a9c20195227065 100644 (file)
--- a/src/xcb.c
+++ b/src/xcb.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "xcb.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
index 1e1e23b0dedadd2d6ae342e71a8edded2d541088..cbfe808bcd11e625909db179fe9d68e787ceba20 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "xcursor.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -9,6 +7,8 @@
  * xcursor.c: xcursor support for themed cursors.
  *
  */
+#include <config.h>
+
 #include <assert.h>
 #include <xcb/xcb_cursor.h>
 
index ddf98375bffb1cd7a6854ea189e833b1fdcf97cd..25bfa6b194970257fffeaa90cc4365605dbc3acb 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "xinerama.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl
deleted file mode 100755 (executable)
index 14c0a15..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-#!/usr/bin/env perl
-# vim:ts=4:sw=4:expandtab
-# © 2010 Michael Stapelberg and contributors
-package complete_run;
-use strict;
-use warnings;
-use v5.10;
-use utf8;
-# the following are modules which ship with Perl (>= 5.10):
-use Pod::Usage;
-use File::Temp qw(tempfile tempdir);
-use Getopt::Long;
-use POSIX ();
-use TAP::Harness;
-use TAP::Parser;
-use TAP::Parser::Aggregator;
-use Time::HiRes qw(time);
-use IO::Handle;
-
-my $dirname;
-
-BEGIN {
-    use File::Basename;
-    use Cwd qw(abs_path);
-
-    # fileparse()[1] contains the directory portion of the specified path.
-    # See File::Basename(3p) for more details.
-    $dirname = (fileparse(abs_path($0)))[1];
-}
-
-# these are shipped with the testsuite
-use lib $dirname . 'lib';
-use i3test::Util qw(slurp);
-use StartXServer;
-use StatusLine;
-use TestWorker;
-# the following modules are not shipped with Perl
-use AnyEvent;
-use AnyEvent::Util;
-use AnyEvent::Handle;
-use AnyEvent::I3 qw(:all);
-use X11::XCB::Connection;
-use JSON::XS; # AnyEvent::I3 depends on it, too.
-
-binmode STDOUT, ':utf8';
-binmode STDERR, ':utf8';
-
-# Close superfluous file descriptors which were passed by running in a VIM
-# subshell or situations like that.
-AnyEvent::Util::close_all_fds_except(0, 1, 2);
-
-# convenience wrapper to write to the log file
-my $log;
-sub Log { say $log "@_" }
-
-my %timings;
-my $help = 0;
-# Number of tests to run in parallel. Important to know how many Xephyr
-# instances we need to start (unless @displays are given). Defaults to
-# num_cores * 2.
-my $parallel = undef;
-my @displays = ();
-my %options = (
-    valgrind => 0,
-    strace => 0,
-    xtrace => 0,
-    coverage => 0,
-    restart => 0,
-);
-my $keep_xserver_output = 0;
-
-my $result = GetOptions(
-    "coverage-testing" => \$options{coverage},
-    "keep-xserver-output" => \$keep_xserver_output,
-    "valgrind" => \$options{valgrind},
-    "strace" => \$options{strace},
-    "xtrace" => \$options{xtrace},
-    "display=s" => \@displays,
-    "parallel=i" => \$parallel,
-    "help|?" => \$help,
-);
-
-pod2usage(-verbose => 2, -exitcode => 0) if $help;
-
-chdir $dirname or die "Could not chdir into $dirname";
-
-# Check for missing executables
-my @binaries = qw(
-                   ../i3
-                   ../i3bar/i3bar
-                   ../i3-config-wizard/i3-config-wizard
-                   ../i3-dump-log/i3-dump-log
-                   ../i3-input/i3-input
-                   ../i3-msg/i3-msg
-                   ../i3-nagbar/i3-nagbar
-               );
-
-foreach my $binary (@binaries) {
-    die "$binary executable not found, did you run “make”?" unless -e $binary;
-    die "$binary is not an executable" unless -x $binary;
-}
-
-if ($options{coverage}) {
-    qx(command -v lcov &> /dev/null);
-    die "Cannot find lcov needed for coverage testing." if $?;
-    qx(command -v genhtml &> /dev/null);
-    die "Cannot find genhtml needed for coverage testing." if $?;
-
-    # clean out the counters that may be left over from previous tests.
-    qx(lcov -d ../ --zerocounters &> /dev/null);
-}
-
-qx(Xephyr -help 2>&1);
-die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on Debian)." if $?;
-
-@displays = split(/,/, join(',', @displays));
-@displays = map { s/ //g; $_ } @displays;
-
-# 2: get a list of all testcases
-my @testfiles = @ARGV;
-
-# if no files were passed on command line, run all tests from t/
-@testfiles = <t/*.t> if @testfiles == 0;
-
-my $numtests = scalar @testfiles;
-
-# No displays specified, let’s start some Xephyr instances.
-if (@displays == 0) {
-    @displays = start_xserver($parallel, $numtests, $keep_xserver_output);
-}
-
-# 1: create an output directory for this test-run
-my $outdir = "testsuite-";
-$outdir .= POSIX::strftime("%Y-%m-%d-%H-%M-%S-", localtime());
-$outdir .= `git describe --tags`;
-chomp($outdir);
-mkdir($outdir) or die "Could not create $outdir";
-unlink("latest") if -l "latest";
-symlink("$outdir", "latest") or die "Could not symlink latest to $outdir";
-
-
-# connect to all displays for two reasons:
-# 1: check if the display actually works
-# 2: keep the connection open so that i3 is not the only client. this prevents
-#    the X server from exiting
-my @single_worker;
-for my $display (@displays) {
-    my $screen;
-    my $x = X11::XCB::Connection->new(display => $display);
-    if ($x->has_error) {
-        die "Could not connect to display $display\n";
-    } else {
-        # start a TestWorker for each display
-        push @single_worker, worker($display, $x, $outdir, \%options);
-    }
-}
-
-# Read previous timing information, if available. We will be able to roughly
-# predict the test duration and schedule a good order for the tests.
-my $timingsjson = slurp('.last_run_timings.json') if -e '.last_run_timings.json';
-%timings = %{decode_json($timingsjson)} if length($timingsjson) > 0;
-
-# Re-order the files so that those which took the longest time in the previous
-# run will be started at the beginning to not delay the whole run longer than
-# necessary.
-@testfiles = map  { $_->[0] }
-             sort { $b->[1] <=> $a->[1] }
-             map  { [$_, $timings{$_} // 999] } @testfiles;
-
-# Run 000-load-deps.t first to bail out early when dependencies are missing.
-my $loadtest = "t/000-load-deps.t";
-if ((scalar grep { $_ eq $loadtest } @testfiles) > 0) {
-    @testfiles = ($loadtest, grep { $_ ne $loadtest } @testfiles);
-}
-
-printf("\nRough time estimate for this run: %.2f seconds\n\n", $timings{GLOBAL})
-    if exists($timings{GLOBAL});
-
-# Forget the old timings, we don’t necessarily run the same set of tests as
-# before. Otherwise we would end up with left-overs.
-%timings = (GLOBAL => time());
-
-my $logfile = "$outdir/complete-run.log";
-open $log, '>', $logfile or die "Could not create '$logfile': $!";
-$log->autoflush(1);
-say "Writing logfile to '$logfile'...";
-
-# 3: run all tests
-my @done;
-my $num = @testfiles;
-my $harness = TAP::Harness->new({ });
-
-my $aggregator = TAP::Parser::Aggregator->new();
-$aggregator->start();
-
-status_init(displays => \@displays, tests => $num);
-
-my $single_cv = AE::cv;
-
-# We start tests concurrently: For each display, one test gets started. Every
-# test starts another test after completing.
-for (@single_worker) {
-    $single_cv->begin;
-    take_job($_, $single_cv, \@testfiles);
-}
-
-$single_cv->recv;
-
-$aggregator->stop();
-
-# print empty lines to separate failed tests from statuslines
-print "\n\n";
-
-for (@done) {
-    my ($test, $output) = @$_;
-    say "no output for $test" unless $output;
-    Log "output for $test:";
-    Log $output;
-    # print error messages of failed tests
-    say for $output =~ /^not ok.+\n+((?:^#.+\n)+)/mg
-}
-
-# 4: print summary
-$harness->summary($aggregator);
-
-close $log;
-
-# 5: Save the timings for better scheduling/prediction next run.
-$timings{GLOBAL} = time() - $timings{GLOBAL};
-open(my $fh, '>', '.last_run_timings.json');
-print $fh encode_json(\%timings);
-close($fh);
-
-# 6: Print the slowest test files.
-my @slowest = map  { $_->[0] }
-              sort { $b->[1] <=> $a->[1] }
-              map  { [$_, $timings{$_}] }
-              grep { !/^GLOBAL$/ } keys %timings;
-say '';
-say 'The slowest tests are:';
-printf("\t%s with %.2f seconds\n", $_, $timings{$_})
-    for @slowest[0..($#slowest > 4 ? 4 : $#slowest)];
-
-# When we are running precisely one test, print the output. Makes developing
-# with a single testcase easier.
-if ($numtests == 1) {
-    say '';
-    say 'Test output:';
-    say slurp($logfile);
-}
-
-END { cleanup() }
-
-if ($options{coverage}) {
-    print("\nGenerating test coverage report...\n");
-    qx(lcov -d ../ -b ../ --capture -o latest/i3-coverage.info);
-    qx(genhtml -o latest/i3-coverage latest/i3-coverage.info);
-    if ($?) {
-        print("Could not generate test coverage html. Did you compile i3 with test coverage support?\n");
-    } else {
-        print("Test coverage report generated in latest/i3-coverage\n");
-    }
-}
-
-# Report logfiles that match “(Leak|Address)Sanitizer:”.
-my @logs_with_leaks;
-for my $log (<$outdir/i3-log-for-*>) {
-    if (slurp($log) =~ /(Leak|Address)Sanitizer:/) {
-        push @logs_with_leaks, $log;
-    }
-}
-if (scalar @logs_with_leaks > 0) {
-    say "\nThe following test logfiles contain AddressSanitizer or LeakSanitizer reports:";
-    for my $log (sort @logs_with_leaks) {
-        say "\t$log";
-    }
-}
-
-exit ($aggregator->failed > 0);
-
-#
-# Takes a test from the beginning of @testfiles and runs it.
-#
-# The TAP::Parser (which reads the test output) will get called as soon as
-# there is some activity on the stdout file descriptor of the test process
-# (using an AnyEvent->io watcher).
-#
-# When a test completes and @done contains $num entries, the $cv condvar gets
-# triggered to finish testing.
-#
-sub take_job {
-    my ($worker, $cv, $tests) = @_;
-
-    my $test = shift @$tests
-        or return $cv->end;
-
-    my $display = $worker->{display};
-
-    Log status($display, "$test: starting");
-    $timings{$test} = time();
-    worker_next($worker, $test);
-
-    # create a TAP::Parser with an in-memory fh
-    my $output;
-    my $parser = TAP::Parser->new({
-        source => do { open(my $fh, '<', \$output); $fh },
-    });
-
-    my $ipc = $worker->{ipc};
-
-    my $w;
-    $w = AnyEvent->io(
-        fh => $ipc,
-        poll => 'r',
-        cb => sub {
-            state $tests_completed = 0;
-            state $partial = '';
-
-            sysread($ipc, my $buf, 4096) or die "sysread: $!";
-
-            if ($partial) {
-                $buf = $partial . $buf;
-                $partial = '';
-            }
-
-            # make sure we feed TAP::Parser complete lines so it doesn't blow up
-            if (substr($buf, -1, 1) ne "\n") {
-                my $nl = rindex($buf, "\n");
-                if ($nl == -1) {
-                    $partial = $buf;
-                    return;
-                }
-
-                # strip partial from buffer
-                $partial = substr($buf, $nl + 1, '');
-            }
-
-            # count lines before stripping eof-marker otherwise we might
-            # end up with for (1 .. 0) { } which would effectivly skip the loop
-            my $lines = $buf =~ tr/\n//;
-            my $t_eof = $buf =~ s/^$TestWorker::EOF$//m;
-
-            $output .= $buf;
-
-            for (1 .. $lines) {
-                my $result = $parser->next;
-                next unless defined($result);
-                if ($result->is_test) {
-                    $tests_completed++;
-                    status($display, "$test: [$tests_completed/??] ");
-                } elsif ($result->is_bailout) {
-                    Log status($display, "$test: BAILOUT");
-                    status_completed(scalar @done);
-                    say "";
-                    say "test $test bailed out: " . $result->explanation;
-                    exit 1;
-                }
-            }
-
-            return unless $t_eof;
-
-            Log status($display, "$test: finished");
-            $timings{$test} = time() - $timings{$test};
-            status_completed(scalar @done);
-
-            $aggregator->add($test, $parser);
-            push @done, [ $test, $output ];
-
-            undef $w;
-            take_job($worker, $cv, $tests);
-        }
-    );
-}
-
-sub cleanup {
-    my $exitcode = $?;
-    $_->() for our @CLEANUP;
-    exit $exitcode;
-}
-
-# must be in a begin block because we C<exit 0> above
-BEGIN {
-    $SIG{$_} = sub {
-        require Carp; Carp::cluck("Caught SIG$_[0]\n");
-        cleanup();
-    } for qw(INT TERM QUIT KILL PIPE)
-}
-
-__END__
-
-=head1 NAME
-
-complete-run.pl - Run the i3 testsuite
-
-=head1 SYNOPSIS
-
-complete-run.pl [files...]
-
-=head1 EXAMPLE
-
-To run the whole testsuite on a reasonable number of Xephyr instances (your
-running X11 will not be touched), run:
-  ./complete-run.pl
-
-To run only a specific test (useful when developing a new feature), run:
-  ./complete-run t/100-fullscreen.t
-
-=head1 OPTIONS
-
-=over 8
-
-=item B<--display>
-
-Specifies which X11 display should be used. Can be specified multiple times and
-will parallelize the tests:
-
-  # Run tests on the second X server
-  ./complete-run.pl -d :1
-
-  # Run four tests in parallel on some Xephyr servers
-  ./complete-run.pl -d :1,:2,:3,:4
-
-Note that it is not necessary to specify this anymore. If omitted,
-complete-run.pl will start (num_cores * 2) Xephyr instances.
-
-=item B<--valgrind>
-
-Runs i3 under valgrind to find memory problems. The output will be available in
-C<latest/valgrind-for-$test.log>.
-
-=item B<--strace>
-
-Runs i3 under strace to trace system calls. The output will be available in
-C<latest/strace-for-$test.log>.
-
-=item B<--xtrace>
-
-Runs i3 under xtrace to trace X11 requests/replies. The output will be
-available in C<latest/xtrace-for-$test.log>.
-
-=item B<--coverage-testing>
-
-Generates a test coverage report at C<latest/i3-coverage>. Exits i3 cleanly
-during tests (instead of kill -9) to make coverage testing work properly.
-
-=item B<--parallel>
-
-Number of Xephyr instances to start (if you don't want to start num_cores * 2
-instances for some reason).
-
-  # Run all tests on a single Xephyr instance
-  ./complete-run.pl -p 1
-
-=back
diff --git a/testcases/complete-run.pl.in b/testcases/complete-run.pl.in
new file mode 100755 (executable)
index 0000000..d872bda
--- /dev/null
@@ -0,0 +1,441 @@
+#!/usr/bin/env perl
+# vim:ts=4:sw=4:expandtab
+# © 2010 Michael Stapelberg and contributors
+package complete_run;
+use strict;
+use warnings;
+use v5.10;
+use utf8;
+# the following are modules which ship with Perl (>= 5.10):
+use Pod::Usage;
+use File::Temp qw(tempfile tempdir);
+use Getopt::Long;
+use POSIX ();
+use TAP::Harness;
+use TAP::Parser;
+use TAP::Parser::Aggregator;
+use Time::HiRes qw(time);
+use IO::Handle;
+
+# these are shipped with the testsuite
+use lib qw(@abs_top_builddir@/testcases/lib @abs_top_srcdir@/testcases/lib);
+use i3test::Util qw(slurp);
+use StartXServer;
+use StatusLine;
+use TestWorker;
+# the following modules are not shipped with Perl
+use AnyEvent;
+use AnyEvent::Util;
+use AnyEvent::Handle;
+use AnyEvent::I3 qw(:all);
+use X11::XCB::Connection;
+use JSON::XS; # AnyEvent::I3 depends on it, too.
+
+binmode STDOUT, ':utf8';
+binmode STDERR, ':utf8';
+
+# Close superfluous file descriptors which were passed by running in a VIM
+# subshell or situations like that.
+AnyEvent::Util::close_all_fds_except(0, 1, 2);
+
+# convenience wrapper to write to the log file
+my $log;
+sub Log { say $log "@_" }
+
+my %timings;
+my $help = 0;
+# Number of tests to run in parallel. Important to know how many Xephyr
+# instances we need to start (unless @displays are given). Defaults to
+# num_cores * 2.
+my $parallel = undef;
+my @displays = ();
+my %options = (
+    valgrind => 0,
+    strace => 0,
+    xtrace => 0,
+    coverage => 0,
+    restart => 0,
+);
+my $keep_xserver_output = 0;
+
+my $result = GetOptions(
+    "coverage-testing" => \$options{coverage},
+    "keep-xserver-output" => \$keep_xserver_output,
+    "valgrind" => \$options{valgrind},
+    "strace" => \$options{strace},
+    "xtrace" => \$options{xtrace},
+    "display=s" => \@displays,
+    "parallel=i" => \$parallel,
+    "help|?" => \$help,
+);
+
+pod2usage(-verbose => 2, -exitcode => 0) if $help;
+
+# Check for missing executables
+my @binaries = qw(
+                   @abs_top_builddir@/i3
+                   @abs_top_builddir@/i3bar/i3bar
+                   @abs_top_builddir@/i3-config-wizard/i3-config-wizard
+                   @abs_top_builddir@/i3-dump-log/i3-dump-log
+                   @abs_top_builddir@/i3-input/i3-input
+                   @abs_top_builddir@/i3-msg/i3-msg
+                   @abs_top_builddir@/i3-nagbar/i3-nagbar
+               );
+
+foreach my $binary (@binaries) {
+    die "$binary executable not found, did you run “make”?" unless -e $binary;
+    die "$binary is not an executable" unless -x $binary;
+}
+
+$ENV{PATH} = join(':',
+    '@abs_top_builddir@/i3-nagbar',
+    '@abs_top_builddir@/i3-msg',
+    '@abs_top_builddir@/i3-input',
+    '@abs_top_builddir@/i3-dump-log',
+    '@abs_top_builddir@/i3-config-wizard',
+    '@abs_top_builddir@/i3bar',
+    '@abs_top_builddir@',
+    '@abs_top_srcdir@',
+    $ENV{PATH});
+
+qx(Xephyr -help 2>&1);
+die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on Debian)." if $?;
+
+@displays = split(/,/, join(',', @displays));
+@displays = map { s/ //g; $_ } @displays;
+
+# 2: get a list of all testcases
+my @testfiles = @ARGV;
+
+# if no files were passed on command line, run all tests from t/
+if (scalar @testfiles == 0) {
+    @testfiles = <@abs_top_srcdir@/testcases/t/*.t> if @testfiles == 0;
+} else {
+    @testfiles = map {
+        # Fully qualify each specified file if necessary
+        if (! -e $_) {
+            $_ = "@abs_top_srcdir@/testcases/$_";
+        }
+        $_
+    } @testfiles;
+}
+
+my $numtests = scalar @testfiles;
+
+# No displays specified, let’s start some Xephyr instances.
+if (@displays == 0) {
+    @displays = start_xserver($parallel, $numtests, $keep_xserver_output);
+}
+
+# 1: create an output directory for this test-run
+my $outdir = "testsuite-";
+$outdir .= POSIX::strftime("%Y-%m-%d-%H-%M-%S-", localtime());
+$outdir .= `git describe --tags`;
+chomp($outdir);
+mkdir($outdir) or die "Could not create $outdir";
+unlink("latest") if -l "latest";
+symlink("$outdir", "latest") or die "Could not symlink latest to $outdir";
+
+
+# connect to all displays for two reasons:
+# 1: check if the display actually works
+# 2: keep the connection open so that i3 is not the only client. this prevents
+#    the X server from exiting
+my @single_worker;
+for my $display (@displays) {
+    my $screen;
+    my $x = X11::XCB::Connection->new(display => $display);
+    if ($x->has_error) {
+        die "Could not connect to display $display\n";
+    } else {
+        # start a TestWorker for each display
+        push @single_worker, worker($display, $x, $outdir, \%options);
+    }
+}
+
+# Read previous timing information, if available. We will be able to roughly
+# predict the test duration and schedule a good order for the tests.
+my $timingsjson = slurp('.last_run_timings.json') if -e '.last_run_timings.json';
+%timings = %{decode_json($timingsjson)} if length($timingsjson) > 0;
+
+# Re-order the files so that those which took the longest time in the previous
+# run will be started at the beginning to not delay the whole run longer than
+# necessary.
+@testfiles = map  { $_->[0] }
+             sort { $b->[1] <=> $a->[1] }
+             map  { [$_, $timings{$_} // 999] } @testfiles;
+
+# Run 000-load-deps.t first to bail out early when dependencies are missing.
+my $loadtest = "t/000-load-deps.t";
+if ((scalar grep { $_ eq $loadtest } @testfiles) > 0) {
+    @testfiles = ($loadtest, grep { $_ ne $loadtest } @testfiles);
+}
+
+printf("\nRough time estimate for this run: %.2f seconds\n\n", $timings{GLOBAL})
+    if exists($timings{GLOBAL});
+
+# Forget the old timings, we don’t necessarily run the same set of tests as
+# before. Otherwise we would end up with left-overs.
+%timings = (GLOBAL => time());
+
+my $logfile = "$outdir/complete-run.log";
+open $log, '>', $logfile or die "Could not create '$logfile': $!";
+$log->autoflush(1);
+say "Writing logfile to '$logfile'...";
+
+# 3: run all tests
+my @done;
+my $num = @testfiles;
+my $harness = TAP::Harness->new({ });
+
+my $aggregator = TAP::Parser::Aggregator->new();
+$aggregator->start();
+
+status_init(displays => \@displays, tests => $num);
+
+my $single_cv = AE::cv;
+
+# We start tests concurrently: For each display, one test gets started. Every
+# test starts another test after completing.
+for (@single_worker) {
+    $single_cv->begin;
+    take_job($_, $single_cv, \@testfiles);
+}
+
+$single_cv->recv;
+
+$aggregator->stop();
+
+# print empty lines to separate failed tests from statuslines
+print "\n\n";
+
+for (@done) {
+    my ($test, $output) = @$_;
+    say "no output for $test" unless $output;
+    Log "output for $test:";
+    Log $output;
+    # print error messages of failed tests
+    say for $output =~ /^not ok.+\n+((?:^#.+\n)+)/mg
+}
+
+# 4: print summary
+$harness->summary($aggregator);
+
+close $log;
+
+# 5: Save the timings for better scheduling/prediction next run.
+$timings{GLOBAL} = time() - $timings{GLOBAL};
+open(my $fh, '>', '.last_run_timings.json');
+print $fh encode_json(\%timings);
+close($fh);
+
+# 6: Print the slowest test files.
+my @slowest = map  { $_->[0] }
+              sort { $b->[1] <=> $a->[1] }
+              map  { [$_, $timings{$_}] }
+              grep { !/^GLOBAL$/ } keys %timings;
+say '';
+say 'The slowest tests are:';
+printf("\t%s with %.2f seconds\n", $_, $timings{$_})
+    for @slowest[0..($#slowest > 4 ? 4 : $#slowest)];
+
+# When we are running precisely one test, print the output. Makes developing
+# with a single testcase easier.
+if ($numtests == 1) {
+    say '';
+    say 'Test output:';
+    say slurp($logfile);
+}
+
+END { cleanup() }
+
+# Report logfiles that match “(Leak|Address)Sanitizer:”.
+my @logs_with_leaks;
+for my $log (<$outdir/i3-log-for-*>) {
+    if (slurp($log) =~ /(Leak|Address)Sanitizer:/) {
+        push @logs_with_leaks, $log;
+    }
+}
+if (scalar @logs_with_leaks > 0) {
+    say "\nThe following test logfiles contain AddressSanitizer or LeakSanitizer reports:";
+    for my $log (sort @logs_with_leaks) {
+        say "\t$log";
+    }
+}
+
+exit ($aggregator->failed > 0);
+
+#
+# Takes a test from the beginning of @testfiles and runs it.
+#
+# The TAP::Parser (which reads the test output) will get called as soon as
+# there is some activity on the stdout file descriptor of the test process
+# (using an AnyEvent->io watcher).
+#
+# When a test completes and @done contains $num entries, the $cv condvar gets
+# triggered to finish testing.
+#
+sub take_job {
+    my ($worker, $cv, $tests) = @_;
+
+    my $test = shift @$tests
+        or return $cv->end;
+
+    my $display = $worker->{display};
+
+    Log status($display, "$test: starting");
+    $timings{$test} = time();
+    worker_next($worker, $test);
+
+    # create a TAP::Parser with an in-memory fh
+    my $output;
+    my $parser = TAP::Parser->new({
+        source => do { open(my $fh, '<', \$output); $fh },
+    });
+
+    my $ipc = $worker->{ipc};
+
+    my $w;
+    $w = AnyEvent->io(
+        fh => $ipc,
+        poll => 'r',
+        cb => sub {
+            state $tests_completed = 0;
+            state $partial = '';
+
+            sysread($ipc, my $buf, 4096) or die "sysread: $!";
+
+            if ($partial) {
+                $buf = $partial . $buf;
+                $partial = '';
+            }
+
+            # make sure we feed TAP::Parser complete lines so it doesn't blow up
+            if (substr($buf, -1, 1) ne "\n") {
+                my $nl = rindex($buf, "\n");
+                if ($nl == -1) {
+                    $partial = $buf;
+                    return;
+                }
+
+                # strip partial from buffer
+                $partial = substr($buf, $nl + 1, '');
+            }
+
+            # count lines before stripping eof-marker otherwise we might
+            # end up with for (1 .. 0) { } which would effectivly skip the loop
+            my $lines = $buf =~ tr/\n//;
+            my $t_eof = $buf =~ s/^$TestWorker::EOF$//m;
+
+            $output .= $buf;
+
+            for (1 .. $lines) {
+                my $result = $parser->next;
+                next unless defined($result);
+                if ($result->is_test) {
+                    $tests_completed++;
+                    status($display, "$test: [$tests_completed/??] ");
+                } elsif ($result->is_bailout) {
+                    Log status($display, "$test: BAILOUT");
+                    status_completed(scalar @done);
+                    say "";
+                    say "test $test bailed out: " . $result->explanation;
+                    exit 1;
+                }
+            }
+
+            return unless $t_eof;
+
+            Log status($display, "$test: finished");
+            $timings{$test} = time() - $timings{$test};
+            status_completed(scalar @done);
+
+            $aggregator->add($test, $parser);
+            push @done, [ $test, $output ];
+
+            undef $w;
+            take_job($worker, $cv, $tests);
+        }
+    );
+}
+
+sub cleanup {
+    my $exitcode = $?;
+    $_->() for our @CLEANUP;
+    exit $exitcode;
+}
+
+# must be in a begin block because we C<exit 0> above
+BEGIN {
+    $SIG{$_} = sub {
+        require Carp; Carp::cluck("Caught SIG$_[0]\n");
+        cleanup();
+    } for qw(INT TERM QUIT KILL PIPE)
+}
+
+__END__
+
+=head1 NAME
+
+complete-run.pl - Run the i3 testsuite
+
+=head1 SYNOPSIS
+
+complete-run.pl [files...]
+
+=head1 EXAMPLE
+
+To run the whole testsuite on a reasonable number of Xephyr instances (your
+running X11 will not be touched), run:
+  ./complete-run.pl
+
+To run only a specific test (useful when developing a new feature), run:
+  ./complete-run t/100-fullscreen.t
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--display>
+
+Specifies which X11 display should be used. Can be specified multiple times and
+will parallelize the tests:
+
+  # Run tests on the second X server
+  ./complete-run.pl -d :1
+
+  # Run four tests in parallel on some Xephyr servers
+  ./complete-run.pl -d :1,:2,:3,:4
+
+Note that it is not necessary to specify this anymore. If omitted,
+complete-run.pl will start (num_cores * 2) Xephyr instances.
+
+=item B<--valgrind>
+
+Runs i3 under valgrind to find memory problems. The output will be available in
+C<latest/valgrind-for-$test.log>.
+
+=item B<--strace>
+
+Runs i3 under strace to trace system calls. The output will be available in
+C<latest/strace-for-$test.log>.
+
+=item B<--xtrace>
+
+Runs i3 under xtrace to trace X11 requests/replies. The output will be
+available in C<latest/xtrace-for-$test.log>.
+
+=item B<--coverage-testing>
+
+Generates a test coverage report at C<latest/i3-coverage>. Exits i3 cleanly
+during tests (instead of kill -9) to make coverage testing work properly.
+
+=item B<--parallel>
+
+Number of Xephyr instances to start (if you don't want to start num_cores * 2
+instances for some reason).
+
+  # Run all tests on a single Xephyr instance
+  ./complete-run.pl -p 1
+
+=back
index b58707a46344d0b79f366a21598fb186da06520e..53dbb3b6ec5c7a64e7fdab5abe585c18d74c2e12 100644 (file)
@@ -62,14 +62,6 @@ sub activate_i3 {
             mkdir $ENV{XDG_RUNTIME_DIR};
         }
         $ENV{DISPLAY} = $args{display};
-        $ENV{PATH} = join(':',
-            '../i3-nagbar',
-            '../i3-msg',
-            '../i3-config-wizard',
-            '../i3bar',
-            '..',
-            $ENV{PATH}
-        );
 
         # We are about to exec, but we did not modify $^F to include $socket
         # when creating the socket (because the file descriptor could have a
@@ -96,7 +88,7 @@ sub activate_i3 {
         # the interactive signalhandler to make it crash immediately instead.
         # Also disable logging to SHM since we redirect the logs anyways.
         # Force Xinerama because we use Xdmx for multi-monitor tests.
-        my $i3cmd = abs_path("../i3") . q| --shmlog-size=0 --disable-signalhandler --force-xinerama|;
+        my $i3cmd = q|i3 --shmlog-size=0 --disable-signalhandler --force-xinerama|;
         if (!$args{validate_config}) {
             # We only set logging if i3 is actually started, but not if we only
             # validate the config file. This is to keep logging to a minimum as
index 6371591f3e1d99e51d1afe36cdfd56dadcfab1d8..aee994f74115a8defe0e435e7f2bdbf26cb61cd5 100644 (file)
@@ -125,7 +125,7 @@ sub worker_wait {
 
             package main;
             local $@;
-            do "./$file";
+            do $file;
             $test->ok(undef, "$@") if $@;
 
             # XXX hack, we need to trigger the read watcher once more
diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm
deleted file mode 100644 (file)
index 9848612..0000000
+++ /dev/null
@@ -1,916 +0,0 @@
-package i3test;
-# vim:ts=4:sw=4:expandtab
-use strict; use warnings;
-
-use File::Temp qw(tmpnam tempfile tempdir);
-use Test::Builder;
-use X11::XCB::Rect;
-use X11::XCB::Window;
-use X11::XCB qw(:all);
-use AnyEvent::I3;
-use List::Util qw(first);
-use Time::HiRes qw(sleep);
-use Cwd qw(abs_path);
-use Scalar::Util qw(blessed);
-use SocketActivation;
-use i3test::Util qw(slurp);
-
-use v5.10;
-
-# preload
-use Test::More ();
-use Data::Dumper ();
-
-use Exporter ();
-our @EXPORT = qw(
-    get_workspace_names
-    get_unused_workspace
-    fresh_workspace
-    get_ws_content
-    get_ws
-    get_focused
-    open_empty_con
-    open_window
-    open_floating_window
-    get_dock_clients
-    cmd
-    sync_with_i3
-    exit_gracefully
-    workspace_exists
-    focused_ws
-    get_socket_path
-    launch_with_config
-    get_i3_log
-    wait_for_event
-    wait_for_map
-    wait_for_unmap
-    $x
-);
-
-=head1 NAME
-
-i3test - Testcase setup module
-
-=encoding utf-8
-
-=head1 SYNOPSIS
-
-  use i3test;
-
-  my $ws = fresh_workspace;
-  is_num_children($ws, 0, 'no containers on this workspace yet');
-  cmd 'open';
-  is_num_children($ws, 1, 'one container after "open"');
-
-  done_testing;
-
-=head1 DESCRIPTION
-
-This module is used in every i3 testcase and takes care of automatically
-starting i3 before any test instructions run. It also saves you typing of lots
-of boilerplate in every test file.
-
-
-i3test automatically "use"s C<Test::More>, C<Data::Dumper>, C<AnyEvent::I3>,
-C<Time::HiRes>’s C<sleep> and C<i3test::Test> so that all of them are available
-to you in your testcase.
-
-See also C<i3test::Test> (L<http://build.i3wm.org/docs/lib-i3test-test.html>)
-which provides additional test instructions (like C<ok> or C<is>).
-
-=cut
-
-my $tester = Test::Builder->new();
-my $_cached_socket_path = undef;
-my $_sync_window = undef;
-my $tmp_socket_path = undef;
-
-our $x;
-
-BEGIN {
-    my $window_count = 0;
-    sub counter_window {
-        return $window_count++;
-    }
-}
-
-my $i3_pid;
-my $i3_autostart;
-
-END {
-
-    # testcases which start i3 manually should always call exit_gracefully
-    # on their own. Let’s see, whether they really did.
-    if (! $i3_autostart) {
-        return unless $i3_pid;
-
-        $tester->ok(undef, 'testcase called exit_gracefully()');
-    }
-
-    # don't trigger SIGCHLD handler
-    local $SIG{CHLD};
-
-    # From perldoc -v '$?':
-    # Inside an "END" subroutine $? contains the value
-    # that is going to be given to "exit()".
-    #
-    # Since waitpid sets $?, we need to localize it,
-    # otherwise TAP would be misinterpreted our return status
-    local $?;
-
-    # When measuring code coverage, try to exit i3 cleanly (otherwise, .gcda
-    # files are not written)
-    if ($ENV{COVERAGE} || $ENV{VALGRIND}) {
-        exit_gracefully($i3_pid, "/tmp/nested-$ENV{DISPLAY}");
-
-    } else {
-        kill(9, $i3_pid)
-            or $tester->BAIL_OUT("could not kill i3");
-
-        waitpid $i3_pid, 0;
-    }
-}
-
-sub import {
-    my ($class, %args) = @_;
-    my $pkg = caller;
-
-    $i3_autostart = delete($args{i3_autostart}) // 1;
-
-    my $cv = launch_with_config('-default', dont_block => 1)
-        if $i3_autostart;
-
-    my $test_more_args = '';
-    $test_more_args = join(' ', 'qw(', %args, ')') if keys %args;
-    local $@;
-    eval << "__";
-package $pkg;
-use Test::More $test_more_args;
-use Data::Dumper;
-use AnyEvent::I3;
-use Time::HiRes qw(sleep);
-use i3test::Test;
-__
-    $tester->BAIL_OUT("$@") if $@;
-    feature->import(":5.10");
-    strict->import;
-    warnings->import;
-
-    $x ||= i3test::X11->new;
-    # set the pointer to a predictable position in case a previous test has
-    # disturbed it
-    $x->root->warp_pointer(0, 0);
-    $cv->recv if $i3_autostart;
-
-    @_ = ($class);
-    goto \&Exporter::import;
-}
-
-=head1 EXPORT
-
-=head2 wait_for_event($timeout, $callback)
-
-Waits for the next event and calls the given callback for every event to
-determine if this is the event we are waiting for.
-
-Can be used to wait until a window is mapped, until a ClientMessage is
-received, etc.
-
-  wait_for_event 0.25, sub { $_[0]->{response_type} == MAP_NOTIFY };
-
-=cut
-sub wait_for_event {
-    my ($timeout, $cb) = @_;
-
-    my $cv = AE::cv;
-
-    $x->flush;
-
-    # unfortunately, there is no constant for this
-    my $ae_read = 0;
-
-    my $guard = AE::io $x->get_file_descriptor, $ae_read, sub {
-        while (defined(my $event = $x->poll_for_event)) {
-            if ($cb->($event)) {
-                $cv->send(1);
-                last;
-            }
-        }
-    };
-
-    # Trigger timeout after $timeout seconds (can be fractional)
-    my $t = AE::timer $timeout, 0, sub { warn "timeout ($timeout secs)"; $cv->send(0) };
-
-    my $result = $cv->recv;
-    undef $t;
-    undef $guard;
-    return $result;
-}
-
-=head2 wait_for_map($window)
-
-Thin wrapper around wait_for_event which waits for MAP_NOTIFY.
-Make sure to include 'structure_notify' in the window’s event_mask attribute.
-
-This function is called by C<open_window>, so in most cases, you don’t need to
-call it on your own. If you need special setup of the window before mapping,
-you might have to map it on your own and use this function:
-
-  my $window = open_window(dont_map => 1);
-  # Do something special with the window first
-  # …
-
-  # Now map it and wait until it’s been mapped
-  $window->map;
-  wait_for_map($window);
-
-=cut
-sub wait_for_map {
-    my ($win) = @_;
-    my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
-    wait_for_event 4, sub {
-        $_[0]->{response_type} == MAP_NOTIFY and $_[0]->{window} == $id
-    };
-}
-
-=head2 wait_for_unmap($window)
-
-Wrapper around C<wait_for_event> which waits for UNMAP_NOTIFY. Also calls
-C<sync_with_i3> to make sure i3 also picked up and processed the UnmapNotify
-event.
-
-  my $ws = fresh_workspace;
-  my $window = open_window;
-  is_num_children($ws, 1, 'one window on workspace');
-  $window->unmap;
-  wait_for_unmap;
-  is_num_children($ws, 0, 'no more windows on this workspace');
-
-=cut
-sub wait_for_unmap {
-    my ($win) = @_;
-    # my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
-    wait_for_event 4, sub {
-        $_[0]->{response_type} == UNMAP_NOTIFY # and $_[0]->{window} == $id
-    };
-    sync_with_i3();
-}
-
-=head2 open_window([ $args ])
-
-Opens a new window (see C<X11::XCB::Window>), maps it, waits until it got mapped
-and synchronizes with i3.
-
-The following arguments can be passed:
-
-=over 4
-
-=item class
-
-The X11 window class (e.g. WINDOW_CLASS_INPUT_OUTPUT), not to be confused with
-the WM_CLASS!
-
-=item rect
-
-An arrayref with 4 members specifying the initial geometry (position and size)
-of the window, e.g. C<< [ 0, 100, 70, 50 ] >> for a window appearing at x=0, y=100
-with width=70 and height=50.
-
-Note that this is entirely irrelevant for tiling windows.
-
-=item background_color
-
-The background pixel color of the window, formatted as "#rrggbb", like HTML
-color codes (e.g. #c0c0c0). This is useful to tell windows apart when actually
-watching the testcases.
-
-=item event_mask
-
-An arrayref containing strings which describe the X11 event mask we use for that
-window. The default is C<< [ 'structure_notify' ] >>.
-
-=item name
-
-The window’s C<_NET_WM_NAME> (UTF-8 window title). By default, this is "Window
-n" with n being replaced by a counter to keep windows apart.
-
-=item dont_map
-
-Set to a true value to avoid mapping the window (making it visible).
-
-=item before_map
-
-A coderef which is called before the window is mapped (unless C<dont_map> is
-true). The freshly created C<$window> is passed as C<$_> and as the first
-argument.
-
-=back
-
-The default values are equivalent to this call:
-
-  open_window(
-    class => WINDOW_CLASS_INPUT_OUTPUT
-    rect => [ 0, 0, 30, 30 ]
-    background_color => '#c0c0c0'
-    event_mask => [ 'structure_notify' ]
-    name => 'Window <n>'
-  );
-
-Usually, though, calls are simpler:
-
-  my $top_window = open_window;
-
-To identify the resulting window object in i3 commands, use the id property:
-
-  my $top_window = open_window;
-  cmd '[id="' . $top_window->id . '"] kill';
-
-=cut
-sub open_window {
-    my %args = @_ == 1 ? %{$_[0]} : @_;
-
-    my $dont_map = delete $args{dont_map};
-    my $before_map = delete $args{before_map};
-
-    $args{class} //= WINDOW_CLASS_INPUT_OUTPUT;
-    $args{rect} //= [ 0, 0, 30, 30 ];
-    $args{background_color} //= '#c0c0c0';
-    $args{event_mask} //= [ 'structure_notify' ];
-    $args{name} //= 'Window ' . counter_window();
-
-    my $window = $x->root->create_child(%args);
-    $window->add_hint('input');
-
-    if ($before_map) {
-        # TODO: investigate why _create is not needed
-        $window->_create;
-        $before_map->($window) for $window;
-    }
-
-    return $window if $dont_map;
-
-    $window->map;
-    wait_for_map($window);
-    return $window;
-}
-
-=head2 open_floating_window([ $args ])
-
-Thin wrapper around open_window which sets window_type to
-C<_NET_WM_WINDOW_TYPE_UTILITY> to make the window floating.
-
-The arguments are the same as those of C<open_window>.
-
-=cut
-sub open_floating_window {
-    my %args = @_ == 1 ? %{$_[0]} : @_;
-
-    $args{window_type} = $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY');
-
-    return open_window(\%args);
-}
-
-sub open_empty_con {
-    my ($i3) = @_;
-
-    my $reply = $i3->command('open')->recv;
-    return $reply->[0]->{id};
-}
-
-=head2 get_workspace_names()
-
-Returns an arrayref containing the name of every workspace (regardless of its
-output) which currently exists.
-
-  my $workspace_names = get_workspace_names;
-  is(scalar @$workspace_names, 3, 'three workspaces exist currently');
-
-=cut
-sub get_workspace_names {
-    my $i3 = i3(get_socket_path());
-    my $tree = $i3->get_tree->recv;
-    my @outputs = @{$tree->{nodes}};
-    my @cons;
-    for my $output (@outputs) {
-        next if $output->{name} eq '__i3';
-        # get the first CT_CON of each output
-        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
-        @cons = (@cons, @{$content->{nodes}});
-    }
-    [ map { $_->{name} } @cons ]
-}
-
-=head2 get_unused_workspace
-
-Returns a workspace name which has not yet been used. See also
-C<fresh_workspace> which directly switches to an unused workspace.
-
-  my $ws = get_unused_workspace;
-  cmd "workspace $ws";
-
-=cut
-sub get_unused_workspace {
-    my @names = get_workspace_names();
-    my $tmp;
-    do { $tmp = tmpnam() } while ((scalar grep { $_ eq $tmp } @names) > 0);
-    $tmp
-}
-
-=head2 fresh_workspace([ $args ])
-
-Switches to an unused workspace and returns the name of that workspace.
-
-Optionally switches to the specified output first.
-
-    my $ws = fresh_workspace;
-
-    # Get a fresh workspace on the second output.
-    my $ws = fresh_workspace(output => 1);
-
-=cut
-sub fresh_workspace {
-    my %args = @_;
-    if (exists($args{output})) {
-        my $i3 = i3(get_socket_path());
-        my $tree = $i3->get_tree->recv;
-        my $output = first { $_->{name} eq "fake-$args{output}" }
-                        @{$tree->{nodes}};
-        die "BUG: Could not find output $args{output}" unless defined($output);
-        # Get the focused workspace on that output and switch to it.
-        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
-        my $focused = $content->{focus}->[0];
-        my $workspace = first { $_->{id} == $focused } @{$content->{nodes}};
-        $workspace = $workspace->{name};
-        cmd("workspace $workspace");
-    }
-
-    my $unused = get_unused_workspace;
-    cmd("workspace $unused");
-    $unused
-}
-
-=head2 get_ws($workspace)
-
-Returns the container (from the i3 layout tree) which represents C<$workspace>.
-
-  my $ws = fresh_workspace;
-  my $ws_con = get_ws($ws);
-  ok(!$ws_con->{urgent}, 'fresh workspace not marked urgent');
-
-Here is an example which counts the number of urgent containers recursively,
-starting from the workspace container:
-
-  sub count_urgent {
-      my ($con) = @_;
-
-      my @children = (@{$con->{nodes}}, @{$con->{floating_nodes}});
-      my $urgent = grep { $_->{urgent} } @children;
-      $urgent += count_urgent($_) for @children;
-      return $urgent;
-  }
-  my $urgent = count_urgent(get_ws($ws));
-  is($urgent, 3, "three urgent windows on workspace $ws");
-
-
-=cut
-sub get_ws {
-    my ($name) = @_;
-    my $i3 = i3(get_socket_path());
-    my $tree = $i3->get_tree->recv;
-
-    my @outputs = @{$tree->{nodes}};
-    my @workspaces;
-    for my $output (@outputs) {
-        # get the first CT_CON of each output
-        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
-        @workspaces = (@workspaces, @{$content->{nodes}});
-    }
-
-    # as there can only be one workspace with this name, we can safely
-    # return the first entry
-    return first { $_->{name} eq $name } @workspaces;
-}
-
-=head2 get_ws_content($workspace)
-
-Returns the content (== tree, starting from the node of a workspace)
-of a workspace. If called in array context, also includes the focus
-stack of the workspace.
-
-  my $nodes = get_ws_content($ws);
-  is(scalar @$nodes, 4, 'there are four containers at workspace-level');
-
-Or, in array context:
-
-  my $window = open_window;
-  my ($nodes, $focus) = get_ws_content($ws);
-  is($focus->[0], $window->id, 'newly opened window focused');
-
-Note that this function does not do recursion for you! It only returns the
-containers B<on workspace level>. If you want to work with all containers (even
-nested ones) on a workspace, you have to use recursion:
-
-  # NB: This function does not count floating windows
-  sub count_urgent {
-      my ($nodes) = @_;
-
-      my $urgent = 0;
-      for my $con (@$nodes) {
-          $urgent++ if $con->{urgent};
-          $urgent += count_urgent($con->{nodes});
-      }
-
-      return $urgent;
-  }
-  my $nodes = get_ws_content($ws);
-  my $urgent = count_urgent($nodes);
-  is($urgent, 3, "three urgent windows on workspace $ws");
-
-If you also want to deal with floating windows, you have to use C<get_ws>
-instead and access C<< ->{nodes} >> and C<< ->{floating_nodes} >> on your own.
-
-=cut
-sub get_ws_content {
-    my ($name) = @_;
-    my $con = get_ws($name);
-    return wantarray ? ($con->{nodes}, $con->{focus}) : $con->{nodes};
-}
-
-=head2 get_focused($workspace)
-
-Returns the container ID of the currently focused container on C<$workspace>.
-
-Note that the container ID is B<not> the X11 window ID, so comparing the result
-of C<get_focused> with a window's C<< ->{id} >> property does B<not> work.
-
-  my $ws = fresh_workspace;
-  my $first_window = open_window;
-  my $first_id = get_focused();
-
-  my $second_window = open_window;
-  my $second_id = get_focused();
-
-  cmd 'focus left';
-
-  is(get_focused($ws), $first_id, 'second window focused');
-
-=cut
-sub get_focused {
-    my ($ws) = @_;
-    my $con = get_ws($ws);
-
-    my @focused = @{$con->{focus}};
-    my $lf;
-    while (@focused > 0) {
-        $lf = $focused[0];
-        last unless defined($con->{focus});
-        @focused = @{$con->{focus}};
-        my @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
-        $con = $cons[0];
-    }
-
-    return $lf;
-}
-
-=head2 get_dock_clients([ $dockarea ])
-
-Returns an array of all dock containers in C<$dockarea> (one of "top" or
-"bottom"). If C<$dockarea> is not specified, returns an array of all dock
-containers in any dockarea.
-
-  my @docked = get_dock_clients;
-  is(scalar @docked, 0, 'no dock clients yet');
-
-=cut
-sub get_dock_clients {
-    my $which = shift;
-
-    my $tree = i3(get_socket_path())->get_tree->recv;
-    my @outputs = @{$tree->{nodes}};
-    # Children of all dockareas
-    my @docked;
-    for my $output (@outputs) {
-        if (!defined($which)) {
-            @docked = (@docked, map { @{$_->{nodes}} }
-                                grep { $_->{type} eq 'dockarea' }
-                                @{$output->{nodes}});
-        } elsif ($which eq 'top') {
-            my $first = first { $_->{type} eq 'dockarea' } @{$output->{nodes}};
-            @docked = (@docked, @{$first->{nodes}}) if defined($first);
-        } elsif ($which eq 'bottom') {
-            my @matching = grep { $_->{type} eq 'dockarea' } @{$output->{nodes}};
-            my $last = $matching[-1];
-            @docked = (@docked, @{$last->{nodes}}) if defined($last);
-        }
-    }
-    return @docked;
-}
-
-=head2 cmd($command)
-
-Sends the specified command to i3 and returns the output.
-
-  my $ws = unused_workspace;
-  cmd "workspace $ws";
-  cmd 'focus right';
-
-=cut
-sub cmd {
-    i3(get_socket_path())->command(@_)->recv
-}
-
-=head2 workspace_exists($workspace)
-
-Returns true if C<$workspace> is the name of an existing workspace.
-
-  my $old_ws = focused_ws;
-  # switch away from where we currently are
-  fresh_workspace;
-
-  ok(workspace_exists($old_ws), 'old workspace still exists');
-
-=cut
-sub workspace_exists {
-    my ($name) = @_;
-    (scalar grep { $_ eq $name } @{get_workspace_names()}) > 0;
-}
-
-=head2 focused_ws
-
-Returns the name of the currently focused workspace.
-
-  my $ws = focused_ws;
-  is($ws, '1', 'i3 starts on workspace 1');
-
-=cut
-sub focused_ws {
-    my $i3 = i3(get_socket_path());
-    my $tree = $i3->get_tree->recv;
-    my $focused = $tree->{focus}->[0];
-    my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
-    my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
-    my $first = first { $_->{fullscreen_mode} == 1 } @{$content->{nodes}};
-    return $first->{name}
-}
-
-=head2 sync_with_i3([ $args ])
-
-Sends an I3_SYNC ClientMessage with a random value to the root window.
-i3 will reply with the same value, but, due to the order of events it
-processes, only after all other events are done.
-
-This can be used to ensure the results of a cmd 'focus left' are pushed to
-X11 and that C<< $x->input_focus >> returns the correct value afterwards.
-
-See also L<http://build.i3wm.org/docs/testsuite.html> for a longer explanation.
-
-  my $window = open_window;
-  $window->add_hint('urgency');
-  # Ensure i3 picked up the change
-  sync_with_i3;
-
-The only time when you need to use the C<no_cache> argument is when you just
-killed your own X11 connection:
-
-  cmd 'kill client';
-  # We need to re-establish the X11 connection which we just killed :).
-  $x = i3test::X11->new;
-  sync_with_i3(no_cache => 1);
-
-=cut
-sub sync_with_i3 {
-    my %args = @_ == 1 ? %{$_[0]} : @_;
-
-    # Since we need a (mapped) window for receiving a ClientMessage, we create
-    # one on the first call of sync_with_i3. It will be re-used in all
-    # subsequent calls.
-    if (!exists($args{window_id}) &&
-        (!defined($_sync_window) || exists($args{no_cache}))) {
-        $_sync_window = open_window(
-            rect => [ -15, -15, 10, 10 ],
-            override_redirect => 1,
-        );
-    }
-
-    my $window_id = delete $args{window_id};
-    $window_id //= $_sync_window->id;
-
-    my $root = $x->get_root_window();
-    # Generate a random number to identify this particular ClientMessage.
-    my $myrnd = int(rand(255)) + 1;
-
-    # Generate a ClientMessage, see xcb_client_message_t
-    my $msg = pack "CCSLLLLLLL",
-         CLIENT_MESSAGE, # response_type
-         32,     # format
-         0,      # sequence
-         $root,  # destination window
-         $x->atom(name => 'I3_SYNC')->id,
-
-         $window_id,    # data[0]: our own window id
-         $myrnd, # data[1]: a random value to identify the request
-         0,
-         0,
-         0;
-
-    # Send it to the root window -- since i3 uses the SubstructureRedirect
-    # event mask, it will get the ClientMessage.
-    $x->send_event(0, $root, EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
-
-    return $myrnd if $args{dont_wait_for_event};
-
-    # now wait until the reply is here
-    return wait_for_event 4, sub {
-        my ($event) = @_;
-        # TODO: const
-        return 0 unless $event->{response_type} == 161;
-
-        my ($win, $rnd) = unpack "LL", $event->{data};
-        return ($rnd == $myrnd);
-    };
-}
-
-=head2 exit_gracefully($pid, [ $socketpath ])
-
-Tries to exit i3 gracefully (with the 'exit' cmd) or kills the PID if that fails.
-
-If C<$socketpath> is not specified, C<get_socket_path()> will be called.
-
-You only need to use this function if you have launched i3 on your own with
-C<launch_with_config>. Otherwise, it will be automatically called when the
-testcase ends.
-
-  use i3test i3_autostart => 0;
-  my $pid = launch_with_config($config);
-  # …
-  exit_gracefully($pid);
-
-=cut
-sub exit_gracefully {
-    my ($pid, $socketpath) = @_;
-    $socketpath ||= get_socket_path();
-
-    my $exited = 0;
-    eval {
-        say "Exiting i3 cleanly...";
-        i3($socketpath)->command('exit')->recv;
-        $exited = 1;
-    };
-
-    if (!$exited) {
-        kill(9, $pid)
-            or $tester->BAIL_OUT("could not kill i3");
-    }
-
-    if ($socketpath =~ m,^/tmp/i3-test-socket-,) {
-        unlink($socketpath);
-    }
-
-    waitpid $pid, 0;
-    undef $i3_pid;
-}
-
-=head2 get_socket_path([ $cache ])
-
-Gets the socket path from the C<I3_SOCKET_PATH> atom stored on the X11 root
-window. After the first call, this function will return a cached version of the
-socket path unless you specify a false value for C<$cache>.
-
-  my $i3 = i3(get_socket_path());
-  $i3->command('nop test example')->recv;
-
-To avoid caching:
-
-  my $i3 = i3(get_socket_path(0));
-
-=cut
-sub get_socket_path {
-    my ($cache) = @_;
-    $cache //= 1;
-
-    if ($cache && defined($_cached_socket_path)) {
-        return $_cached_socket_path;
-    }
-
-    my $atom = $x->atom(name => 'I3_SOCKET_PATH');
-    my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
-    my $reply = $x->get_property_reply($cookie->{sequence});
-    my $socketpath = $reply->{value};
-    if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") {
-        $socketpath .= '-activation';
-    }
-    $_cached_socket_path = $socketpath;
-    return $socketpath;
-}
-
-=head2 launch_with_config($config, [ $args ])
-
-Launches a new i3 process with C<$config> as configuration file. Useful for
-tests which test specific config file directives.
-
-  use i3test i3_autostart => 0;
-
-  my $config = <<EOT;
-  # i3 config file (v4)
-  for_window [class="borderless"] border none
-  for_window [title="special borderless title"] border none
-  EOT
-
-  my $pid = launch_with_config($config);
-
-  # …
-
-  exit_gracefully($pid);
-
-=cut
-sub launch_with_config {
-    my ($config, %args) = @_;
-
-    $tmp_socket_path = "/tmp/nested-$ENV{DISPLAY}";
-
-    $args{dont_create_temp_dir} //= 0;
-    $args{validate_config} //= 0;
-
-    my ($fh, $tmpfile) = tempfile("i3-cfg-for-$ENV{TESTNAME}-XXXXX", UNLINK => 1);
-
-    if ($config ne '-default') {
-        say $fh $config;
-    } else {
-        open(my $conf_fh, '<', './i3-test.config')
-            or $tester->BAIL_OUT("could not open default config: $!");
-        local $/;
-        say $fh scalar <$conf_fh>;
-    }
-
-    say $fh "ipc-socket $tmp_socket_path"
-        unless $args{dont_add_socket_path};
-
-    close($fh);
-
-    my $cv = AnyEvent->condvar;
-    $i3_pid = activate_i3(
-        unix_socket_path => "$tmp_socket_path-activation",
-        display => $ENV{DISPLAY},
-        configfile => $tmpfile,
-        outdir => $ENV{OUTDIR},
-        testname => $ENV{TESTNAME},
-        valgrind => $ENV{VALGRIND},
-        strace => $ENV{STRACE},
-        xtrace => $ENV{XTRACE},
-        restart => $ENV{RESTART},
-        cv => $cv,
-        dont_create_temp_dir => $args{dont_create_temp_dir},
-        validate_config => $args{validate_config},
-    );
-
-    # If we called i3 with -C, we wait for it to exit and then return as
-    # there's nothing else we need to do.
-    if ($args{validate_config}) {
-        $cv->recv;
-        waitpid $i3_pid, 0;
-
-        # We need this since exit_gracefully will not be called in this case.
-        undef $i3_pid;
-
-        return ${^CHILD_ERROR_NATIVE};
-    }
-
-    # force update of the cached socket path in lib/i3test
-    # as soon as i3 has started
-    $cv->cb(sub { get_socket_path(0) });
-
-    return $cv if $args{dont_block};
-
-    # blockingly wait until i3 is ready
-    $cv->recv;
-
-    return $i3_pid;
-}
-
-=head2 get_i3_log
-
-Returns the content of the log file for the current test.
-
-=cut
-sub get_i3_log {
-    my $logfile = "$ENV{OUTDIR}/i3-log-for-$ENV{TESTNAME}";
-    return slurp($logfile);
-}
-
-=head1 AUTHOR
-
-Michael Stapelberg <michael@i3wm.org>
-
-=cut
-
-package i3test::X11;
-use parent 'X11::XCB::Connection';
-
-sub input_focus {
-    my $self = shift;
-    i3test::sync_with_i3();
-
-    return $self->SUPER::input_focus(@_);
-}
-
-1
diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in
new file mode 100644 (file)
index 0000000..f9f6e82
--- /dev/null
@@ -0,0 +1,916 @@
+package i3test;
+# vim:ts=4:sw=4:expandtab
+use strict; use warnings;
+
+use File::Temp qw(tmpnam tempfile tempdir);
+use Test::Builder;
+use X11::XCB::Rect;
+use X11::XCB::Window;
+use X11::XCB qw(:all);
+use AnyEvent::I3;
+use List::Util qw(first);
+use Time::HiRes qw(sleep);
+use Cwd qw(abs_path);
+use Scalar::Util qw(blessed);
+use SocketActivation;
+use i3test::Util qw(slurp);
+
+use v5.10;
+
+# preload
+use Test::More ();
+use Data::Dumper ();
+
+use Exporter ();
+our @EXPORT = qw(
+    get_workspace_names
+    get_unused_workspace
+    fresh_workspace
+    get_ws_content
+    get_ws
+    get_focused
+    open_empty_con
+    open_window
+    open_floating_window
+    get_dock_clients
+    cmd
+    sync_with_i3
+    exit_gracefully
+    workspace_exists
+    focused_ws
+    get_socket_path
+    launch_with_config
+    get_i3_log
+    wait_for_event
+    wait_for_map
+    wait_for_unmap
+    $x
+);
+
+=head1 NAME
+
+i3test - Testcase setup module
+
+=encoding utf-8
+
+=head1 SYNOPSIS
+
+  use i3test;
+
+  my $ws = fresh_workspace;
+  is_num_children($ws, 0, 'no containers on this workspace yet');
+  cmd 'open';
+  is_num_children($ws, 1, 'one container after "open"');
+
+  done_testing;
+
+=head1 DESCRIPTION
+
+This module is used in every i3 testcase and takes care of automatically
+starting i3 before any test instructions run. It also saves you typing of lots
+of boilerplate in every test file.
+
+
+i3test automatically "use"s C<Test::More>, C<Data::Dumper>, C<AnyEvent::I3>,
+C<Time::HiRes>’s C<sleep> and C<i3test::Test> so that all of them are available
+to you in your testcase.
+
+See also C<i3test::Test> (L<http://build.i3wm.org/docs/lib-i3test-test.html>)
+which provides additional test instructions (like C<ok> or C<is>).
+
+=cut
+
+my $tester = Test::Builder->new();
+my $_cached_socket_path = undef;
+my $_sync_window = undef;
+my $tmp_socket_path = undef;
+
+our $x;
+
+BEGIN {
+    my $window_count = 0;
+    sub counter_window {
+        return $window_count++;
+    }
+}
+
+my $i3_pid;
+my $i3_autostart;
+
+END {
+
+    # testcases which start i3 manually should always call exit_gracefully
+    # on their own. Let’s see, whether they really did.
+    if (! $i3_autostart) {
+        return unless $i3_pid;
+
+        $tester->ok(undef, 'testcase called exit_gracefully()');
+    }
+
+    # don't trigger SIGCHLD handler
+    local $SIG{CHLD};
+
+    # From perldoc -v '$?':
+    # Inside an "END" subroutine $? contains the value
+    # that is going to be given to "exit()".
+    #
+    # Since waitpid sets $?, we need to localize it,
+    # otherwise TAP would be misinterpreted our return status
+    local $?;
+
+    # When measuring code coverage, try to exit i3 cleanly (otherwise, .gcda
+    # files are not written)
+    if ($ENV{COVERAGE} || $ENV{VALGRIND}) {
+        exit_gracefully($i3_pid, "/tmp/nested-$ENV{DISPLAY}");
+
+    } else {
+        kill(9, $i3_pid)
+            or $tester->BAIL_OUT("could not kill i3");
+
+        waitpid $i3_pid, 0;
+    }
+}
+
+sub import {
+    my ($class, %args) = @_;
+    my $pkg = caller;
+
+    $i3_autostart = delete($args{i3_autostart}) // 1;
+
+    my $cv = launch_with_config('-default', dont_block => 1)
+        if $i3_autostart;
+
+    my $test_more_args = '';
+    $test_more_args = join(' ', 'qw(', %args, ')') if keys %args;
+    local $@;
+    eval << "__";
+package $pkg;
+use Test::More $test_more_args;
+use Data::Dumper;
+use AnyEvent::I3;
+use Time::HiRes qw(sleep);
+use i3test::Test;
+__
+    $tester->BAIL_OUT("$@") if $@;
+    feature->import(":5.10");
+    strict->import;
+    warnings->import;
+
+    $x ||= i3test::X11->new;
+    # set the pointer to a predictable position in case a previous test has
+    # disturbed it
+    $x->root->warp_pointer(0, 0);
+    $cv->recv if $i3_autostart;
+
+    @_ = ($class);
+    goto \&Exporter::import;
+}
+
+=head1 EXPORT
+
+=head2 wait_for_event($timeout, $callback)
+
+Waits for the next event and calls the given callback for every event to
+determine if this is the event we are waiting for.
+
+Can be used to wait until a window is mapped, until a ClientMessage is
+received, etc.
+
+  wait_for_event 0.25, sub { $_[0]->{response_type} == MAP_NOTIFY };
+
+=cut
+sub wait_for_event {
+    my ($timeout, $cb) = @_;
+
+    my $cv = AE::cv;
+
+    $x->flush;
+
+    # unfortunately, there is no constant for this
+    my $ae_read = 0;
+
+    my $guard = AE::io $x->get_file_descriptor, $ae_read, sub {
+        while (defined(my $event = $x->poll_for_event)) {
+            if ($cb->($event)) {
+                $cv->send(1);
+                last;
+            }
+        }
+    };
+
+    # Trigger timeout after $timeout seconds (can be fractional)
+    my $t = AE::timer $timeout, 0, sub { warn "timeout ($timeout secs)"; $cv->send(0) };
+
+    my $result = $cv->recv;
+    undef $t;
+    undef $guard;
+    return $result;
+}
+
+=head2 wait_for_map($window)
+
+Thin wrapper around wait_for_event which waits for MAP_NOTIFY.
+Make sure to include 'structure_notify' in the window’s event_mask attribute.
+
+This function is called by C<open_window>, so in most cases, you don’t need to
+call it on your own. If you need special setup of the window before mapping,
+you might have to map it on your own and use this function:
+
+  my $window = open_window(dont_map => 1);
+  # Do something special with the window first
+  # …
+
+  # Now map it and wait until it’s been mapped
+  $window->map;
+  wait_for_map($window);
+
+=cut
+sub wait_for_map {
+    my ($win) = @_;
+    my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
+    wait_for_event 4, sub {
+        $_[0]->{response_type} == MAP_NOTIFY and $_[0]->{window} == $id
+    };
+}
+
+=head2 wait_for_unmap($window)
+
+Wrapper around C<wait_for_event> which waits for UNMAP_NOTIFY. Also calls
+C<sync_with_i3> to make sure i3 also picked up and processed the UnmapNotify
+event.
+
+  my $ws = fresh_workspace;
+  my $window = open_window;
+  is_num_children($ws, 1, 'one window on workspace');
+  $window->unmap;
+  wait_for_unmap;
+  is_num_children($ws, 0, 'no more windows on this workspace');
+
+=cut
+sub wait_for_unmap {
+    my ($win) = @_;
+    # my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
+    wait_for_event 4, sub {
+        $_[0]->{response_type} == UNMAP_NOTIFY # and $_[0]->{window} == $id
+    };
+    sync_with_i3();
+}
+
+=head2 open_window([ $args ])
+
+Opens a new window (see C<X11::XCB::Window>), maps it, waits until it got mapped
+and synchronizes with i3.
+
+The following arguments can be passed:
+
+=over 4
+
+=item class
+
+The X11 window class (e.g. WINDOW_CLASS_INPUT_OUTPUT), not to be confused with
+the WM_CLASS!
+
+=item rect
+
+An arrayref with 4 members specifying the initial geometry (position and size)
+of the window, e.g. C<< [ 0, 100, 70, 50 ] >> for a window appearing at x=0, y=100
+with width=70 and height=50.
+
+Note that this is entirely irrelevant for tiling windows.
+
+=item background_color
+
+The background pixel color of the window, formatted as "#rrggbb", like HTML
+color codes (e.g. #c0c0c0). This is useful to tell windows apart when actually
+watching the testcases.
+
+=item event_mask
+
+An arrayref containing strings which describe the X11 event mask we use for that
+window. The default is C<< [ 'structure_notify' ] >>.
+
+=item name
+
+The window’s C<_NET_WM_NAME> (UTF-8 window title). By default, this is "Window
+n" with n being replaced by a counter to keep windows apart.
+
+=item dont_map
+
+Set to a true value to avoid mapping the window (making it visible).
+
+=item before_map
+
+A coderef which is called before the window is mapped (unless C<dont_map> is
+true). The freshly created C<$window> is passed as C<$_> and as the first
+argument.
+
+=back
+
+The default values are equivalent to this call:
+
+  open_window(
+    class => WINDOW_CLASS_INPUT_OUTPUT
+    rect => [ 0, 0, 30, 30 ]
+    background_color => '#c0c0c0'
+    event_mask => [ 'structure_notify' ]
+    name => 'Window <n>'
+  );
+
+Usually, though, calls are simpler:
+
+  my $top_window = open_window;
+
+To identify the resulting window object in i3 commands, use the id property:
+
+  my $top_window = open_window;
+  cmd '[id="' . $top_window->id . '"] kill';
+
+=cut
+sub open_window {
+    my %args = @_ == 1 ? %{$_[0]} : @_;
+
+    my $dont_map = delete $args{dont_map};
+    my $before_map = delete $args{before_map};
+
+    $args{class} //= WINDOW_CLASS_INPUT_OUTPUT;
+    $args{rect} //= [ 0, 0, 30, 30 ];
+    $args{background_color} //= '#c0c0c0';
+    $args{event_mask} //= [ 'structure_notify' ];
+    $args{name} //= 'Window ' . counter_window();
+
+    my $window = $x->root->create_child(%args);
+    $window->add_hint('input');
+
+    if ($before_map) {
+        # TODO: investigate why _create is not needed
+        $window->_create;
+        $before_map->($window) for $window;
+    }
+
+    return $window if $dont_map;
+
+    $window->map;
+    wait_for_map($window);
+    return $window;
+}
+
+=head2 open_floating_window([ $args ])
+
+Thin wrapper around open_window which sets window_type to
+C<_NET_WM_WINDOW_TYPE_UTILITY> to make the window floating.
+
+The arguments are the same as those of C<open_window>.
+
+=cut
+sub open_floating_window {
+    my %args = @_ == 1 ? %{$_[0]} : @_;
+
+    $args{window_type} = $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY');
+
+    return open_window(\%args);
+}
+
+sub open_empty_con {
+    my ($i3) = @_;
+
+    my $reply = $i3->command('open')->recv;
+    return $reply->[0]->{id};
+}
+
+=head2 get_workspace_names()
+
+Returns an arrayref containing the name of every workspace (regardless of its
+output) which currently exists.
+
+  my $workspace_names = get_workspace_names;
+  is(scalar @$workspace_names, 3, 'three workspaces exist currently');
+
+=cut
+sub get_workspace_names {
+    my $i3 = i3(get_socket_path());
+    my $tree = $i3->get_tree->recv;
+    my @outputs = @{$tree->{nodes}};
+    my @cons;
+    for my $output (@outputs) {
+        next if $output->{name} eq '__i3';
+        # get the first CT_CON of each output
+        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
+        @cons = (@cons, @{$content->{nodes}});
+    }
+    [ map { $_->{name} } @cons ]
+}
+
+=head2 get_unused_workspace
+
+Returns a workspace name which has not yet been used. See also
+C<fresh_workspace> which directly switches to an unused workspace.
+
+  my $ws = get_unused_workspace;
+  cmd "workspace $ws";
+
+=cut
+sub get_unused_workspace {
+    my @names = get_workspace_names();
+    my $tmp;
+    do { $tmp = tmpnam() } while ((scalar grep { $_ eq $tmp } @names) > 0);
+    $tmp
+}
+
+=head2 fresh_workspace([ $args ])
+
+Switches to an unused workspace and returns the name of that workspace.
+
+Optionally switches to the specified output first.
+
+    my $ws = fresh_workspace;
+
+    # Get a fresh workspace on the second output.
+    my $ws = fresh_workspace(output => 1);
+
+=cut
+sub fresh_workspace {
+    my %args = @_;
+    if (exists($args{output})) {
+        my $i3 = i3(get_socket_path());
+        my $tree = $i3->get_tree->recv;
+        my $output = first { $_->{name} eq "fake-$args{output}" }
+                        @{$tree->{nodes}};
+        die "BUG: Could not find output $args{output}" unless defined($output);
+        # Get the focused workspace on that output and switch to it.
+        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
+        my $focused = $content->{focus}->[0];
+        my $workspace = first { $_->{id} == $focused } @{$content->{nodes}};
+        $workspace = $workspace->{name};
+        cmd("workspace $workspace");
+    }
+
+    my $unused = get_unused_workspace;
+    cmd("workspace $unused");
+    $unused
+}
+
+=head2 get_ws($workspace)
+
+Returns the container (from the i3 layout tree) which represents C<$workspace>.
+
+  my $ws = fresh_workspace;
+  my $ws_con = get_ws($ws);
+  ok(!$ws_con->{urgent}, 'fresh workspace not marked urgent');
+
+Here is an example which counts the number of urgent containers recursively,
+starting from the workspace container:
+
+  sub count_urgent {
+      my ($con) = @_;
+
+      my @children = (@{$con->{nodes}}, @{$con->{floating_nodes}});
+      my $urgent = grep { $_->{urgent} } @children;
+      $urgent += count_urgent($_) for @children;
+      return $urgent;
+  }
+  my $urgent = count_urgent(get_ws($ws));
+  is($urgent, 3, "three urgent windows on workspace $ws");
+
+
+=cut
+sub get_ws {
+    my ($name) = @_;
+    my $i3 = i3(get_socket_path());
+    my $tree = $i3->get_tree->recv;
+
+    my @outputs = @{$tree->{nodes}};
+    my @workspaces;
+    for my $output (@outputs) {
+        # get the first CT_CON of each output
+        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
+        @workspaces = (@workspaces, @{$content->{nodes}});
+    }
+
+    # as there can only be one workspace with this name, we can safely
+    # return the first entry
+    return first { $_->{name} eq $name } @workspaces;
+}
+
+=head2 get_ws_content($workspace)
+
+Returns the content (== tree, starting from the node of a workspace)
+of a workspace. If called in array context, also includes the focus
+stack of the workspace.
+
+  my $nodes = get_ws_content($ws);
+  is(scalar @$nodes, 4, 'there are four containers at workspace-level');
+
+Or, in array context:
+
+  my $window = open_window;
+  my ($nodes, $focus) = get_ws_content($ws);
+  is($focus->[0], $window->id, 'newly opened window focused');
+
+Note that this function does not do recursion for you! It only returns the
+containers B<on workspace level>. If you want to work with all containers (even
+nested ones) on a workspace, you have to use recursion:
+
+  # NB: This function does not count floating windows
+  sub count_urgent {
+      my ($nodes) = @_;
+
+      my $urgent = 0;
+      for my $con (@$nodes) {
+          $urgent++ if $con->{urgent};
+          $urgent += count_urgent($con->{nodes});
+      }
+
+      return $urgent;
+  }
+  my $nodes = get_ws_content($ws);
+  my $urgent = count_urgent($nodes);
+  is($urgent, 3, "three urgent windows on workspace $ws");
+
+If you also want to deal with floating windows, you have to use C<get_ws>
+instead and access C<< ->{nodes} >> and C<< ->{floating_nodes} >> on your own.
+
+=cut
+sub get_ws_content {
+    my ($name) = @_;
+    my $con = get_ws($name);
+    return wantarray ? ($con->{nodes}, $con->{focus}) : $con->{nodes};
+}
+
+=head2 get_focused($workspace)
+
+Returns the container ID of the currently focused container on C<$workspace>.
+
+Note that the container ID is B<not> the X11 window ID, so comparing the result
+of C<get_focused> with a window's C<< ->{id} >> property does B<not> work.
+
+  my $ws = fresh_workspace;
+  my $first_window = open_window;
+  my $first_id = get_focused();
+
+  my $second_window = open_window;
+  my $second_id = get_focused();
+
+  cmd 'focus left';
+
+  is(get_focused($ws), $first_id, 'second window focused');
+
+=cut
+sub get_focused {
+    my ($ws) = @_;
+    my $con = get_ws($ws);
+
+    my @focused = @{$con->{focus}};
+    my $lf;
+    while (@focused > 0) {
+        $lf = $focused[0];
+        last unless defined($con->{focus});
+        @focused = @{$con->{focus}};
+        my @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
+        $con = $cons[0];
+    }
+
+    return $lf;
+}
+
+=head2 get_dock_clients([ $dockarea ])
+
+Returns an array of all dock containers in C<$dockarea> (one of "top" or
+"bottom"). If C<$dockarea> is not specified, returns an array of all dock
+containers in any dockarea.
+
+  my @docked = get_dock_clients;
+  is(scalar @docked, 0, 'no dock clients yet');
+
+=cut
+sub get_dock_clients {
+    my $which = shift;
+
+    my $tree = i3(get_socket_path())->get_tree->recv;
+    my @outputs = @{$tree->{nodes}};
+    # Children of all dockareas
+    my @docked;
+    for my $output (@outputs) {
+        if (!defined($which)) {
+            @docked = (@docked, map { @{$_->{nodes}} }
+                                grep { $_->{type} eq 'dockarea' }
+                                @{$output->{nodes}});
+        } elsif ($which eq 'top') {
+            my $first = first { $_->{type} eq 'dockarea' } @{$output->{nodes}};
+            @docked = (@docked, @{$first->{nodes}}) if defined($first);
+        } elsif ($which eq 'bottom') {
+            my @matching = grep { $_->{type} eq 'dockarea' } @{$output->{nodes}};
+            my $last = $matching[-1];
+            @docked = (@docked, @{$last->{nodes}}) if defined($last);
+        }
+    }
+    return @docked;
+}
+
+=head2 cmd($command)
+
+Sends the specified command to i3 and returns the output.
+
+  my $ws = unused_workspace;
+  cmd "workspace $ws";
+  cmd 'focus right';
+
+=cut
+sub cmd {
+    i3(get_socket_path())->command(@_)->recv
+}
+
+=head2 workspace_exists($workspace)
+
+Returns true if C<$workspace> is the name of an existing workspace.
+
+  my $old_ws = focused_ws;
+  # switch away from where we currently are
+  fresh_workspace;
+
+  ok(workspace_exists($old_ws), 'old workspace still exists');
+
+=cut
+sub workspace_exists {
+    my ($name) = @_;
+    (scalar grep { $_ eq $name } @{get_workspace_names()}) > 0;
+}
+
+=head2 focused_ws
+
+Returns the name of the currently focused workspace.
+
+  my $ws = focused_ws;
+  is($ws, '1', 'i3 starts on workspace 1');
+
+=cut
+sub focused_ws {
+    my $i3 = i3(get_socket_path());
+    my $tree = $i3->get_tree->recv;
+    my $focused = $tree->{focus}->[0];
+    my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
+    my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
+    my $first = first { $_->{fullscreen_mode} == 1 } @{$content->{nodes}};
+    return $first->{name}
+}
+
+=head2 sync_with_i3([ $args ])
+
+Sends an I3_SYNC ClientMessage with a random value to the root window.
+i3 will reply with the same value, but, due to the order of events it
+processes, only after all other events are done.
+
+This can be used to ensure the results of a cmd 'focus left' are pushed to
+X11 and that C<< $x->input_focus >> returns the correct value afterwards.
+
+See also L<http://build.i3wm.org/docs/testsuite.html> for a longer explanation.
+
+  my $window = open_window;
+  $window->add_hint('urgency');
+  # Ensure i3 picked up the change
+  sync_with_i3;
+
+The only time when you need to use the C<no_cache> argument is when you just
+killed your own X11 connection:
+
+  cmd 'kill client';
+  # We need to re-establish the X11 connection which we just killed :).
+  $x = i3test::X11->new;
+  sync_with_i3(no_cache => 1);
+
+=cut
+sub sync_with_i3 {
+    my %args = @_ == 1 ? %{$_[0]} : @_;
+
+    # Since we need a (mapped) window for receiving a ClientMessage, we create
+    # one on the first call of sync_with_i3. It will be re-used in all
+    # subsequent calls.
+    if (!exists($args{window_id}) &&
+        (!defined($_sync_window) || exists($args{no_cache}))) {
+        $_sync_window = open_window(
+            rect => [ -15, -15, 10, 10 ],
+            override_redirect => 1,
+        );
+    }
+
+    my $window_id = delete $args{window_id};
+    $window_id //= $_sync_window->id;
+
+    my $root = $x->get_root_window();
+    # Generate a random number to identify this particular ClientMessage.
+    my $myrnd = int(rand(255)) + 1;
+
+    # Generate a ClientMessage, see xcb_client_message_t
+    my $msg = pack "CCSLLLLLLL",
+         CLIENT_MESSAGE, # response_type
+         32,     # format
+         0,      # sequence
+         $root,  # destination window
+         $x->atom(name => 'I3_SYNC')->id,
+
+         $window_id,    # data[0]: our own window id
+         $myrnd, # data[1]: a random value to identify the request
+         0,
+         0,
+         0;
+
+    # Send it to the root window -- since i3 uses the SubstructureRedirect
+    # event mask, it will get the ClientMessage.
+    $x->send_event(0, $root, EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
+
+    return $myrnd if $args{dont_wait_for_event};
+
+    # now wait until the reply is here
+    return wait_for_event 4, sub {
+        my ($event) = @_;
+        # TODO: const
+        return 0 unless $event->{response_type} == 161;
+
+        my ($win, $rnd) = unpack "LL", $event->{data};
+        return ($rnd == $myrnd);
+    };
+}
+
+=head2 exit_gracefully($pid, [ $socketpath ])
+
+Tries to exit i3 gracefully (with the 'exit' cmd) or kills the PID if that fails.
+
+If C<$socketpath> is not specified, C<get_socket_path()> will be called.
+
+You only need to use this function if you have launched i3 on your own with
+C<launch_with_config>. Otherwise, it will be automatically called when the
+testcase ends.
+
+  use i3test i3_autostart => 0;
+  my $pid = launch_with_config($config);
+  # …
+  exit_gracefully($pid);
+
+=cut
+sub exit_gracefully {
+    my ($pid, $socketpath) = @_;
+    $socketpath ||= get_socket_path();
+
+    my $exited = 0;
+    eval {
+        say "Exiting i3 cleanly...";
+        i3($socketpath)->command('exit')->recv;
+        $exited = 1;
+    };
+
+    if (!$exited) {
+        kill(9, $pid)
+            or $tester->BAIL_OUT("could not kill i3");
+    }
+
+    if ($socketpath =~ m,^/tmp/i3-test-socket-,) {
+        unlink($socketpath);
+    }
+
+    waitpid $pid, 0;
+    undef $i3_pid;
+}
+
+=head2 get_socket_path([ $cache ])
+
+Gets the socket path from the C<I3_SOCKET_PATH> atom stored on the X11 root
+window. After the first call, this function will return a cached version of the
+socket path unless you specify a false value for C<$cache>.
+
+  my $i3 = i3(get_socket_path());
+  $i3->command('nop test example')->recv;
+
+To avoid caching:
+
+  my $i3 = i3(get_socket_path(0));
+
+=cut
+sub get_socket_path {
+    my ($cache) = @_;
+    $cache //= 1;
+
+    if ($cache && defined($_cached_socket_path)) {
+        return $_cached_socket_path;
+    }
+
+    my $atom = $x->atom(name => 'I3_SOCKET_PATH');
+    my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
+    my $reply = $x->get_property_reply($cookie->{sequence});
+    my $socketpath = $reply->{value};
+    if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") {
+        $socketpath .= '-activation';
+    }
+    $_cached_socket_path = $socketpath;
+    return $socketpath;
+}
+
+=head2 launch_with_config($config, [ $args ])
+
+Launches a new i3 process with C<$config> as configuration file. Useful for
+tests which test specific config file directives.
+
+  use i3test i3_autostart => 0;
+
+  my $config = <<EOT;
+  # i3 config file (v4)
+  for_window [class="borderless"] border none
+  for_window [title="special borderless title"] border none
+  EOT
+
+  my $pid = launch_with_config($config);
+
+  # …
+
+  exit_gracefully($pid);
+
+=cut
+sub launch_with_config {
+    my ($config, %args) = @_;
+
+    $tmp_socket_path = "/tmp/nested-$ENV{DISPLAY}";
+
+    $args{dont_create_temp_dir} //= 0;
+    $args{validate_config} //= 0;
+
+    my ($fh, $tmpfile) = tempfile("i3-cfg-for-$ENV{TESTNAME}-XXXXX", UNLINK => 1);
+
+    if ($config ne '-default') {
+        say $fh $config;
+    } else {
+        open(my $conf_fh, '<', '@abs_top_srcdir@/testcases/i3-test.config')
+            or $tester->BAIL_OUT("could not open default config: $!");
+        local $/;
+        say $fh scalar <$conf_fh>;
+    }
+
+    say $fh "ipc-socket $tmp_socket_path"
+        unless $args{dont_add_socket_path};
+
+    close($fh);
+
+    my $cv = AnyEvent->condvar;
+    $i3_pid = activate_i3(
+        unix_socket_path => "$tmp_socket_path-activation",
+        display => $ENV{DISPLAY},
+        configfile => $tmpfile,
+        outdir => $ENV{OUTDIR},
+        testname => $ENV{TESTNAME},
+        valgrind => $ENV{VALGRIND},
+        strace => $ENV{STRACE},
+        xtrace => $ENV{XTRACE},
+        restart => $ENV{RESTART},
+        cv => $cv,
+        dont_create_temp_dir => $args{dont_create_temp_dir},
+        validate_config => $args{validate_config},
+    );
+
+    # If we called i3 with -C, we wait for it to exit and then return as
+    # there's nothing else we need to do.
+    if ($args{validate_config}) {
+        $cv->recv;
+        waitpid $i3_pid, 0;
+
+        # We need this since exit_gracefully will not be called in this case.
+        undef $i3_pid;
+
+        return ${^CHILD_ERROR_NATIVE};
+    }
+
+    # force update of the cached socket path in lib/i3test
+    # as soon as i3 has started
+    $cv->cb(sub { get_socket_path(0) });
+
+    return $cv if $args{dont_block};
+
+    # blockingly wait until i3 is ready
+    $cv->recv;
+
+    return $i3_pid;
+}
+
+=head2 get_i3_log
+
+Returns the content of the log file for the current test.
+
+=cut
+sub get_i3_log {
+    my $logfile = "$ENV{OUTDIR}/i3-log-for-$ENV{TESTNAME}";
+    return slurp($logfile);
+}
+
+=head1 AUTHOR
+
+Michael Stapelberg <michael@i3wm.org>
+
+=cut
+
+package i3test::X11;
+use parent 'X11::XCB::Connection';
+
+sub input_focus {
+    my $self = shift;
+    i3test::sync_with_i3();
+
+    return $self->SUPER::input_focus(@_);
+}
+
+1
index d098ae58bef7a5ab3c066afb8556d88e45157aa4..5bd21128348f463277628786d89272229a02f152 100644 (file)
@@ -29,7 +29,7 @@ sub migrate_config {
     print $fh $config;
     close($fh);
 
-    my $cmd = "sh -c 'exec " . abs_path("../i3-migrate-config-to-v4") . " --v3 <$tmpfile'";
+    my $cmd = "sh -c 'exec i3-migrate-config-to-v4 --v3 <$tmpfile'";
     return [ split /\n/, qx($cmd) ];
 }
 
index b27bed53ed0648c05a742919d26ab1fc98aa3c08..4456b1d0433db35cd0f5d7c5d3ace14b480b5d15 100644 (file)
@@ -192,7 +192,7 @@ is_num_children($third_ws, 2, 'two containers on the third workspace');
 # environment variable.
 ######################################################################
 
-mkfifo($tmp, 0600) or BAIL_OUT "Could not create FIFO in $tmp";
+mkfifo($tmp, 0600) or BAIL_OUT "Could not create FIFO in $tmp: $!";
 
 cmd qq|exec --no-startup-id echo \$DESKTOP_STARTUP_ID >$tmp|;
 
@@ -208,7 +208,7 @@ is($startup_id, '', 'startup_id empty');
 # 4) same thing, but with double quotes in exec
 ######################################################################
 
-mkfifo($tmp, 0600) or BAIL_OUT "Could not create FIFO in $tmp";
+mkfifo($tmp, 0600) or BAIL_OUT "Could not create FIFO in $tmp: $!";
 
 cmd qq|exec --no-startup-id "echo \$DESKTOP_STARTUP_ID >$tmp"|;
 
index 73c443f996b9e43a7620603e46cf20fe9b435110..dc5b67ed127a73b08212d77dfc234d9f39eeace1 100644 (file)
@@ -25,7 +25,7 @@ sub parser_calls {
 
     # TODO: use a timeout, so that we can error out if it doesn’t terminate
     # TODO: better way of passing arguments
-    my $stdout = qx(../test.commands_parser '$command' 2>&1 >&-);
+    my $stdout = qx(test.commands_parser '$command' 2>&1 >&-);
 
     # Filter out all debugging output.
     my @lines = split("\n", $stdout);
index e5049eb8688f0dd4da817b8bd853229f1661d2f6..7c53732b45fed778ced9515c89c601b0434ec284 100644 (file)
@@ -28,7 +28,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
 workspace 2 output DVI-I_1/digital
 EOT
 
-my $output = qx(../i3 -C -c $filename);
+my $output = qx(i3 -C -c $filename);
 unlike($output, qr/ERROR/, 'no errors in i3 -C');
 
 close($fh);
index d92d3b2093a9b627e1860a6feb60eb56e67a2d18..6cd84b6f1dfc39d918048accb8ce06b65afa0d7e 100644 (file)
@@ -25,7 +25,7 @@ sub parser_calls {
     my ($command) = @_;
 
     my $stdout;
-    run [ '../test.config_parser', $command ],
+    run [ 'test.config_parser', $command ],
         '>/dev/null',
         '2>', \$stdout;
     # TODO: use a timeout, so that we can error out if it doesn’t terminate
index b63a74996aead7d0bc31d7d581a42e3ebdfb7cb8..b6c6d7767a000b1fab353c58ff85d5169a1e5b25 100644 (file)
@@ -33,7 +33,7 @@ my $pid = launch_with_config($config);
 
 my $stdout;
 my $stderr;
-run [ '../i3-dump-log/i3-dump-log' ],
+run [ 'i3-dump-log' ],
     '>', \$stdout,
     '2>', \$stderr;
 
@@ -49,7 +49,7 @@ cmd 'shmlog on';
 my $random_nop = mktemp('nop.XXXXXX');
 cmd "nop $random_nop";
 
-run [ '../i3-dump-log/i3-dump-log' ],
+run [ 'i3-dump-log' ],
     '>', \$stdout,
     '2>', \$stderr;
 
@@ -62,7 +62,7 @@ like($stderr, qr#^$#, 'stderr empty');
 
 cmd 'shmlog ' . (23 * 1024 * 1024);
 
-run [ '../i3-dump-log/i3-dump-log' ],
+run [ 'i3-dump-log' ],
     '>', \$stdout,
     '2>', \$stderr;
 
@@ -75,7 +75,7 @@ like($stderr, qr#^$#, 'stderr empty');
 
 cmd 'shmlog off';
 
-run [ '../i3-dump-log/i3-dump-log' ],
+run [ 'i3-dump-log' ],
     '>', \$stdout,
     '2>', \$stderr;
 
index ec17353e177c56e9d64043e2c82aea44a28908f1..5e87d9922a2579e32116d6bc71f2274a19abf821 100644 (file)
@@ -26,7 +26,7 @@ sub check_config {
     my ($config) = @_;
     my ($fh, $tmpfile) = tempfile(UNLINK => 1);
     print $fh $config;
-    my $output = qx(DISPLAY= ../i3 -C -c $tmpfile 2>&1);
+    my $output = qx(DISPLAY= i3 -C -c $tmpfile 2>&1);
     my $retval = $?;
     $fh->flush;
     close($fh);
index 71feec31a57855e20036001a98a14c1ab26f777e..6d070136b9640370feeb6a5ac1bbb504314b41fc 100755 (executable)
@@ -29,13 +29,13 @@ my $binary_spelling_exceptions = {
     'betwen' => 1, # asan_flags.inc contains this spelling error.
 };
 my @binaries = qw(
-    i3
-    i3-config-wizard/i3-config-wizard
-    i3-dump-log/i3-dump-log
-    i3-input/i3-input
-    i3-msg/i3-msg
-    i3-nagbar/i3-nagbar
-    i3bar/i3bar
+    build/i3
+    build/i3-config-wizard/i3-config-wizard
+    build/i3-dump-log/i3-dump-log
+    build/i3-input/i3-input
+    build/i3-msg/i3-msg
+    build/i3-nagbar/i3-nagbar
+    build/i3bar/i3bar
 );
 for my $binary (@binaries) {
     check_spelling(slurp($binary), $binary_spelling_exceptions, sub {
@@ -50,7 +50,7 @@ for my $binary (@binaries) {
 my $manpage_spelling_exceptions = {
 };
 
-for my $name (glob('man/*.1')) {
+for my $name (glob('build/man/*.1')) {
     for my $line (split(/\n/, slurp($name))) {
         next if $line =~ /^\.\\\"/o;
         check_spelling($line, $manpage_spelling_exceptions, sub {
index 05d541191c370fd9248b466211bacab53566327e..97c11fccda91b80386bb932d71a0fa7db0cdff16 100755 (executable)
@@ -3,7 +3,7 @@
 set -e
 set -x
 
-mkdir -p deb/DIST-clang
+mkdir -p deb/DIST-clang/build
 tar xf *.tar.bz2 -C deb/DIST-clang --strip-components=1
-(cd deb/DIST-clang && scan-build -o ../CLANG --html-title="Analysis of i3 v$(git describe --tags)" make -j8)
+(cd deb/DIST-clang/build && scan-build -o ../../CLANG ../configure && scan-build -o ../../CLANG --html-title="Analysis of i3 v$(git describe --tags)" make -j8)
 mv deb/CLANG/*/* deb/CLANG
index 655bd5c41e8bd4ac0917fff052b8769ab1ac70a0..9ce5a5aff6838e3279733079246c18ae8c9d1be5 100755 (executable)
@@ -5,12 +5,15 @@ set -x
 
 DEST=$1
 
-make store_git_version
-make dist
+mkdir -p build
+cd build
+../configure
+make echo-version > ../I3_VERSION
+make dist-bzip2
 # unpack dist tarball
 mkdir -p "${DEST}"
 tar xf *.tar.bz2 -C "${DEST}" --strip-components=1
-cp -r debian "${DEST}"
+cp -r ../debian "${DEST}"
 sed -i '/^\s*libxcb-xrm-dev/d' deb/ubuntu-*/DIST/debian/control || true
 cd "${DEST}"
 debchange -m -l+g$(git describe --tags) 'Automatically built'
index d8a40d77027e38aab69be908bdf47202a20e1cbb..44df81d2ffbdf257fdb0c428999290c56c711db5 100755 (executable)
@@ -3,7 +3,7 @@
 set -e
 set -x
 
-cd testcases
+cd build
 
 # TODO: remove this workaround once https://bugs.debian.org/836723 is fixed
 # Found at https://llvm.org/bugs/show_bug.cgi?id=27310#c8:
@@ -26,7 +26,7 @@ fi
 
 # Try running the tests in parallel so that the common case (tests pass) is
 # quick, but fall back to running them in sequence to make debugging easier.
-if ! xvfb-run ./complete-run.pl
+if ! xvfb-run make check
 then
-       xvfb-run ./complete-run.pl --parallel=1 || (cat latest/complete-run.log; false)
+       xvfb-run ./testcases/complete-run.pl --parallel=1 || (cat latest/complete-run.log; false)
 fi