diff --git a/src/common.mk b/src/common.mk
new file mode 100644
index 0000000000000000000000000000000000000000..15577fbd1004b66159d9f58b3448b46b01b80ab7
--- /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 7a9da742b09cc69b65e797eecbd7117be3bbb5d2..58e17fb3a26fdfbb2e623251a343edebb99df61b 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 726a9ed05b362c9a8ca0bea6dd01653b686d31a6..66d3d85e4c85d80c4411685087b7d51338679f6d 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