#Maintainer: Dylan Delgado pkgname=mlucas pkgver=19 pkgrel=1 pkgdesc="Program used to perform Lucas-Lehmer tests of Mersenne numbers. Can be built on the ARM architecture." arch=('i686' 'x86_64' 'arm' 'aarch64') url="https://www.mersenneforum.org/mayer/README.html" license=('FDL1.3') source=("https://www.mersenneforum.org/mayer/src/C/mlucas_v19.txz" 'fp-link.patch' 'sysctl-missing.patch') md5sums=('10906d3f1f4206ae93ebdb045f36535c' '04b7e30ea09677f239195f46c9f14966' '6959099d2b465f156c7d375b644d9dec') prepare() { cd "${srcdir}"/"${pkgname}"_v"${pkgver}" patch -R -p1 < "../../sysctl-missing.patch" patch -R -p1 < "../../fp-link.patch" } build() { cd "${srcdir}"/"${pkgname}"_v"${pkgver}"/src #Check the instructions on the computer and build based on that #use this for x86, x86_64 if [[ $CARCH == "i686" || $CARCH == "x86_64" ]] then if grep avx512 /proc/cpuinfo > /dev/null; then #avx512 (Intel i9, KNL) gcc -g -c -O3 -DUSE_AVX512 -DUSE_THREADS -march=native *.c > build.log elif grep avx2 /proc/cpuinfo > /dev/null; then #avx2 (most modern Intel processors (Haswell+), AMD Ryzen) gcc -g -c -O3 -DUSE_AVX2 -mavx2 -DUSE_THREADS *.c > build.log elif grep avx /proc/cpuinfo > /dev/null; then #avx (Intel Sandy/Ivy Bridge, AMD Heavy-Equipment) gcc -g -c -O3 -DUSE_AVX -mavx -DUSE_THREADS *.c > build.log elif grep sse2 /proc/cpuinfo > /dev/null; then #sse2 (Most machines from ~2003 on should have this!) gcc -g -c -O3 -DUSE_SSE2 -DUSE_THREADS *.c > build.log else #generic x86, x86_64 build gcc -g -c -O3 -DUSE_THREADS *.c > build.log fi fi #arm #only go to this if CARCH is arm or aarch64 if [[ $CARCH == "arm" || $CARCH == "aarch64" ]] then if grep asimd /proc/cpuinfo > /dev/null; then #newer arm chips gcc -g -c -O3 -DUSE_ARM_V8_SIMD -DUSE_THREADS *.c > build.log else #older arm chips gcc -g -c -O3 -DUSE_THREADS *.c > build.log fi fi #check the build log, to see if it empty, then link if ! grep error build.log > /dev/null; then gcc -g -o ../Mlucas *.o -lm -lpthread -lrt fi } package() { cd "${srcdir}"/"${pkgname}"_v"${pkgver}" install -Dm755 Mlucas "${pkgdir}"/usr/bin/mlucas }