From 4ee74c01e3aa781f983557d3956628e3576ca17a Mon Sep 17 00:00:00 2001
From: Ricardo Jesus <rj.bcjesus@gmail.com>
Date: Tue, 5 Oct 2021 10:55:12 +0100
Subject: meme: Fix compilation with `arm` and `nvhpc` compilers (#24883)

* Fix compilation with `arm` and `nvhpc` compilers

* Update package.py
---
 var/spack/repos/builtin/packages/meme/arm.patch  | 36 ++++++++++++++++++++++++
 var/spack/repos/builtin/packages/meme/package.py | 13 +++++++--
 2 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/meme/arm.patch

(limited to 'var')

diff --git a/var/spack/repos/builtin/packages/meme/arm.patch b/var/spack/repos/builtin/packages/meme/arm.patch
new file mode 100644
index 0000000000..4bcb0c51ca
--- /dev/null
+++ b/var/spack/repos/builtin/packages/meme/arm.patch
@@ -0,0 +1,36 @@
+--- a/src/mtwist.h	2021-07-14 12:18:25.848290454 +0000
++++ b/src/mtwist.h	2021-07-14 12:37:35.581368981 +0000
+@@ -285,6 +285,7 @@
+   prototypes using the ifdef.
+ */
+ #ifndef __APPLE__
++#ifndef __ARM_LINUX_COMPILER__
+ extern uint32_t		mts_lrand(mt_state* state);
+ 					/* Generate 32-bit value, any gen. */
+ #ifdef UINT64_MAX
+@@ -310,6 +311,7 @@
+ 					/* Generate floating value */
+ 					/* Slower, with 64-bit precision */
+ #endif
++#endif
+ 
+ /*
+  * Tempering parameters.  These are perhaps the most magic of all the magic
+@@ -381,10 +383,14 @@
+ #ifdef __cplusplus
+ #define MT_EXTERN			/* C++ doesn't need static */
+ #else /* __cplusplus */
+-#ifndef __APPLE__
+-#define MT_EXTERN	extern		/* C (at least gcc) needs extern */
+-#else
++#ifdef __APPLE__
+ #define MT_EXTERN	static 		/* The apple compiler freaks out if the definitions are not static */
++#else /* __APPLE__ */
++#ifdef __ARM_LINUX_COMPILER__
++#define MT_EXTERN	static 		/* The Arm compiler complains if the definitions are not static */
++#else /* __ARM_LINUX_COMPILER__ */
++#define MT_EXTERN	extern		/* C (at least gcc) needs extern */
++#endif /* __ARM_LINUX_COMPILER__ */
+ #endif /* __APPLE__ */
+ #endif /* __cplusplus */
+ #endif /* MT_EXTERN */
diff --git a/var/spack/repos/builtin/packages/meme/package.py b/var/spack/repos/builtin/packages/meme/package.py
index bf6b463e52..b26e926464 100644
--- a/var/spack/repos/builtin/packages/meme/package.py
+++ b/var/spack/repos/builtin/packages/meme/package.py
@@ -31,6 +31,10 @@ class Meme(AutotoolsPackage):
     depends_on('mpi', when='+mpi')
     depends_on('imagemagick', type=('build', 'run'), when='+image-magick')
     depends_on('perl-xml-parser', type=('build', 'run'))
+    depends_on('libxml2', type=('build', 'run'))
+    depends_on('libxslt', type=('build', 'run'))
+
+    patch('arm.patch', when='%arm')
 
     def url_for_version(self, version):
         url = 'http://meme-suite.org/meme-software/{0}/meme{1}{2}.tar.gz'
@@ -39,8 +43,13 @@ class Meme(AutotoolsPackage):
 
     def configure_args(self):
         spec = self.spec
-        # have meme build its own versions of libxml2/libxslt, see #6736
-        args = ['--enable-build-libxml2', '--enable-build-libxslt']
+        args = []
         if '~mpi' in spec:
             args += ['--enable-serial']
         return args
+
+    def patch(self):
+        # Remove flags not recognized by the NVIDIA compiler
+        if self.spec.satisfies('%nvhpc'):
+            filter_file('-fno-common', '', 'configure')
+            filter_file('-Wno-unused', '', 'configure')
-- 
cgit v1.2.3-70-g09d2