bug-hello
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross-Compiling fails due to man-page generation


From: Sami Kerola
Subject: Re: Cross-Compiling fails due to man-page generation
Date: Sat, 19 Jul 2014 19:27:12 +0100

On 17 July 2014 06:58, Assaf Gordon <address@hidden> wrote:
> Hello,
>
> I've encountered a problem where GNU Hello build fails with a cross
> compiler, after the switch to non-recursive make
> (of course there's no reason to need GNU hello cross-compiled, but my
> project is based on GNU hello's build system).

Hi Assaf,

Thank you for the issue report.  I agree there is little point in cross
compiling GNU Hello, just as there is little use for greeting program in
itself.  The hello should be fully working and complete demonstration of
autotools and other GNU project setup, so it's fair to say that an issue
like this invalidates the example until code is corrected.

> If I use:
>     ./configure --host=arm-linux-gnueabi
>
> Then 'make' fails in the man-page step:
>     <...>
>     make[2]: Entering directory
> '/home/gordon/projects/hello/temp/hello-2.9.38-6bac'
>     : --include=./man/hello.x ./hello -o hello.1-t
>     chmod a=r hello.1-t
>     chmod: cannot access 'hello.1-t': No such file or directory
>     Makefile:2605: recipe for target 'hello.1' failed
>     make[2]: *** [hello.1] Error 1
>     make[2]: Leaving directory
> '/home/gordon/projects/hello/temp/hello-2.9.38-6bac'
>     Makefile:1872: recipe for target 'all-recursive' failed
>     make[1]: *** [all-recursive] Error 1
>     make[1]: Leaving directory
> '/home/gordon/projects/hello/temp/hello-2.9.38-6bac'
>     Makefile:1407: recipe for target 'all' failed
>     make: *** [all] Error 2
>     If I trace it back correctly, then "configure" has this statement:
>     if test $cross_compiling = no; then :
>       HELP2MAN=${HELP2MAN-"${am_missing_run}help2man"}
>     else
>       HELP2MAN=:
>     fi
>
> Which makes HELP2MAN a no-op in a cross-compile, but the rule in
> "Makefile.am" is:
>     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 $@
>
> Which assumes "HELP2MAN" will always run, and re-generate "hello.1".
>
> I suspect this rule needs to be a bit more complicated, to accommodate few
> possibilities:
> 1. Native compiling from GIT repository, where "hello.1" doesn't exist (yet)
> and "hello" can be executed - then "hello.1" can be generated.

This seems right.

> 2. Native compiling from tarball, where "hello.1" already exists (due to
> 'make dist') and "hello" can be executed - then either re-generate "hello.1"
> or not ?

Output at this point the content of the manual is fixed, so I am voting
for not re-generating.

> 3. Cross-compiling from GIT repository, "hello.1" doesn't exist but "hello"
> *can not* be executed - ignore and use empty "hello.1" ?

Distributing empty manuals sounds wrong.  When cross-compiling from git
the segment requiring manuals needs to be suppressed from Makefile.am.

> 4. Cross-compiling from tarball, where "hello.1" exists but "hello" *can
> not* be executed - use existing "hello.1" (despite it being older than
> "hello", which might confuse the make target?) .

This makes sense.

> The following hack "works for me", thought I haven't thoroughly tested:
>
>     hello.1: hello
>             $(HELP2MAN) --include=$(top_srcdir)/man/hello.x
> $(top_builddir)/hello -o address@hidden
>             if test -e address@hidden ; then \
>               chmod a=r address@hidden ;\
>               mv -f address@hidden $@ ;\
>             elif ! test -e $@ ; then \
>               touch $@ ; \
>             fi
>
> (If the new temp man-page was created, override any existing man page. If
> not created, and no existing man page, create an empty one).

The change looks good.  Only one AM_CONDITIONAL is needed to make 3.
exclude the manuals when creating one is impossible or the least quite
difficult.

I haven't tested the following, but it might work.

-- snip
From: Assaf Gordon <address@hidden>
Date: Sat, 19 Jul 2014 19:20:54 +0100
Subject: [PATCH] build: do not fail cross compilation when cross-compiling

* configure.ac, Makefile.am: Add GIT_CROSS_COMPILING automake conditional
to exclude manual when it cannot be generated.
---
 Makefile.am  | 10 ++++++++--
 configure.ac |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 44957a4..a260e1a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,14 +43,20 @@ hello_LDADD = $(LIBINTL) $(top_builddir)/lib/lib$(PACKAGE).a
 localedir = $(datadir)/locale
 DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@

+if !GIT_CROSS_COMPILING
 man_MANS = hello.1
 EXTRA_DIST += $(man_MANS)
 CLEANFILES = $(man_MANS)

 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 $@
+ if test -e address@hidden ; then ; \
+ chmod a=r address@hidden ; \
+ mv -f address@hidden $@ ; \
+ elif ! test -e $@; then ; \
+ touch $@ ; \
+ fi
+fi

 TESTS = \
  tests/greeting-1 \
diff --git a/configure.ac b/configure.ac
index 6b32fb5..7d5a23c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ AS_IF([test $cross_compiling = no], [
   AM_MISSING_PROG([HELP2MAN], [help2man])
 ], [
   HELP2MAN=:
+  AM_CONDITIONAL([GIT_CROSS_COMPILING], [test -e .git])
 ])

 dnl i18n support from GNU gettext.
-- 
2.0.2
-- snip

> For comparison, the last tarball release of GNU Hello version 2.9 which
> still uses recursive makefiles compiles fine under cross-compiler.

That release did not have intermediate address@hidden file, and it did not also
work when compiled from git.  Fair to say the earlier version was better,
but not good enough.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]