>From c81611edbcf05201bb017eb08494d4a00ece30b9 Mon Sep 17 00:00:00 2001 From: "A. Gordon" Date: Wed, 23 Jul 2014 21:27:48 -0400 Subject: [PATCH] build: generate man-page only when appropriate * configure.ac: detect compilation under git (vs tarball), and cross-compilation. * Makefile.am: 1) re-generate (and clean) man-page only when building from git. 2) if building from git AND cross-compiling, don't add target for man-page - there's no way to generate it. Possible future improvement: If cross-compliing from git, AND user have 'binfmt' configured to run non-native binaries, then the man-page can be generated. Reference: http://lists.gnu.org/archive/html/bug-hello/2014-07/msg00001.html --- Makefile.am | 9 ++++++++- configure.ac | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 44957a4..352898b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,15 +43,22 @@ hello_LDADD = $(LIBINTL) $(top_builddir)/lib/lib$(PACKAGE).a localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ +CLEANFILES = + +if !GIT_CROSS_COMPILING man_MANS = hello.1 EXTRA_DIST += $(man_MANS) -CLEANFILES = $(man_MANS) +endif +if BUILD_FROM_GIT hello.1: hello $(HELP2MAN) --include=$(top_srcdir)/man/hello.x $(top_builddir)/hello -o address@hidden chmod a=r address@hidden mv -f address@hidden $@ +CLEANFILES += $(man_MANS) +endif + TESTS = \ tests/greeting-1 \ tests/greeting-2 \ diff --git a/configure.ac b/configure.ac index 6b32fb5..2ac1fa2 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,13 @@ dnl Copyright will apply as long as these sources are in use, e.g., are dnl being compiled, which is reasonable year to claim the copyright. AC_DEFINE([COPYRIGHT_YEAR], [m4_esyscmd([date +%Y])], [year in copyright message]) +dnl Are we building from git checked-out sources, or a tarball ? +dnl This is used in "Makefile.am" to avoid re-generating the manpage +dnl when building from tarballs. +AM_CONDITIONAL([BUILD_FROM_GIT], [test -d "$srcdir/.git"]) +AM_CONDITIONAL([GIT_CROSS_COMPILING], + [test -d "$srcdir/.git" && test $cross_compiling = yes]) + dnl GNU help2man creates man pages from --help output; in many cases, this dnl is sufficient, and obviates the need to maintain man pages separately. dnl However, this means invoking executables, which we generally cannot do -- 1.9.1