Source: lnav
Version: 0.8.5-2
Tags: patch upstream
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

lnav fails to cross build from source for multiple reasons. The
immediate failure comes from adding /usr/lib/x86_64-linux-gnu to the
library search path. This is totally wrong and leads gcc to using
incompatible libraries.

The second failure is tring to execute bin2c. It's only used during
building and it is a tool whose behaviour is not dependent on the
architecture it is built on. Thus we should use the build architecture
compiler here. It can be detected using the AX_CC_FOR_BUILD macro from
the autoconf-archive.

Then ptimec fails to run for the same reason as failing to run bin2c.
I'm not sure what ptimec does exactly and whether it can be similarly
compiled using the build architecture compiler. Thus my patch only
solves the former problems. Please consider applying it anyway as a step
towards making lnav cross buildable. Please close this bug when doing
so even though lnav will continue to fail cross building.

Helmut
--- lnav-0.8.5.orig/configure.ac
+++ lnav-0.8.5/configure.ac
@@ -16,20 +16,6 @@
     fi
 done
 
-for defdir in /opt/local /usr/local /usr /; do
-
-    if test -d "$defdir/lib64"; then
-        LDFLAGS="$LDFLAGS -L$defdir/lib64"
-    fi
-    if test -d "$defdir/lib"; then
-        LDFLAGS="$LDFLAGS -L$defdir/lib"
-    fi
-
-    if test -d "$defdir/lib/x86_64-linux-gnu"; then
-        LDFLAGS="$LDFLAGS -L$defdir/lib/x86_64-linux-gnu"
-    fi
-done
-
 dnl abssrcdir is the absolute path to the source base (regardless of where
 dnl you are building it)
 AS_CASE([x$srcdir],
@@ -41,6 +27,7 @@
 AC_SUBST(abssrcdir)
 
 AC_PROG_CXX
+AX_CC_FOR_BUILD
 
 CPPFLAGS="$CPPFLAGS -D_ISOC99_SOURCE -D__STDC_LIMIT_MACROS -D_GNU_SOURCE"
 
--- lnav-0.8.5.orig/src/Makefile.am
+++ lnav-0.8.5/src/Makefile.am
@@ -1,7 +1,7 @@
 
 bin_PROGRAMS = lnav
 
-noinst_PROGRAMS = bin2c ptimec lnav-test
+noinst_PROGRAMS = ptimec lnav-test
 
 noinst_LIBRARIES = libdiag.a
 
@@ -17,26 +17,26 @@
 RE2C_V_ = $(RE2C_V_@AM_DEFAULT_V@)
 RE2C_V_0 = @echo "  RE2C   " $@;
 
-help.c: $(srcdir)/help.txt bin2c
-	$(BIN2C_V)./bin2c -z -c $(srcdir)/help.txt $@
+help.c: $(srcdir)/help.txt bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $(srcdir)/help.txt $@
 
-dump-pid-sh.c: $(srcdir)/dump-pid.sh bin2c
-	$(BIN2C_V)./bin2c -z -c $(srcdir)/dump-pid.sh $@
+dump-pid-sh.c: $(srcdir)/dump-pid.sh bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $(srcdir)/dump-pid.sh $@
 
-default-log-formats-json.c: $(srcdir)/default-log-formats.json bin2c
-	$(BIN2C_V)./bin2c -z -c $(srcdir)/default-log-formats.json $@
+default-log-formats-json.c: $(srcdir)/default-log-formats.json bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $(srcdir)/default-log-formats.json $@
 
-default-config-json.c: $(srcdir)/default-config.json bin2c
-	$(BIN2C_V)./bin2c -z -c $(srcdir)/default-config.json $@
+default-config-json.c: $(srcdir)/default-config.json bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $(srcdir)/default-config.json $@
 
-init-sql.c: bin2c init.sql
-	$(BIN2C_V)./bin2c -z -c $(srcdir)/init.sql $@
+init-sql.c: bin2c$(EXEEXT_FOR_BUILD) init.sql
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $(srcdir)/init.sql $@
 
-%.c: $(srcdir)/%.lnav bin2c
-	$(BIN2C_V)./bin2c -z -c $< $@
+%.c: $(srcdir)/%.lnav bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $< $@
 
-%.c: $(srcdir)/%.json bin2c
-	$(BIN2C_V)./bin2c -z -c $< $@
+%.c: $(srcdir)/%.json bin2c$(EXEEXT_FOR_BUILD)
+	$(BIN2C_V)./bin2c$(EXEEXT_FOR_BUILD) -z -c $< $@
 
 TIME_FORMATS = \
     "@%@" \
@@ -401,8 +401,8 @@
 	$(TEXT2C_FILES) \
 	$(LDADD)
 
-bin2c_SOURCES = bin2c.c
-bin2c_LDADD =
+bin2c$(EXEEXT_FOR_BUILD): bin2c.c
+	$(CC_FOR_BUILD) $< -o $@
 
 ptimec_SOURCES = ptimec.cc
 ptimec_LDADD =

Reply via email to