From 600841913d5e6f5e977a2660578d480d4fbbe0b8 Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Mon, 16 Jan 2023 17:55:13 +0100
Subject: [PATCH] Pull out splfr settings into another common Makefile

---
 src/common.mk                | 3 +++
 src/helper_files/Makefile    | 4 ++--
 src/methods/method_common.mk | 7 +++++--
 3 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 src/common.mk

diff --git a/src/common.mk b/src/common.mk
new file mode 100644
index 0000000..15577fb
--- /dev/null
+++ b/src/common.mk
@@ -0,0 +1,3 @@
+splfr=/usr/local/sicstus4.7.1/bin/splfr
+
+common_splfr_flags := -larmadillo -fopenmp -lmlpack -lstdc++ -cxx --struct
diff --git a/src/helper_files/Makefile b/src/helper_files/Makefile
index 7a9da74..58e17fb 100644
--- a/src/helper_files/Makefile
+++ b/src/helper_files/Makefile
@@ -1,8 +1,8 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
+include ../common.mk
 
 METHOD_NAME=helper_tests
 
 $(METHOD_NAME).so: $(METHOD_NAME).pl $(METHOD_NAME).cpp
-	$(splfr) -larmadillo -fopenmp -lmlpack -lstdc++ -cxx --struct $(METHOD_NAME).pl $(METHOD_NAME).cpp helper.cpp
+	$(splfr) $(common_splfr_flags) $(CXXFLAGS) $(LDFLAGS) $(METHOD_NAME).pl $(METHOD_NAME).cpp helper.cpp $(LDLIBS)
 clean:
 	rm $(METHOD_NAME).so
diff --git a/src/methods/method_common.mk b/src/methods/method_common.mk
index 726a9ed..66d3d85 100644
--- a/src/methods/method_common.mk
+++ b/src/methods/method_common.mk
@@ -1,8 +1,11 @@
 # The including Makefile must set METHOD_NAME
 
-splfr=/usr/local/sicstus4.7.1/bin/splfr
+# An extra .. is needed here,
+# because the path is interpreted relative to the *including* Makefile(s),
+# which is one directory below this one.
+include ../../common.mk
 
 $(METHOD_NAME).so: $(METHOD_NAME).pl $(METHOD_NAME).cpp
-	$(splfr) -larmadillo -fopenmp -lmlpack -lstdc++ -cxx --struct $(METHOD_NAME).pl $(METHOD_NAME).cpp ../../helper_files/helper.cpp
+	$(splfr) $(common_splfr_flags) $(METHOD_NAME).pl $(METHOD_NAME).cpp ../../helper_files/helper.cpp
 clean:
 	rm $(METHOD_NAME).so
-- 
GitLab