Ohai,
we (Debian) got a report with a patch that should improve mutt cross
building: https://bugs.debian.org/843351
I'd like not to have yet another patch against mutt in Debian and thus
suggested the submitter to post it here, but it seems mutt-dev does not
allow posts by non-subscribers (:/ - but I totally can understand why).
Anyways, original mail by Helmut is attached, please have a look and
share your thoughts.
Greets
Evgeni
--- Begin Message ---
Hi mutt developers,
While conducting cross build tests on Debian, I noticed that mutt fails
to cross build from source. I submitted a Debian patch at
https://bugs.debian.org/843351 and would now like to discuss the
upstream portions here.
There are two major issues with cross building mutt. They are makedoc
and mutt_md5. In both cases, they are tools that are run during build.
Currently, the mutt build does not consider using the build architecture
compiler and simply compiles these tools with the host architecture
compiler. Consequently executing makedoc or mutt_md5 fails during cross
builds.
The attached patch fixes both issues at the expense of portability to
not-so-common platforms. It runs the macro AC_PROG_CC_FOR_BUILD
(available in the autoconf-archive) to set up variables such as
CC_FOR_BUILD, CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD
and BUILD_EXEEXT. These variables can then be used in the relevant
Makefile.am to use the build architecture compiler.
The more difficult aspect here is that these tools can no longer include
"config.h", because that file contains check results for the host
architecture that may be wrong for the build architecture. Thus my patch
removes that part and fixes the includes to work on reasonably posix-ish
systems. Checking for build architecture headers, does not seem to be
supported by autoconf, so I have no idea how to fix that part.
Does simply including e.g. <unistd.h>, <getopt.h> and <stdint.h> seem
reasonable to you? If yes, please consider applying the attached patch.
If no, I welcome any ideas to make this work.
Helmut
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@
if test "$ac_cv_prog_cc_c99" = "no"; then
AC_ERROR([Compiler does not support C99. Aborting.])
fi
+AC_PROG_CC_FOR_BUILD
if test "$CC" = "gcc"; then
CFLAGS="$CFLAGS -fno-delete-null-pointer-checks"
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -130,11 +130,14 @@
Muttrc: stamp-doc-rc
-stamp-doc-rc: $(top_srcdir)/init.h makedoc$(EXEEXT) $(srcdir)/Muttrc.head
+makedoc$(BUILD_EXEEXT): makedoc.c makedoc-defs.h
+ $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $< -o $@
+
+stamp-doc-rc: $(top_srcdir)/init.h makedoc$(BUILD_EXEEXT) $(srcdir)/Muttrc.head
-rm -f Muttrc stamp-doc-rc
sed -e 's,[@]docdir[@],$(docdir),' $(srcdir)/Muttrc.head > Muttrc
$(CPP) $(AM_CPPFLAGS) $(DEFS) $(CPPFLAGS) -D_MAKEDOC -C \
- $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -c >> Muttrc
+ $(top_srcdir)/init.h | ./makedoc$(BUILD_EXEEXT) -c >> Muttrc
touch stamp-doc-rc
manual.html: $(srcdir)/html.xsl $(srcdir)/mutt.xsl stamp-doc-xml $(srcdir)/mutt.css
@@ -189,8 +192,8 @@
update-doc: stamp-doc-xml stamp-doc-chunked stamp-doc-rc manual.txt manual.html
-muttrc.man: makedoc$(EXEEXT) $(top_srcdir)/init.h muttrc.man.head muttrc.man.tail
- $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -m | \
+muttrc.man: makedoc$(BUILD_EXEEXT) $(top_srcdir)/init.h muttrc.man.head muttrc.man.tail
+ $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(BUILD_EXEEXT) -m | \
cat $(srcdir)/muttrc.man.head - $(srcdir)/muttrc.man.tail\
> muttrc.man
@@ -210,12 +213,12 @@
smime_keys.1: $(srcdir)/smime_keys.man
$(EDIT) $(srcdir)/smime_keys.man > $@
-stamp-doc-xml: makedoc$(EXEEXT) $(top_srcdir)/init.h \
+stamp-doc-xml: makedoc$(BUILD_EXEEXT) $(top_srcdir)/init.h \
manual.xml.head $(top_srcdir)/functions.h $(top_srcdir)/OPS* manual.xml.tail \
$(srcdir)/gen-map-doc
( date=`head -n 1 $(top_srcdir)/ChangeLog.neomutt | LC_ALL=C cut -b 1-10` && \
sed -e "s/@VERSION\@/$(PACKAGE_VERSION) (1.7.1)/" $(srcdir)/manual.xml.head && \
- $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -s && \
+ $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(BUILD_EXEEXT) -s && \
$(MAKEDOC_CPP) $(top_srcdir)/functions.h | \
perl $(srcdir)/gen-map-doc $(srcdir)/manual.xml.tail $(top_srcdir)/OPS* \
) > manual.xml
--- a/doc/makedoc.c
+++ b/doc/makedoc.c
@@ -27,36 +27,16 @@
**
**/
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-
#include <errno.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_GETOPT_H
-# include <getopt.h>
-#endif
+#include <unistd.h>
+#include <getopt.h>
#include "makedoc-defs.h"
-#ifndef HAVE_STRERROR
-#ifndef STDC_HEADERS
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
-
-#define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0
-#endif /* !HAVE_STRERROR */
-
extern int optind;
#define BUFFSIZE 2048
--- a/Makefile.am
+++ b/Makefile.am
@@ -101,14 +101,15 @@
pgpring_DEPENDENCIES = $(LIBOBJS) $(INTLDEPS)
mutt_md5_SOURCES = md5.c
-mutt_md5_CFLAGS = -DMD5UTIL
-mutt_md5_LDADD =
txt2c_SOURCES = txt2c.c
txt2c_LDADD =
noinst_PROGRAMS = $(MUTT_MD5) txt2c
+mutt_md5$(BUILD_EXEEXT): md5.c md5.h
+ $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) -DMD5UTIL $(LDFLAGS_FOR_BUILD) $< -o $@
+
mutt_dotlock.c: dotlock.c
cp $(srcdir)/dotlock.c mutt_dotlock.c
--- a/md5.c
+++ b/md5.c
@@ -20,10 +20,6 @@
/* Written by Ulrich Drepper <drep...@gnu.ai.mit.edu>, 1995. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include "md5.h"
#include <stddef.h>
--- a/md5.h
+++ b/md5.h
@@ -28,9 +28,7 @@
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
-#if HAVE_STDINT_H || _LIBC
-# include <stdint.h>
-#endif
+#include <stdint.h>
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
--- End Message ---