Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:f93c2a11c2496171dbc5a74848d8d39828a3dd78
Author...:A. Gordon
Committer:Sami Kerola
Date.....:Wed Jul 23 21:27:48 2014 -0400
Parents..:6bac6fef21abf0853308f57d8958bd9ec2057a46

Message
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

Changes
diff --git a/Makefile.am b/Makefile.am
line changes: +8/-1
index 44957a4..352898b
--- 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 $@-t
 	chmod a=r $@-t
 	mv -f $@-t $@
 
+CLEANFILES += $(man_MANS)
+endif
+
 TESTS = \
 	tests/greeting-1 \
 	tests/greeting-2 \

diff --git a/configure.ac b/configure.ac
line changes: +7/-0
index 6b32fb5..2ac1fa2
--- 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

This website is licensed under AGPL-3.0. Feel free to copy!