diff --git a/src/methods/adaboost/Makefile b/src/methods/adaboost/Makefile
index 8eda7ceddec61d86b6d509c1e52bc2ffd1b99d18..ffc46ec319d26db353a9a0725548554d2669e37e 100644
--- a/src/methods/adaboost/Makefile
+++ b/src/methods/adaboost/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=adaboost
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/approx_kfn/Makefile b/src/methods/approx_kfn/Makefile
index b1685a9d5ec50f8208584a9078e661e91714a527..59f360d1702472f40c824f902417491a1db3f3f3 100644
--- a/src/methods/approx_kfn/Makefile
+++ b/src/methods/approx_kfn/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=approx_kfn
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/bayesian_linear_regression/Makefile b/src/methods/bayesian_linear_regression/Makefile
index ac7294e45cb48df8fc1ea3d9a6840ce4b24aa35d..dcc5a20cb9bfdad74ead44965d69371b93706b0c 100644
--- a/src/methods/bayesian_linear_regression/Makefile
+++ b/src/methods/bayesian_linear_regression/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=bayesian_linear_regression
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
\ No newline at end of file
+include ../method_common.mk
diff --git a/src/methods/dbscan/Makefile b/src/methods/dbscan/Makefile
index f77df52ce59cfb47a839240b26797edd702f1aa5..643b17df20255b694672ab1be2c7dc487117552d 100644
--- a/src/methods/dbscan/Makefile
+++ b/src/methods/dbscan/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=dbscan
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/decision_tree/Makefile b/src/methods/decision_tree/Makefile
index 7a9b569e9df415ed8a5a4b523206fe6250234791..2a88f2e4a23d11988631cce8e245b99283ca7402 100644
--- a/src/methods/decision_tree/Makefile
+++ b/src/methods/decision_tree/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=decision_tree
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/emst/Makefile b/src/methods/emst/Makefile
index 8dc7eeb79a3e2e2311e023be2f19a742a43acfee..61686240d655f782fe59799049ace716cff11b00 100644
--- a/src/methods/emst/Makefile
+++ b/src/methods/emst/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=emst
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/fastmks/Makefile b/src/methods/fastmks/Makefile
index 52955632a41d9e1a1f75e4ae1f609c98096fa828..58954ec10ce2fd9ad80d21dffff97413833c474d 100644
--- a/src/methods/fastmks/Makefile
+++ b/src/methods/fastmks/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=fastmks
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/hoeffding_tree/Makefile b/src/methods/hoeffding_tree/Makefile
index d37037f2a5a4ee04877200e510d6c3ec6bac6504..05ce3b2e79ca11f469ee509faec7d5dd720a1476 100644
--- a/src/methods/hoeffding_tree/Makefile
+++ b/src/methods/hoeffding_tree/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=hoeffding_tree
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/kde/Makefile b/src/methods/kde/Makefile
index 5af26c9f050efca09c437fcc584c0ac824d57355..b524c7b664ed0f32ee60d92f0649c1071da0ea63 100644
--- a/src/methods/kde/Makefile
+++ b/src/methods/kde/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=kde
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/kernel_pca/Makefile b/src/methods/kernel_pca/Makefile
index 76bab9734a8c694cee152b5f8fc902b41259c6e7..998f887912c7ad0fc21efe2ed83edc23f073ebc1 100644
--- a/src/methods/kernel_pca/Makefile
+++ b/src/methods/kernel_pca/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=kernel_pca
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/kfn/Makefile b/src/methods/kfn/Makefile
index ab06e3e4ccea2deb93e4ea2fbb3f285bdd5acd24..689985a67a73d7fb6a9edc8b0b3041e6d1e800d7 100644
--- a/src/methods/kfn/Makefile
+++ b/src/methods/kfn/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=kfn
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/kmeans/Makefile b/src/methods/kmeans/Makefile
index ddaebe122390f9974a5e65d080dcee33075b21d4..dc05cdd3aaa51ac8743125c140398428ef53e6e0 100644
--- a/src/methods/kmeans/Makefile
+++ b/src/methods/kmeans/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=kmeans
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/knn/Makefile b/src/methods/knn/Makefile
index 6dceec3d2f3723b3ea1237ed7e9adae1db2f7196..9778bdae406006a3f85270209842cb05f93de4e1 100644
--- a/src/methods/knn/Makefile
+++ b/src/methods/knn/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=knn
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/lars/Makefile b/src/methods/lars/Makefile
index 653dfb4247049e8feab4194d9053f4801f9c318d..8019c7680f9aa5c5d10cdc6d1f65f9ca0c77f049 100644
--- a/src/methods/lars/Makefile
+++ b/src/methods/lars/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=lars
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/linear_SVM/Makefile b/src/methods/linear_SVM/Makefile
index 97760dadbb6f8e5fed557d7fcfc470cb5d6e6a8c..7460dda897a706d7a73fde7c0ae1d4bf99ce1a73 100644
--- a/src/methods/linear_SVM/Makefile
+++ b/src/methods/linear_SVM/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=linear_SVM
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/linear_regression/Makefile b/src/methods/linear_regression/Makefile
index 71995e2b8072030ef4ff73a021a744823e14eb52..c401592235ed2319a25b543eea1355be0b08d2a5 100644
--- a/src/methods/linear_regression/Makefile
+++ b/src/methods/linear_regression/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=linear_regression
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/lmnn/Makefile b/src/methods/lmnn/Makefile
index 7e808a537332f4ef85d2f6bd23acac8d5173465e..0d49048c7a1d3bdf5885535d633052c2b34645b6 100644
--- a/src/methods/lmnn/Makefile
+++ b/src/methods/lmnn/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=lmnn
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/local_coordinate_coding/Makefile b/src/methods/local_coordinate_coding/Makefile
index 772fcca4609af4f63f022cd91dda63470f60fdeb..02ffbdae9809a420e03cca3eb202912bafbecded 100644
--- a/src/methods/local_coordinate_coding/Makefile
+++ b/src/methods/local_coordinate_coding/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=local_coordinate_coding
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/logistic_regression/Makefile b/src/methods/logistic_regression/Makefile
index c22417f69bca892363901fdc3e05ec16ba4e72e7..df8c0366488fadd31718c6dbfcca98355ff87dd6 100644
--- a/src/methods/logistic_regression/Makefile
+++ b/src/methods/logistic_regression/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=logistic_regression
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/lsh/Makefile b/src/methods/lsh/Makefile
index b520001e90dac8db77d56c00721b1dc8f139c31a..c296a0dd6dfb94f9797bcbb07eea7279c96b1dfc 100644
--- a/src/methods/lsh/Makefile
+++ b/src/methods/lsh/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=lsh
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/mean_shift/Makefile b/src/methods/mean_shift/Makefile
index bcb68d02c90e51cb8f7095505e3b8df6be7daeda..94e7a5d3093669aed38fde986061488378f3ddcd 100644
--- a/src/methods/mean_shift/Makefile
+++ b/src/methods/mean_shift/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=mean_shift
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/method_common.mk b/src/methods/method_common.mk
new file mode 100644
index 0000000000000000000000000000000000000000..726a9ed05b362c9a8ca0bea6dd01653b686d31a6
--- /dev/null
+++ b/src/methods/method_common.mk
@@ -0,0 +1,8 @@
+# The including Makefile must set METHOD_NAME
+
+splfr=/usr/local/sicstus4.7.1/bin/splfr
+
+$(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
+clean:
+	rm $(METHOD_NAME).so
diff --git a/src/methods/naive_bayes_classifier/Makefile b/src/methods/naive_bayes_classifier/Makefile
index c5e644954d11bca2542de86569180a2e9e747114..1c268b2b352b3d5f0cc384c373b243263b164e11 100644
--- a/src/methods/naive_bayes_classifier/Makefile
+++ b/src/methods/naive_bayes_classifier/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=naive_bayes_classifier
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/nca/Makefile b/src/methods/nca/Makefile
index eac493d54de3e18ef133797caa24dfb16ae09ebe..bb5f05964ee949ec29e3c42fe877bbb6d325b511 100644
--- a/src/methods/nca/Makefile
+++ b/src/methods/nca/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=nca
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/nmf/Makefile b/src/methods/nmf/Makefile
index 387b1e095d43b830cd142d27f9d7fd7721d2aa02..6356489cec72079f29a72ebb04558f7ae9d63722 100644
--- a/src/methods/nmf/Makefile
+++ b/src/methods/nmf/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=nmf
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/pca/Makefile b/src/methods/pca/Makefile
index 7e86acf75a62f2164149773d2f9a19c8fb1dc914..11667b6f4a6edcc6538ceb36412952e04575ca1b 100644
--- a/src/methods/pca/Makefile
+++ b/src/methods/pca/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=pca
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/perceptron/Makefile b/src/methods/perceptron/Makefile
index 3911c137838368723f9035ef9300a5381d3b1d70..b71d203d60407afabb4decd2c2397b2350a227ba 100644
--- a/src/methods/perceptron/Makefile
+++ b/src/methods/perceptron/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=perceptron
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/radical/Makefile b/src/methods/radical/Makefile
index c78ed74fc6015199dc0d07b7a3080db39c4b3f92..87ad93cd72f073a1e62b8945bfd3c288629f26e3 100644
--- a/src/methods/radical/Makefile
+++ b/src/methods/radical/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=radical
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/random_forest/Makefile b/src/methods/random_forest/Makefile
index ebaf94f28a1597d1ff6372d43d9b8b18ce4b5047..a0ac13a9d9a6a2edfe58e761f9ef4105dc9fa924 100644
--- a/src/methods/random_forest/Makefile
+++ b/src/methods/random_forest/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=random_forest
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/softmax_regression/Makefile b/src/methods/softmax_regression/Makefile
index bd460779f5e0384b52f2902db4f9187be22874c0..5c3bc0a1380eaff62c39b6dc5c1c695e99044a16 100644
--- a/src/methods/softmax_regression/Makefile
+++ b/src/methods/softmax_regression/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=softmax_regression
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk
diff --git a/src/methods/sparse_coding/Makefile b/src/methods/sparse_coding/Makefile
index fa08d89490a69261ba2fac430eae1ec374996638..c263e914193d48ebb1d6d5595b25e326a4b8db9c 100644
--- a/src/methods/sparse_coding/Makefile
+++ b/src/methods/sparse_coding/Makefile
@@ -1,8 +1,2 @@
-splfr=/usr/local/sicstus4.7.1/bin/splfr
-
 METHOD_NAME=sparse_coding
-
-$(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
-clean:
-	rm $(METHOD_NAME).so
+include ../method_common.mk