commit:     dad58a7d48705b0fca67da25cbe8636e960800fa
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 29 00:00:16 2022 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Sat Jan 29 00:00:16 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dad58a7d

sci-mathematics/msieve: fix build system

Closes: https://bugs.gentoo.org/725592
Closes: https://bugs.gentoo.org/779589
Signed-off-by: David Seifert <soap <AT> gentoo.org>

 .../msieve/files/msieve-1.51-reduce-printf.patch   |  15 ++-
 .../msieve/files/msieve-1.53-fix-version.patch     |   4 -
 .../msieve/files/msieve-1.53-makefile.patch        | 108 +++++++++++++++++++++
 sci-mathematics/msieve/msieve-1.53-r1.ebuild       |  30 +++---
 4 files changed, 128 insertions(+), 29 deletions(-)

diff --git a/sci-mathematics/msieve/files/msieve-1.51-reduce-printf.patch 
b/sci-mathematics/msieve/files/msieve-1.51-reduce-printf.patch
index 39892716716a..e3483b8d15bb 100644
--- a/sci-mathematics/msieve/files/msieve-1.51-reduce-printf.patch
+++ b/sci-mathematics/msieve/files/msieve-1.51-reduce-printf.patch
@@ -1,6 +1,5 @@
-diff -Naur msieve-1.50/common/minimize.c msieve-copy/common/minimize.c
---- msieve-1.50/common/minimize.c      2011-07-04 23:32:33.000000000 +0800
-+++ msieve-copy/common/minimize.c      2012-11-26 23:09:22.889240528 +0800
+--- a/common/minimize.c
++++ b/common/minimize.c
 @@ -210,7 +210,7 @@
                }
        }
@@ -10,9 +9,8 @@ diff -Naur msieve-1.50/common/minimize.c 
msieve-copy/common/minimize.c
        *min_out = x;
        *status = 1;
        return fx;
-diff -Naur msieve-1.50/gnfs/poly/stage2/optimize.c 
msieve-copy/gnfs/poly/stage2/optimize.c
---- msieve-1.50/gnfs/poly/stage2/optimize.c    2011-10-15 23:03:39.000000000 
+0800
-+++ msieve-copy/gnfs/poly/stage2/optimize.c    2012-11-26 23:14:36.243232414 
+0800
+--- a/gnfs/poly/stage2/optimize.c
++++ b/gnfs/poly/stage2/optimize.c
 @@ -430,9 +430,9 @@
  #if 0
        printf("norm %.7e skew %lf\n", *pol_norm, best[SKEWNESS]);
@@ -25,9 +23,8 @@ diff -Naur msieve-1.50/gnfs/poly/stage2/optimize.c 
msieve-copy/gnfs/poly/stage2/
  #endif
  }
  
-diff -Naur msieve-1.50/gnfs/poly/stage2/stage2.c 
msieve-copy/gnfs/poly/stage2/stage2.c
---- msieve-1.50/gnfs/poly/stage2/stage2.c      2011-10-09 09:32:49.000000000 
+0800
-+++ msieve-copy/gnfs/poly/stage2/stage2.c      2012-11-26 23:14:30.894232552 
+0800
+--- a/gnfs/poly/stage2/stage2.c
++++ b/gnfs/poly/stage2/stage2.c
 @@ -122,10 +122,10 @@
        }
  

diff --git a/sci-mathematics/msieve/files/msieve-1.53-fix-version.patch 
b/sci-mathematics/msieve/files/msieve-1.53-fix-version.patch
index eb9a8d7ac2d0..c3ec73ac5987 100644
--- a/sci-mathematics/msieve/files/msieve-1.53-fix-version.patch
+++ b/sci-mathematics/msieve/files/msieve-1.53-fix-version.patch
@@ -1,5 +1,3 @@
-diff --git a/common/driver.c b/common/driver.c
-index ffecfa9..3e1da78 100644
 --- a/common/driver.c
 +++ b/common/driver.c
 @@ -189,10 +189,9 @@ void msieve_run(msieve_obj *obj) {
@@ -15,8 +13,6 @@ index ffecfa9..3e1da78 100644
        start_time = time(NULL);
        if (obj->flags & MSIEVE_FLAG_LOG_TO_STDOUT) {
                printf("%s", ctime(&start_time));
-diff --git a/demo.c b/demo.c
-index a882732..ec3e869 100644
 --- a/demo.c
 +++ b/demo.c
 @@ -81,9 +81,8 @@ void get_random_seeds(uint32 *seed1, uint32 *seed2) {

diff --git a/sci-mathematics/msieve/files/msieve-1.53-makefile.patch 
b/sci-mathematics/msieve/files/msieve-1.53-makefile.patch
new file mode 100644
index 000000000000..2676cefff18b
--- /dev/null
+++ b/sci-mathematics/msieve/files/msieve-1.53-makefile.patch
@@ -0,0 +1,108 @@
+--- a/Makefile
++++ b/Makefile
+@@ -18,10 +18,8 @@
+ 
+ # gcc with basic optimization (-march flag could
+ # get overridden by architecture-specific builds)
+-CC = gcc
+-WARN_FLAGS = -Wall -W
+-OPT_FLAGS = -O3 -fomit-frame-pointer -march=native \
+-          -D_FILE_OFFSET_BITS=64 -DNDEBUG -D_LARGEFILE64_SOURCE
++CFLAGS += -Wall -W
++CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
+ 
+ # use := instead of = so we only run the following once
+ SVN_VERSION := $(shell svnversion .)
+@@ -29,15 +27,14 @@
+       SVN_VERSION := unknown
+ endif
+ 
+-CFLAGS = $(OPT_FLAGS) $(MACHINE_FLAGS) $(WARN_FLAGS) \
+-              -DMSIEVE_SVN_VERSION="\"$(SVN_VERSION)\"" \
+-              -I. -Iaprcl -Iinclude -Ignfs -Ignfs/poly -Ignfs/poly/stage1
++CPPFLAGS += -DMSIEVE_SVN_VERSION="\"$(SVN_VERSION)\"" \
++      -I. -Iaprcl -Iinclude -Ignfs -Ignfs/poly -Ignfs/poly/stage1
+ 
+ # tweak the compile flags
+ 
+ ifeq ($(ECM),1)
+-      CFLAGS += -DHAVE_GMP_ECM
+-      LIBS += -lecm
++      CPPFLAGS += -DHAVE_GMP_ECM
++      LIBS += -lecm -lgomp
+ endif
+ ifeq ($(WIN),1)
+ 
+@@ -61,22 +58,21 @@
+       CUDA_ROOT = $(shell dirname $(NVCC))/../
+       CUDA_LIBS = -lcuda
+ endif
+-      CFLAGS += -I"$(CUDA_ROOT)/include" -Icub -DHAVE_CUDA
++      CPPFLAGS += -I"$(CUDA_ROOT)/include" -Icub -DHAVE_CUDA
+       LIBS += $(CUDA_LIBS)
+ endif
+ ifeq ($(MPI),1)
+-      CC = mpicc
+-      CFLAGS += -DHAVE_MPI
++      CPPFLAGS += -DHAVE_MPI
+ endif
+ ifeq ($(BOINC),1)
+       # fill in as appropriate
+       BOINC_INC_DIR = .
+       BOINC_LIB_DIR = .
+-      CFLAGS += -I$(BOINC_INC_DIR) -DHAVE_BOINC
++      CPPFLAGS += -I$(BOINC_INC_DIR) -DHAVE_BOINC
+       LIBS += -L$(BOINC_LIB_DIR) -lboinc_api -lboinc
+ endif
+ ifeq ($(NO_ZLIB),1)
+-      CFLAGS += -DNO_ZLIB
++      CPPFLAGS += -DNO_ZLIB
+ else
+       LIBS += -lz
+ endif
+@@ -272,9 +268,9 @@
+ 
+ all: $(COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS) $(GPU_OBJS)
+       rm -f libmsieve.a
+-      ar r libmsieve.a $(COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS)
+-      ranlib libmsieve.a
+-      $(CC) $(CFLAGS) demo.c -o msieve $(LDFLAGS) \
++      $(AR) r libmsieve.a $(COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS)
++      $(RANLIB) libmsieve.a
++      $(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) demo.c -o msieve \
+                       libmsieve.a $(LIBS)
+ 
+ clean:
+@@ -287,27 +283,27 @@
+ # common file build rules
+ 
+ %.o: %.c $(COMMON_HDR)
+-      $(CC) $(CFLAGS) -c -o $@ $<
++      $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+ 
+ # QS build rules
+ 
+ mpqs/sieve_core_generic_32k.qo: mpqs/sieve_core.c $(COMMON_HDR) $(QS_HDR)
+-      $(CC) $(CFLAGS) -DBLOCK_KB=32 -DHAS_SSE2 \
++      $(CC) $(CFLAGS) $(CPPFLAGS) -DBLOCK_KB=32 -DHAS_SSE2 \
+               -DROUTINE_NAME=qs_core_sieve_generic_32k \
+               -c -o $@ mpqs/sieve_core.c
+ 
+ mpqs/sieve_core_generic_64k.qo: mpqs/sieve_core.c $(COMMON_HDR) $(QS_HDR)
+-      $(CC) $(CFLAGS) -DBLOCK_KB=64 -DHAS_SSE2 \
++      $(CC) $(CFLAGS) $(CPPFLAGS) -DBLOCK_KB=64 -DHAS_SSE2 \
+               -DROUTINE_NAME=qs_core_sieve_generic_64k \
+               -c -o $@ mpqs/sieve_core.c
+ 
+ %.qo: %.c $(COMMON_HDR) $(QS_HDR)
+-      $(CC) $(CFLAGS) -c -o $@ $<
++      $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+ 
+ # NFS build rules
+ 
+ %.no: %.c $(COMMON_HDR) $(NFS_HDR)
+-      $(CC) $(CFLAGS) -Ignfs -c -o $@ $<
++      $(CC) $(CFLAGS) $(CPPFLAGS) -Ignfs -c -o $@ $<
+ 
+ # GPU build rules
+ 

diff --git a/sci-mathematics/msieve/msieve-1.53-r1.ebuild 
b/sci-mathematics/msieve/msieve-1.53-r1.ebuild
index 4cf9b2d6dce3..1f8a4593e738 100644
--- a/sci-mathematics/msieve/msieve-1.53-r1.ebuild
+++ b/sci-mathematics/msieve/msieve-1.53-r1.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
 inherit toolchain-funcs
 
@@ -24,26 +24,24 @@ PATCHES=(
        # TODO: Integrate ggnfs properly
        "${FILESDIR}"/${PN}-1.51-reduce-printf.patch
        "${FILESDIR}"/${PN}-1.53-fix-version.patch
+       "${FILESDIR}"/${PN}-1.53-makefile.patch
 )
 
-src_prepare() {
-       default
+src_configure() {
+       tc-export AR CC RANLIB
 
-       sed -i -e 's/-march=k8//' Makefile || die
-       sed -i -e 's/CC =/#CC =/' Makefile || die
-       sed -i -e 's/CFLAGS =/CFLAGS +=/' Makefile || die
-       sed -i -e 's/LIBS += -lecm/LIBS += -lecm -lgomp/' Makefile || die
+       use ecm && export ECM=1
+
+       if use mpi; then
+               export MPI=1
+               export CC=mpicc
+       fi
+
+       use zlib && export ZLIB=1
 }
 
 src_compile() {
-       use ecm && export ECM=1
-       use mpi && export MPI=1
-       use zlib && export ZLIB=1
-       emake \
-               CC=$(tc-getCC) \
-               AR=$(tc-getAR) \
-               OPT_FLAGS="${CFLAGS}" \
-               all
+       emake all
 }
 
 src_install() {

Reply via email to