From 1d95d3868bbf1517ad2523c19fee190cc1194996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Thu, 8 Jun 2023 17:34:47 +0200 Subject: [PATCH] Link lp_solve tool dynamically --- ...2.11-Link-a-tool-to-a-shared-library.patch | 46 +++++++++++++++++++ lpsolve.spec | 12 ++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch diff --git a/lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch b/lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch new file mode 100644 index 0000000..f3821b8 --- /dev/null +++ b/lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch @@ -0,0 +1,46 @@ +From 11c6cd491bd192e0e3fef9fd2652297797e0fef1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 8 Jun 2023 16:11:00 +0200 +Subject: [PATCH] Link a tool to a shared library +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Build first lpsolve55 (the library), then lp_solve (the tool). It will +save time and space. + +Signed-off-by: Petr Písař +--- + lp_solve/ccc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/lp_solve/ccc b/lp_solve/ccc +index f86be81..d3aaba8 100644 +--- a/lp_solve/ccc ++++ b/lp_solve/ccc +@@ -1,5 +1,5 @@ + : +-src='../lp_MDO.c ../shared/commonlib.c ../colamd/colamd.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_solve.c ../lp_SOS.c ../lp_utils.c ../yacc_read.c' ++src='../lp_MDO.c ../shared/commonlib.c ../colamd/colamd.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:-cc} + CFLAGS=${CFLAGS:--O3} + +@@ -34,11 +34,14 @@ rm "$MYTMP"/isnan.c "$MYTMP"/isnan >/dev/null 2>&1 + rmdir "$MYTMP" + + def= ++LIBS= + if [ "$PLATFORM" = "SCO_UNIX" ] + then CFLAGS="${CFLAGS} -O0" + def='-dy -K PIC -DLLONG=long' + dl=-ldl + else dl=-ldl ++ LIBS="-L../lpsolve55/bin/$PLATFORM -llpsolve55" ++ src='' + fi + +-$c $CFLAGS -I.. -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -I../shared $def $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src $LDFLAGS -o bin/$PLATFORM/lp_solve $math $dl ++$c $CFLAGS -I.. -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -I../shared $def $NOISNAN -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine $src lp_solve.c $LDFLAGS -o bin/$PLATFORM/lp_solve $math $dl $LIBS +-- +2.40.1 + diff --git a/lpsolve.spec b/lpsolve.spec index 8e8abae..798dc9e 100644 --- a/lpsolve.spec +++ b/lpsolve.spec @@ -42,12 +42,16 @@ Patch0: lp_solve-5.5.2.11-Respect-CC-CFLAGS-and-LDFLAGS.patch # Port to C99, GCC 14 will remove support for previous standards, proposed to # an upstream . Patch1: lp_solve-5.5.2.11-Port-to-C99.patch +# Do not duplicate library code in the the tool +Patch2: lp_solve-5.5.2.11-Link-a-tool-to-a-shared-library.patch BuildRequires: bash # binutils for ar and ranlib BuildRequires: binutils BuildRequires: coreutils BuildRequires: gcc BuildRequires: sed +# Tests: +BuildRequires: grep %description Mixed Integer Linear Programming (MILP) solver lpsolve solves pure linear, @@ -87,8 +91,13 @@ install -p -m 644 \ lp*.h %{buildroot}%{_includedir}/lpsolve %check -%set_build_flags LP_PATH="$(echo lpsolve55/bin/ux*)" +# Verify lp_solve tool works +echo 'max: x; x < 42;' | \ + LD_LIBRARY_PATH="$LP_PATH" ./lp_solve/bin/ux*/lp_solve -S1 | \ + grep -e ': 42\.0*$' +# Verify a demo code is buildable +%set_build_flags ${CC} ${CFLAGS} -I. demo/demo.c ${LDFLAGS} -L"$LP_PATH" -llpsolve55 LD_LIBRARY_PATH="$LP_PATH" ./a.out - 5.5.2.11-1 - 5.5.2.11 bump +- Link lp_solve tool dynamically * Wed Jun 07 2023 Petr Pisar - 5.5.2.0-33 - Modernize a spec file