config_host.mk.in                           |    3 ++
 configure.ac                                |   35 +++++++++++++++++++++++--
 external/lpsolve/ExternalProject_lpsolve.mk |    1 
 external/lpsolve/UnpackedTarball_lpsolve.mk |    1 
 external/lpsolve/ccc.static                 |   13 +++++++--
 external/lpsolve/system-colamd.diff         |   39 ++++++++++++++++++++++++++++
 6 files changed, 88 insertions(+), 4 deletions(-)

New commits:
commit e4dc378991002cdc64909af581053d588cc92a0a
Author:     Rene Engelhard <r...@rene-engelhard.de>
AuthorDate: Mon Mar 3 21:48:18 2025 +0100
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Tue Aug 5 12:17:08 2025 +0200

    implement --with-system-colamd (for internal lpsolve)
    
    using suitesparse. Tested with both suitesparse 5.12.0 (Debian stable,
    without pc) and 7.9.0 (Debian unstable, with .pc)
    
    Change-Id: I6e0d014455ea2dec111aa3380bd49bd586dfad0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182444
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/config_host.mk.in b/config_host.mk.in
index 33ae1a855f9c..eb900cf7ffac 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -95,6 +95,8 @@ export CPDB_CFLAGS=@CPDB_CFLAGS@
 export CPDB_LIBS=@CPDB_LIBS@
 export CPPU_ENV=@CPPU_ENV@
 export CPPU_ENV_FOR_BUILD=@CPPU_ENV_FOR_BUILD@
+export COLAMD_CFLAGS=$(gb_SPACE)@COLAMD_CFLAGS@
+export COLAMD_LIBS=$(gb_SPACE)@COLAMD_LIBS@
 export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@
 export CPPUNIT_LIBS=$(gb_SPACE)@CPPUNIT_LIBS@
 export CPUNAME=@CPUNAME@
@@ -657,6 +659,7 @@ SYSTEM_BOX2D=@SYSTEM_BOX2D@
 SYSTEM_BZIP2=@SYSTEM_BZIP2@
 SYSTEM_CAIRO=@SYSTEM_CAIRO@
 SYSTEM_CLUCENE=@SYSTEM_CLUCENE@
+SYSTEM_COLAMD=@SYSTEM_COLAMD@
 SYSTEM_CPPUNIT=@SYSTEM_CPPUNIT@
 SYSTEM_CURL=@SYSTEM_CURL@
 SYSTEM_DICTS=@SYSTEM_DICTS@
diff --git a/configure.ac b/configure.ac
index 70f8efbf2152..75fa898b7f55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2768,6 +2768,11 @@ AC_ARG_WITH(system-lpsolve,
         [Use lpsolve already on system.]),,
     [with_system_lpsolve="$with_system_libs"])
 
+AC_ARG_WITH(system-colamd,
+    AS_HELP_STRING([--with-system-colamd],
+        [Use COLAMD already on system.]),,
+    [with_system_colamd="$with_system_libs"])
+
 AC_ARG_WITH(system-coinmp,
     AS_HELP_STRING([--with-system-coinmp],
         [Use CoinMP already on system.]),,
@@ -12189,8 +12194,34 @@ if test "$ENABLE_LPSOLVE" = TRUE; then
         AC_MSG_RESULT([internal])
         SYSTEM_LPSOLVE=
         BUILD_TYPE="$BUILD_TYPE LPSOLVE"
-    fi
-fi
+        AC_MSG_CHECKING([which colamd to use])
+        if test "$with_system_colamd" = "yes"; then
+               AC_MSG_RESULT([external])
+               SYSTEM_COLAMD=TRUE
+               # This assumes suitesparse, which has
+               # /usr/lib/x86_64-linux-gnu/pkgconfig/COLAMD.pc
+               PKG_CHECK_MODULES([COLAMD], [COLAMD],
+                      [],
+                      [
+                       # older versions don't. Look in /usr/include/suitesparse
+                       COLAMD_CFLAGS=-I/usr/include/suitesparse
+                       save_CFLAGS=$CFLAGS
+                       CFLAGS="$CFLAGS $COLAMD_CFLAGS"
+                       AC_CHECK_HEADER(colamd.h, [],
+                               [ AC_MSG_ERROR(colamd.h header not found.)], [])
+                       CFLAGS=$save_CFLAGS
+                       AC_CHECK_LIB(colamd, colamd)
+                       COLAMD_LIBS=-lcolamd
+                     ])
+       else
+               AC_MSG_RESULT([internal])
+               SYSTEM_COLAMD=
+       fi
+    fi
+fi
+AC_SUBST(SYSTEM_COLAMD)
+AC_SUBST(COLAMD_CFLAGS)
+AC_SUBST(COLAMD_LIBS)
 AC_SUBST(SYSTEM_LPSOLVE)
 
 dnl ===================================================================
diff --git a/external/lpsolve/ExternalProject_lpsolve.mk 
b/external/lpsolve/ExternalProject_lpsolve.mk
index 21843f713c58..2bd5cdacbe2a 100644
--- a/external/lpsolve/ExternalProject_lpsolve.mk
+++ b/external/lpsolve/ExternalProject_lpsolve.mk
@@ -26,6 +26,7 @@ $(call gb_ExternalProject_get_state_target,lpsolve,build):
        $(call gb_Trace_StartRange,lpsolve,EXTERNAL)
        $(call gb_ExternalProject_run,build,\
                CC="$(CC) $(call gb_ExternalProject_get_build_flags,lpsolve)" \
+               SYSTEM_COLAMD=$(SYSTEM_COLAMD) \
                $(if $(filter MACOSX,$(OS)),EXTRA_LINKFLAGS='-install_name 
@__________________________________________________OOO/liblpsolve55.dylib') \
                sh -e $(if $(filter MACOSX,$(OS)),ccc.osx, \
                $(if $(filter TRUE,$(DISABLE_DYNLOADING)),ccc.static, \
diff --git a/external/lpsolve/UnpackedTarball_lpsolve.mk 
b/external/lpsolve/UnpackedTarball_lpsolve.mk
index 2e289861cede..167c14862587 100644
--- a/external/lpsolve/UnpackedTarball_lpsolve.mk
+++ b/external/lpsolve/UnpackedTarball_lpsolve.mk
@@ -33,6 +33,7 @@ else
 $(eval $(call gb_UnpackedTarball_add_patches,lpsolve,\
        external/lpsolve/lp_solve_5.5.patch \
        external/lpsolve/lpsolve-ubsan.patch.0 \
+       external/lpsolve/system-colamd.diff \
 ))
 
 $(eval $(call 
gb_UnpackedTarball_add_file,lpsolve,lpsolve55/ccc.static,external/lpsolve/ccc.static))
diff --git a/external/lpsolve/ccc.static b/external/lpsolve/ccc.static
index 6911c4b2c892..c8f070921202 100644
--- a/external/lpsolve/ccc.static
+++ b/external/lpsolve/ccc.static
@@ -1,11 +1,20 @@
-src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c 
../ini.c ../fortify.c ../colamd/colamd.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'
+if [ "$SYSTEM_COLAMD" != "TRUE" ]; then
+    colamd_c=../colamd/colamd.c
+fi
+src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c 
../ini.c ../fortify.c $colamd_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'
 obj=`echo $src|sed -e 's/\.c/.o/g' -e 's!\([^ ]*/\)*!!g'`
 
 opts='-O3'
 
 def=
 
-$CC -I.. -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd 
-I../shared $opts $def -DYY_NEVER_INTERACTIVE -DPARSER_LP 
-DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine -c $src
+# FIMXE: Link statically with colamd?
+if test "$SYSTEM_COLAMD" = "TRUE"; then
+       colamd_i=$COLAMD_CFLAGS
+else
+       colamd_i=-I../colamd
+fi
+$CC -I.. -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL $colamd_i 
-I../shared $opts $def -DYY_NEVER_INTERACTIVE -DPARSER_LP 
-DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine -c $src
 
 $AR -r liblpsolve55.a $obj
 rm $obj
diff --git a/external/lpsolve/system-colamd.diff 
b/external/lpsolve/system-colamd.diff
new file mode 100644
index 000000000000..80eba695f379
--- /dev/null
+++ b/external/lpsolve/system-colamd.diff
@@ -0,0 +1,39 @@
+diff -urN lp_solve_5.5-old/lpsolve55/ccc lp_solve_5.5/lpsolve55/ccc
+--- misc/build/lp_solve_5.5/lpsolve55/ccc      2005-06-11 21:27:18.000000000 
+0200
++++ misc/build/lp_solve_5.5/lpsolve55/ccc      2025-03-02 17:58:19.904235635 
+0100
+@@ -1,4 +1,7 @@
+-src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c 
../ini.c ../fortify.c ../colamd/colamd.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'
++if test "$SYSTEM_COLAMD" != "TRUE"; then
++     colamd_c=../colamd/colamd.c
++fi
++src="../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c 
../ini.c ../fortify.c $colamd_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"
+ ar=$AR
+ c=$CC
+ ranlib=$RANLIB
+@@ -25,17 +28,24 @@
+ 
+ if [ "$OS" = "LINUX" ]; then
+      libs="$libs -ldl"
++     libs="$libs $COLAMD_LIBS"
+ fi
+ 
+ opts='-O3'
+ 
+-$c -s $inline -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL 
-I../bfp/bfp_LUSOL/LUSOL -I../colamd $opts $def -DYY_NEVER_INTERACTIVE 
-DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
++if test "$SYSTEM_COLAMD" = "TRUE"; then
++      colamd_i=$COLAMD_CFLAGS
++else
++      colamd_i=-I../colamd
++fi
++
++$c -s $inline -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL 
-I../bfp/bfp_LUSOL/LUSOL $colamd_i $opts $def -DYY_NEVER_INTERACTIVE 
-DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
+ $ar rv liblpsolve55.$a `echo $src|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'`
+ $ranlib liblpsolve55.$a
+ 
+ if [ "$so" != "" ]
+ then
+-  $c $pic -s $inline -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL 
-I../bfp/bfp_LUSOL/LUSOL -I../colamd -I. $opts -DYY_NEVER_INTERACTIVE 
-DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
++  $c $pic -s $inline -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL 
-I../bfp/bfp_LUSOL/LUSOL $colamd_i -I. $opts -DYY_NEVER_INTERACTIVE -DPARSER_LP 
-DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src
+   $c -shared $ldflags -o ${soprefix}lpsolve55.$so `echo $src|sed 
s/[.]c/.o/g|sed 's/[^ ]*\///g'` $libs
+ fi
+ 

Reply via email to