From 2ad622c0e91d0092cfa369452435ef9a8a80db90 Mon Sep 17 00:00:00 2001
From: Giovanna Stefanelli <giovanna.stefanelli@student.uclouvain.be>
Date: Sun, 26 Apr 2020 16:46:03 +0200
Subject: [PATCH] Update Makefile

---
 Makefile   | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.c | 41 -----------------------------------------
 2 files changed, 49 insertions(+), 41 deletions(-)
 create mode 100644 Makefile
 delete mode 100644 Makefile.c

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..55a546e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+# Group: Q6 
+# Date: 24 April 2020
+# Course: LEPL1503 - PROJECT3
+# Object: factorial programme with Cunit test, Valgrind and cppcheck modules
+
+CC = gcc
+
+# The option -Werror convert warning into error 
+FLAGS = -Werror -pthread
+
+#TEST_FLAGS = -I${HOME}/local/include} -L${HOME}/local/lib -Wall -lcunit 
+
+fact: fact.c
+	$(CC) $(FLAGS) fact.c -o fact -lm
+	echo "fact.c file compiled"
+	# File provinding wrong numbers (negative, <2, 0), command:
+	#       ./fact incorrect_numbers.txt out.txt
+
+test: Fact_UnitTest.c
+	$(CC) -Wall -I${HOME}/local/include Fact_UnitTest.c -L${HOME}/local/lib  -o Fact_UnitTest -lcunit -lm
+	echo "Fact_UnitTest.c file compiled"
+
+clean: 
+	rm fact
+	# rm testing ouput files ####
+	# rm Fact_UnitTest
+	# rm out*.txt
+
+	## ADDITIONAL MAKE COMMANDS:
+	## make cunit, make valgrind, make cppcheck, make valgrind_cunit, make cppcheck_cunit
+
+cunit:
+	# Before the execution launch:
+	export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH
+	# The output of the unit test is stored in "Cunit_test_file.txt"
+	./Fact_UnitTest > Cunit_test_file.txt 2>&1
+	echo "Unit test launched see report in test_file.txt"
+
+valgrind:
+	valgrind ./fact  > valgrind_fact.txt 2>&1
+
+cppcheck:
+	cppcheck ./fact > cppcheck_fact.txt 2>&1
+
+valgrind_cunit:
+	valgrind ./Fact_UnitTest > valgrind_cunit.txt 2>&1
+
+cppcheck_cunit:
+	cppcheck ./Fact_UnitTest > cppcheck_cunit.txt 2>&1
diff --git a/Makefile.c b/Makefile.c
deleted file mode 100644
index 7a04f0c..0000000
--- a/Makefile.c
+++ /dev/null
@@ -1,41 +0,0 @@
-# Group: Q6 - gs
-# Date: 23 April 2020
-# Course: LEPL1503 - PROJECT3
-# Object: factorial
-
-CC = gcc
-
-# The option -Werror convert warning into error 
-FLAGS = -Werror -pthread
-
-#TEST_FLAGS = -I${HOME/local/include} -L${HOME/local/lib -Wall -lcunit 
-
-fact: fact.c
-	$(CC) $(FLAGS) fact.c -o fact -lm
-	echo Compiler task ended
-
-
-test: Fact_UnitTest.c
-	gcc -Wall -lcunit  -I${HOME}/local/include Fact_UnitTest.c -L${HOME}/local/lib  -o Fact_UnitTest -lm
-	echo "Test completed"
-
-
-clean: fact
-	rm fact
-	# rm testing ouput files ####
-	rm Fact_UnitTest
-	rm out*.txt
-	echo "Clean completed"
-
-
-valgrind:
-	valgrind ./fact
-
-valgrind_test:
-	valgrind ./Fact_UnitTest
-
-cppcheck:
-	cppcheck ./fact
-
-cppcheck_test:
-	cppcheck ./Fact_UnitTest
\ No newline at end of file
-- 
GitLab