Source: lp-solve
Version: 5.5.2.11-2
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

lp-solve fails to cross build from source for multiple reason. Number
one is that debian/rules does not tell the upstream builds scripts about
what architecture we are building for in any way. The upstream build
scripts also provide no way of picking up this information and just hard
code the build architecture compiler. They also run a test program to
determine whether we're on a 64bit or 32bit system. I'm attaching a
patch to address all of these aspects. A significant portion of it
likely should go upstream and generally helps with cross building also
on other distributions such as Yocto or PtxDist.

Helmut
diff --minimal -Nru lp-solve-5.5.2.11/debian/changelog 
lp-solve-5.5.2.11/debian/changelog
--- lp-solve-5.5.2.11/debian/changelog  2024-08-04 21:40:47.000000000 +0200
+++ lp-solve-5.5.2.11/debian/changelog  2024-08-17 18:26:34.000000000 +0200
@@ -1,3 +1,14 @@
+lp-solve (5.5.2.11-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Pass a host compiler to the compilation scripts.
+    + cross.patch: Pick up the passed compiler.
+    + Rewrite platform check as compile-only test.
+    + Do not fail removal of temporary files that may be missing.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 17 Aug 2024 18:26:34 +0200
+
 lp-solve (5.5.2.11-2) unstable; urgency=medium
 
   * upload to unstable
diff --minimal -Nru lp-solve-5.5.2.11/debian/patches/cross.patch 
lp-solve-5.5.2.11/debian/patches/cross.patch
--- lp-solve-5.5.2.11/debian/patches/cross.patch        1970-01-01 
01:00:00.000000000 +0100
+++ lp-solve-5.5.2.11/debian/patches/cross.patch        2024-08-17 
18:26:34.000000000 +0200
@@ -0,0 +1,72 @@
+--- lp-solve-5.5.2.11.orig/lp_solve/ccc
++++ lp-solve-5.5.2.11/lp_solve/ccc
+@@ -1,6 +1,6 @@
+ :
+ src="lp_solve.c"
+-c=cc
++c="${CC:-cc}"
+ 
+ MYTMP=`mktemp -d "${TMPDIR:-/tmp}"/lp_solve_XXXXXX`
+ 
+@@ -8,10 +8,12 @@
+ >"$MYTMP"/platform.c
+ echo '#include <stdlib.h>'>>"$MYTMP"/platform.c
+ echo '#include <stdio.h>'>>"$MYTMP"/platform.c
+-echo 'int main(){printf("ux%d", (int) (sizeof(void 
*)*8));}'>>"$MYTMP"/platform.c
+-$c "$MYTMP"/platform.c -o "$MYTMP"/platform
+-PLATFORM=`"$MYTMP"/platform`
+-rm "$MYTMP"/platform "$MYTMP"/platform.c >/dev/null 2>&1
++echo 'int main(){char x[6-sizeof(void *)]; return 0 * 
x[0];}'>>"$MYTMP"/platform.c
++if $c "$MYTMP"/platform.c -o "$MYTMP"/platform 2>/dev/null
++then PLATFORM=ux32
++else PLATFORM=ux64
++fi
++rm -f "$MYTMP"/platform "$MYTMP"/platform.c >/dev/null 2>&1
+ 
+ mkdir bin bin/$PLATFORM >/dev/null 2>&1
+ 
+@@ -28,7 +30,7 @@
+ then NOISNAN=
+ else NOISNAN=-DNOISNAN
+ fi
+-rm "$MYTMP"/isnan.c "$MYTMP"/isnan >/dev/null 2>&1
++rm -f "$MYTMP"/isnan.c "$MYTMP"/isnan >/dev/null 2>&1
+ 
+ opts='-O2'
+ 
+--- lp-solve-5.5.2.11.orig/lpsolve55/ccc
++++ lp-solve-5.5.2.11/lpsolve55/ccc
+@@ -1,6 +1,6 @@
+ :
+ src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c 
../ini.c ../fortify.c ../lp_rlp.c ../lp_crash.c ../bfp/bfp_LUSOL/lp_LUSOL.c 
../bfp/bfp_LUSOL/LUSOL/lusol.c ../lp_Hash.c ../lp_lib.c ../lp_wlp.c 
../lp_matrix.c ../lp_mipbb.c ../lp_MPS.c ../lp_params.c ../lp_presolve.c 
../lp_price.c ../lp_pricePSE.c ../lp_report.c ../lp_scale.c ../lp_simplex.c 
../lp_SOS.c ../lp_utils.c ../yacc_read.c'
+-c=cc
++c="${CC:-cc}"
+ 
+ MYTMP=`mktemp -d "${TMPDIR:-/tmp}"/lp_solve_XXXXXX`
+ 
+@@ -8,10 +8,12 @@
+ >"$MYTMP"/platform.c
+ echo '#include <stdlib.h>'>>"$MYTMP"/platform.c
+ echo '#include <stdio.h>'>>"$MYTMP"/platform.c
+-echo 'int main(){printf("ux%d", (int) (sizeof(void 
*)*8));}'>>"$MYTMP"/platform.c
+-$c "$MYTMP"/platform.c -o "$MYTMP"/platform
+-PLATFORM=`"$MYTMP"/platform`
+-rm "$MYTMP"/platform "$MYTMP"/platform.c >/dev/null 2>&1
++echo 'int main(){char x[6-sizeof(void *)]; return 0 * 
x[0];}'>>"$MYTMP"/platform.c
++if $c "$MYTMP"/platform.c -o "$MYTMP"/platform 2>/dev/null
++then PLATFORM=ux32
++else PLATFORM=ux64
++fi
++rm -f "$MYTMP"/platform "$MYTMP"/platform.c >/dev/null 2>&1
+ 
+ mkdir bin bin/$PLATFORM >/dev/null 2>&1
+ 
+@@ -26,7 +28,7 @@
+ then NOISNAN=
+ else NOISNAN=-DNOISNAN
+ fi
+-rm "$MYTMP"/isnan.c "$MYTMP"/isnan >/dev/null 2>&1
++rm -f "$MYTMP"/isnan.c "$MYTMP"/isnan >/dev/null 2>&1
+ 
+ rmdir "$MYTMP"
+ 
diff --minimal -Nru lp-solve-5.5.2.11/debian/patches/series 
lp-solve-5.5.2.11/debian/patches/series
--- lp-solve-5.5.2.11/debian/patches/series     2024-07-26 20:03:43.000000000 
+0200
+++ lp-solve-5.5.2.11/debian/patches/series     2024-08-17 18:26:09.000000000 
+0200
@@ -5,3 +5,4 @@
 07_fix_xli_CPLEX-segfault
 09_lp_solve.1
 10_int_main.diff
+cross.patch
diff --minimal -Nru lp-solve-5.5.2.11/debian/rules 
lp-solve-5.5.2.11/debian/rules
--- lp-solve-5.5.2.11/debian/rules      2016-05-23 15:06:35.000000000 +0200
+++ lp-solve-5.5.2.11/debian/rules      2024-08-17 18:26:32.000000000 +0200
@@ -10,6 +10,9 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
+DPKG_EXPORT_BUILDTOOLS=1
+include /usr/share/dpkg/buildtools.mk
+
 build: build-arch build-indep
 
 build-arch: build-arch-stamp

Reply via email to