summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3c147265ddb826f7e963fb9ce98c1ec4a2eed5c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Maintainer Simone Cimarelli a.k.a. AquilaIrreale <aquilairreale@ymail.com>
# Contributor Jérémie Detrey
# Contributor Christian Cornelssen
# Contributor gilcu3

_pkg=cado-nfs
pkgname=${_pkg}-git
pkgver=20240318.a24829267
pkgrel=1
pkgdesc="Implementation of the Number Field Sieve (NFS) algorithm for factoring integers"
arch=('x86_64')
url="http://cado-nfs.gforge.inria.fr/"
license=('LGPL2')
# We configure with optional curl, hwloc, gmp-ecm.
# Configuring with hwloc makes binaries in linalg/bwc depend on it.
depends=('gmp' 'python' 'sqlite' 'hwloc')
makedepends=('git' 'cmake' 'inetutils' 'curl' 'gmp-ecm')
optdepends=('curl: for cado-nfs-client.py'
            'gmp-ecm: for JL DLP polynomial selection'
            'perl: for bwc.pl')
conflicts=('cado-nfs')
provides=('cado-nfs')
source=("git+https://gitlab.inria.fr/cado-nfs/${_pkg}.git"
        fmt.patch)
sha384sums=('SKIP'
            '493abdd5b33bb202eb6f159bd399cf947f6c8a082fc23ba4fcf79dadcc07fbc8ef5989b0a5580cdb7537346af713d374')

# Need -march for SIMD support. Makes the resulting package less portable.
_march=native

_update_march()
{
  local flags_no_march=''

  for f in $1; do
    if ! [[ "$f" =~ -march=.* ]]; then
      flags_no_march+=" $f"
    fi
  done

  echo "${flags_no_march} -march=$_march"
}

pkgver() {
  cd "$_pkg"
  git log -1 --format="%cd.%h" --date=short | sed 's/-//g'
}

prepare() {
  patch -d "$_pkg" -p1 < fmt.patch

  cat <<EOF >"$_pkg/local.sh"
PREFIX=/usr
HWLOC="\$PREFIX"
GMPECM="\$PREFIX"
CURL="\$PREFIX"
# Remove 32-bit barriers to big factorizations
FLAGS_SIZE="-DSIZEOF_P_R_VALUES=8 -DSIZEOF_INDEX=8"
EOF
}

build() {
  cd "$_pkg"

  CFLAGS="$(_update_march "$CFLAGS") -Wno-stringop-overflow -ffile-prefix-map=${srcdir}=."
  CPPFLAGS="$(_update_march "$CPPFLAGS") -Wno-stringop-overflow -ffile-prefix-map=${srcdir}=."
  CXXFLAGS="$(_update_march "$CXXFLAGS") -Wno-stringop-overflow -ffile-prefix-map=${srcdir}=."

  make cmake
  local escaped="$(sed 's|[.*^$\\\|[]|\\&|g;s/\n/\\n/g' <<< "$srcdir")"
  find build -type f -iname '*.h' -print0 | xargs -0 sed -zi "s|$escaped|$_pkg|g"

  make
}

package() {
  cd "$_pkg"
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
}

# vim:set ts=2 sw=2 et: