Commit 41bea9ab2bf21e3e9544b4beed86a362fe40d57f

Ran Benita 2017-08-01T22:19:48

build: make doxygen run from the source tree I couldn't find any other way to make this work! Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/Makefile.am b/Makefile.am
index 5deef76..42c6ae9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = \
 	scripts/makekeys \
 	scripts/update-keysyms \
 	scripts/update-keywords \
+	scripts/doxygen-wrapper \
 	src/xkbcomp/keywords.gperf \
 	test/data \
 	README.md \
@@ -164,7 +165,7 @@ doc/html: doc/Doxyfile $(doxygen_input)
 	    cat $<; \
 	    echo "INPUT = $(doxygen_input)"; \
 	    echo "OUTPUT_DIRECTORY = $(abs_top_builddir)/doc"; \
-	) | $(DOXYGEN) -
+	) | $(top_srcdir)/scripts/doxygen-wrapper "$(DOXYGEN)" - "$(abs_top_srcdir)"
 clean-doxygen:
 	rm -rf doc/html
 
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 04a2991..798381f 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -2,6 +2,8 @@ PROJECT_NAME           = @PACKAGE_NAME@
 
 PROJECT_NUMBER         = @PACKAGE_VERSION@
 
+OUTPUT_DIRECTORY       = @OUTPUT_DIRECTORY@
+
 BRIEF_MEMBER_DESC      = NO
 
 JAVADOC_AUTOBRIEF      = YES
@@ -32,7 +34,7 @@ ALPHABETICAL_INDEX     = NO
 IGNORE_PREFIX          = xkb_ \
                          XKB_
 
-HTML_EXTRA_STYLESHEET  = @abs_top_srcdir@/doc/doxygen-extra.css
+HTML_EXTRA_STYLESHEET  = doc/doxygen-extra.css
 
 HTML_TIMESTAMP         = NO
 
diff --git a/meson.build b/meson.build
index 2b4a57a..7d517d7 100644
--- a/meson.build
+++ b/meson.build
@@ -447,36 +447,35 @@ if get_option('enable-docs')
         error('''Documentation requires doxygen which was not found.
 You can disable the documentation with -Denable-docs=false.''')
     endif
+    doxygen_wrapper = find_program('scripts/doxygen-wrapper')
 
     doxygen_input = [
-        join_paths(meson.source_root(), 'README.md'),
-        join_paths(meson.source_root(), 'doc/doxygen-extra.css'),
-        join_paths(meson.source_root(), 'doc/quick-guide.md'),
-        join_paths(meson.source_root(), 'doc/compat.md'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-names.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-x11.h'),
-        join_paths(meson.source_root(), 'xkbcommon/xkbcommon-compose.h'),
+        'README.md',
+        'doc/doxygen-extra.css',
+        'doc/quick-guide.md',
+        'doc/compat.md',
+        'xkbcommon/xkbcommon.h',
+        'xkbcommon/xkbcommon-names.h',
+        'xkbcommon/xkbcommon-x11.h',
+        'xkbcommon/xkbcommon-compose.h',
     ]
     doxygen_data = configuration_data()
     doxygen_data.set('PACKAGE_NAME', meson.project_name())
     doxygen_data.set('PACKAGE_VERSION', meson.project_version())
     doxygen_data.set('INPUT', ' '.join(doxygen_input))
-    doxygen_data.set('abs_top_srcdir', meson.source_root())
+    doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root())
     doxyfile = configure_file(
         input: 'doc/Doxyfile.in',
         output: 'Doxyfile',
         configuration: doxygen_data,
-        install: false,
     )
     # TODO: Meson should provide this.
     docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
-    # TODO: Relative links in README.md fail.
     custom_target(
         'doc',
         input: [doxyfile] + doxygen_input,
         output: 'html',
-        command: [doxygen, doxyfile],
+        command: [doxygen_wrapper, doxygen.path(), join_paths(meson.build_root(), 'Doxyfile'), meson.source_root()],
         install: true,
         install_dir: docdir,
         build_by_default: true,
diff --git a/scripts/doxygen-wrapper b/scripts/doxygen-wrapper
new file mode 100755
index 0000000..baa7b26
--- /dev/null
+++ b/scripts/doxygen-wrapper
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Run doxygen such that the working directory is the source root.
+# This is needed for various reasons (e.g. relative references in md files).
+# Do not use directly.
+DOXYGEN="$1"
+DOXYFILE="$2"
+ABS_TOP_SRCDIR="$3"
+cd "$ABS_TOP_SRCDIR" && exec "$DOXYGEN" "$DOXYFILE"