-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeMakefile
More file actions
88 lines (58 loc) · 1.96 KB
/
theMakefile
File metadata and controls
88 lines (58 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#make - to compile for normal run
#make test - to compile for unit testing
#make clean - to clean up
#put here the names of your files
PROGRAM_NAME =
UNIT_TEST_NAME =$(PROGRAM_NAME)_test_case
HEADER_FILE_NAME =
#for release add a file with a main function
#Targetfolder
BIN_DIR = bin
MK_DIR = mkdir
# variable to find the test environment
GTEST_DIR =${HOME}/Studium/WS18_fin/prg_c/ESP/googletest/googletest
#Compiler
CC = gcc
CPP = g++
#Flags for the compiler to create .o files
CCFLAGS = -Wall -c
CPPFLAGS =
# Flags for libs
LIBFLAGS=
#target is the result of the makefile.
# make alone will try to create the first target in the file
# Targets:
#make /make Programname
release: $(PROGRAM_NAME).o main.o
$(CC) $(PROGRAM_NAME).o -o $(BIN_DIR)/$(PROGRAM_NAME) $(LIBFLAGS)
#make test
test: Gtest_main.o libgtest.a $(UNIT_TEST_NAME).o $(PROGRAM_NAME)_test.o $(BIN_DIR)
$(CPP) $(LIBFLAGS) -I $(GTEST_DIR)/include -pthread $(UNIT_TEST_NAME).o Gtest_main.o libgtest.a $(PROGRAM_NAME).o -o $(BIN_DIR)/$(PROGRAM_NAME)_test
##Normal##
#still needs to be finished to compile a the file as an normal application
$(PROGRAM_NAME).o: $(PROGRAM_NAME).c
$(CC) $(CCFLAGS) $(PROGRAM_NAME).c
#only if the user wants to make a funtionable standalone program
main.o: main.c
$(CC) $(CCFLAGS) main.c
#### Unit Test ####
Gtest_main.o: Gtest_main.c
g++ -c -isystem $(GTEST_DIR)/include -I$(GTEST_DIR) Gtest_main.c
## Google Test Framework Lib##
libgtest.a:
g++ -isystem $(GTEST_DIR)/include -I$(GTEST_DIR) -pthread -c $(GTEST_DIR)/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
## own Unit test code
$(UNIT_TEST_NAME).o: $(UNIT_TEST_NAME).c $(HEADER_FILE_NAME).h
$(CPP) -c -isystem $(GTEST_DIR)/include -I$(GTEST_DIR) $(UNIT_TEST_NAME).c
## own Code to be tested ##
$(PROGRAM_NAME)_test.o: $(PROGRAM_NAME).c
$(CPP) $(CCFLAGS) $(PROGRAM_NAME).c
## folder for the compiled file ##
$(BIN_DIR):
$(MK_DIR) $(BIN_DIR)
#### Clean ####
.PHONY: clean
clean:
rm -f *.o
rm -rf $(BIN_DIR)