Link lp_solve tool dynamically

f41
Petr Písař 2 years ago
parent 8fe9078873
commit 1d95d3868b

@ -0,0 +1,46 @@
From 11c6cd491bd192e0e3fef9fd2652297797e0fef1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
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ř <ppisar@redhat.com>
---
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

@ -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 # Port to C99, GCC 14 will remove support for previous standards, proposed to
# an upstream <https://groups.google.com/g/lp_solve/c/WjVf0dxrwfQ/m/rKMwf57tAwAJ>. # an upstream <https://groups.google.com/g/lp_solve/c/WjVf0dxrwfQ/m/rKMwf57tAwAJ>.
Patch1: lp_solve-5.5.2.11-Port-to-C99.patch 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 BuildRequires: bash
# binutils for ar and ranlib # binutils for ar and ranlib
BuildRequires: binutils BuildRequires: binutils
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: gcc BuildRequires: gcc
BuildRequires: sed BuildRequires: sed
# Tests:
BuildRequires: grep
%description %description
Mixed Integer Linear Programming (MILP) solver lpsolve solves pure linear, Mixed Integer Linear Programming (MILP) solver lpsolve solves pure linear,
@ -87,8 +91,13 @@ install -p -m 644 \
lp*.h %{buildroot}%{_includedir}/lpsolve lp*.h %{buildroot}%{_includedir}/lpsolve
%check %check
%set_build_flags
LP_PATH="$(echo lpsolve55/bin/ux*)" 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 ${CC} ${CFLAGS} -I. demo/demo.c ${LDFLAGS} -L"$LP_PATH" -llpsolve55
LD_LIBRARY_PATH="$LP_PATH" ./a.out </dev/null LD_LIBRARY_PATH="$LP_PATH" ./a.out </dev/null
@ -105,6 +114,7 @@ LD_LIBRARY_PATH="$LP_PATH" ./a.out </dev/null
%changelog %changelog
* Wed Jun 07 2023 Petr Pisar <ppisar@redhat.com> - 5.5.2.11-1 * Wed Jun 07 2023 Petr Pisar <ppisar@redhat.com> - 5.5.2.11-1
- 5.5.2.11 bump - 5.5.2.11 bump
- Link lp_solve tool dynamically
* Wed Jun 07 2023 Petr Pisar <ppisar@redhat.com> - 5.5.2.0-33 * Wed Jun 07 2023 Petr Pisar <ppisar@redhat.com> - 5.5.2.0-33
- Modernize a spec file - Modernize a spec file

Loading…
Cancel
Save