From 12553a2e4382b6d67a3609bb8d4267f6e87272bd Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 30 May 2018 14:45:12 +0200
Subject: [PATCH] COMP: include /usr/local in search for system
 headers/libraries

- this is consistent with compiler defaults, and helps Darwin users
---
 wmake/rules/General/CGAL    |  1 +
 wmake/scripts/have_boost    | 23 +++++++++++++++++------
 wmake/scripts/have_cgal     | 23 +++++++++++++++++------
 wmake/scripts/have_fftw     | 23 +++++++++++++++++------
 wmake/scripts/have_kahip    | 23 +++++++++++++++++------
 wmake/scripts/have_metis    | 23 +++++++++++++++++------
 wmake/scripts/have_mgridgen | 23 +++++++++++++++++------
 wmake/scripts/have_readline | 23 +++++++++++++++++------
 wmake/scripts/have_scotch   | 26 +++++++++++++++++++++-----
 wmake/scripts/have_zoltan   | 23 +++++++++++++++++------
 10 files changed, 158 insertions(+), 53 deletions(-)

diff --git a/wmake/rules/General/CGAL b/wmake/rules/General/CGAL
index f6c32e1bb6b..1606a2a8ebe 100644
--- a/wmake/rules/General/CGAL
+++ b/wmake/rules/General/CGAL
@@ -3,6 +3,7 @@ CGAL_INC = \
     -I$(MPFR_ARCH_PATH)/include \
     -I$(BOOST_ARCH_PATH)/include \
     -I$(CGAL_ARCH_PATH)/include \
+    -I/usr/local/include \
     -I/usr/include
 
 CGAL_LIBS = \
diff --git a/wmake/scripts/have_boost b/wmake/scripts/have_boost
index c1cd39dbc17..e78d8ab2280 100644
--- a/wmake/scripts/have_boost
+++ b/wmake/scripts/have_boost
@@ -82,12 +82,23 @@ have_boost()
         )
     elif isSystem "$BOOST_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_cgal b/wmake/scripts/have_cgal
index 9c14b0caec9..d641ccad251 100644
--- a/wmake/scripts/have_cgal
+++ b/wmake/scripts/have_cgal
@@ -82,12 +82,23 @@ have_cgal()
         )
     elif isSystem "$CGAL_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_fftw b/wmake/scripts/have_fftw
index d3e87c5daba..1a899b05042 100644
--- a/wmake/scripts/have_fftw
+++ b/wmake/scripts/have_fftw
@@ -82,12 +82,23 @@ have_fftw()
         )
     elif isSystem "$FFTW_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_kahip b/wmake/scripts/have_kahip
index 84e8cbde35c..3dcf7c952b7 100644
--- a/wmake/scripts/have_kahip
+++ b/wmake/scripts/have_kahip
@@ -90,12 +90,23 @@ have_kahip()
         )
     elif isSystem "$KAHIP_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_metis b/wmake/scripts/have_metis
index ec5b185c041..40752864183 100644
--- a/wmake/scripts/have_metis
+++ b/wmake/scripts/have_metis
@@ -91,12 +91,23 @@ have_metis()
         )
     elif isSystem "$METIS_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_mgridgen b/wmake/scripts/have_mgridgen
index 3c232c43fb5..d8900a56626 100644
--- a/wmake/scripts/have_mgridgen
+++ b/wmake/scripts/have_mgridgen
@@ -91,12 +91,23 @@ have_mgridgen()
         )
     elif isSystem "$MGRIDGEN_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_readline b/wmake/scripts/have_readline
index db85cdf0e83..9f9509e40f3 100644
--- a/wmake/scripts/have_readline
+++ b/wmake/scripts/have_readline
@@ -61,12 +61,23 @@ have_readline()
     library="libreadline$extLibso"
 
     # System only?
-    header=$(findFirstFile /usr/include/$header)
-
-    library=$(findFirstFile \
-        /usr/lib/$library \
-        /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-    )
+    header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+    case "$header" in
+    /usr/local/*)
+        library=$(findFirstFile \
+            /usr/local/lib/$library \
+            /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+        )
+        ;;
+
+    *)
+        library=$(findFirstFile \
+            /usr/lib/$library \
+            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+        )
+        ;;
+    esac
 
     # Header found?
     [ -n "$header" ] || {
diff --git a/wmake/scripts/have_scotch b/wmake/scripts/have_scotch
index bf613acf399..98c298c2215 100644
--- a/wmake/scripts/have_scotch
+++ b/wmake/scripts/have_scotch
@@ -91,12 +91,28 @@ have_scotch()
         )
     elif isSystem "$SCOTCH_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header /usr/include/scotch/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+        header=$(findFirstFile \
+            /usr/local/include/$header \
+            /usr/local/include/scotch/$header \
+            /usr/include/$header \
+            /usr/include/scotch/$header \
         )
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
diff --git a/wmake/scripts/have_zoltan b/wmake/scripts/have_zoltan
index bd02ac54a4e..40d7a7d26c8 100644
--- a/wmake/scripts/have_zoltan
+++ b/wmake/scripts/have_zoltan
@@ -90,12 +90,23 @@ have_zoltan()
         )
     elif isSystem "$ZOLTAN_ARCH_PATH"
     then
-        header=$(findFirstFile /usr/include/$header)
-
-        library=$(findFirstFile \
-            /usr/lib/$library \
-            /usr/lib$WM_COMPILER_LIB_ARCH/$library \
-        )
+        header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
+
+        case "$header" in
+        /usr/local/*)
+            library=$(findFirstFile \
+                /usr/local/lib/$library \
+                /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+
+        *)
+            library=$(findFirstFile \
+                /usr/lib/$library \
+                /usr/lib$WM_COMPILER_LIB_ARCH/$library \
+            )
+            ;;
+        esac
     else
         unset header library
     fi
-- 
GitLab