From 1ea20ff7f5a87b2e01878ff5350376ed31eda6b6 Mon Sep 17 00:00:00 2001
From: "Kurt A. O'Hearn" <ohearnku@msu.edu>
Date: Tue, 11 Jul 2017 14:22:53 -0400
Subject: [PATCH] PG-PuReMD: update build system to include CUB. Other
 refactoring.

---
 Makefile.am            |  4 ++--
 PG-PuReMD/configure.ac | 16 +++++++---------
 configure.ac           |  1 -
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e46a9e3f..465748f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS =
 DIST_SUBDIRS =
+EXTRA_DIST = data environ tools
 
 if BUILD_S_OMP
 SUBDIRS += PuReMD-GPU
@@ -18,6 +19,7 @@ endif
 if BUILD_MPI_GPU
 SUBDIRS += PG-PuReMD
 DIST_SUBDIRS += PG-PuReMD
+EXTRA_DIST += PG-PuReMD/src/cub
 endif
 
 if BUILD_DOC
@@ -25,7 +27,5 @@ SUBDIRS += doc
 DIST_SUBDIRS += doc
 endif
 
-EXTRA_DIST = data environ tools
-
 dist-hook:
 	rm -rf `find $(distdir) -name .git`
diff --git a/PG-PuReMD/configure.ac b/PG-PuReMD/configure.ac
index 6fc8c567..d0136ecf 100644
--- a/PG-PuReMD/configure.ac
+++ b/PG-PuReMD/configure.ac
@@ -4,6 +4,8 @@
 AC_PREREQ([2.69])
 
 AC_INIT([PG-PuReMD], [1.0], [ohearnku@msu.edu hma@msu.edu])
+# Do not allow AC_PROG_CC to set CFLAGS (this line must be after AC_INIT but before AC_PROG_CC)
+sav_CFLAGS="$CFLAGS"
 : ${CFLAGS=""}
 AM_INIT_AUTOMAKE([1.15 subdir-objects -Wall -Werror foreign])
 # Enable silent build rules by default.
@@ -22,8 +24,9 @@ AC_DEFUN([CONFIGURE_HEADLINE],
 AC_LANG([C])
 
 # Checks for programs.
-AC_PROG_CC([icc gcc cc])
+AC_PROG_CC([icc gcc clang cc])
 AC_PROG_CPP
+CFLAGS="$sav_CFLAGS"
 
 AX_COMPILER_VENDOR
 
@@ -53,7 +56,7 @@ AC_CHECK_FUNCS([gettimeofday memset])
 
 # Check for MPI support.
 CONFIGURE_HEADLINE([ MPI compiler ])
-ACX_MPI([], [AC_MSG_ERROR([could not find mpi library])])
+ACX_MPI([], [AC_MSG_ERROR([could not find MPI library])])
 AC_CHECK_PROG(MPIRUN, mpirun, mpirun)
 AC_SUBST(MPIRUN)
 
@@ -69,9 +72,7 @@ AC_CHECK_DECL([MPICH2], [mpi_vendor="MPICH"],
 CC="$sav_CC"
 CFLAGS="$sav_CFLAGS"
 
-#
 # try to set MPI_CFLAGS and MPI_LIBS
-#
 MPI_CFLAGS=
 MPI_LIBS=
 if test "$mpi_vendor" = "OpenMPI"
@@ -116,7 +117,7 @@ AC_SUBST(MPI_LIBS)
 AC_LANG([C++])
 
 # Checks for programs.
-AC_PROG_CXX([icpc g++ c++])
+AC_PROG_CXX([icpc g++ clang++ c++])
 AC_PROG_CXXCPP
 
 AX_COMPILER_VENDOR
@@ -127,10 +128,7 @@ if test "x$BUILD_GPU" = "xyes"; then
 	AX_CUDA
 
         NVCCFLAGS=
-	if test "$ax_cv_cxx_compiler_vendor" = "intel"
-	then
-		NVCCFLAGS+=" -ccbin=icpc"
-	fi
+	NVCCFLAGS+=" -ccbin=$CXX"
 	if test "BUILD_DEBUG" = "true"
 	then
 		NVCCFLAGS+=" -g -G"
diff --git a/configure.ac b/configure.ac
index b9d5d0fc..787ab511 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,6 @@
 AC_PREREQ([2.69])
 
 AC_INIT([PuReMD], [1.0], [ohearnku@msu.edu hma@msu.edu])
-: ${CFLAGS=""}
 AM_INIT_AUTOMAKE([1.15 -Wall -Werror])
 # Enable silent build rules by default.
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],[1])])
-- 
GitLab