-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
161 lines (111 loc) · 4.19 KB
/
Makefile
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
CC=gcc-4.9
MPICC=mpicc
LDFLAGS?=-std=c99 -Wall -O3
LDLIBS=-lcrypto -ldl
CUNITLIB=-lcunit
OBJ=obj
BIN=bin
SRC=src
INCLUDE=include
TEST=test
SOURCES=$(SRC)/fs.c $(SRC)/keygen.c $(SRC)/encryptor.c $(SRC)/commons.c
HEADERS=$(INCLUDE)/fs.h $(INCLUDE)/keygen.h $(INCLUDE)/encryptor.h $(INCLUDE)/commons.h
OBJECTS=$(OBJ)/keygen.o $(OBJ)/fs.o $(OBJ)/encryptor.o $(OBJ)/commons.o
TARGETS=$(BIN)/serial $(BIN)/omp $(BIN)/mpi $(BIN)/encrypt $(BIN)/decrypt $(BIN)/unit-tests $(BIN)/stress-tests
all: $(TARGETS)
test: test-unit test-utils test-app
test-unit: $(BIN)/unit-tests
@./$(BIN)/unit-tests 2> /dev/null
@rm -fr output/testfile
test-stress: $(TARGETS)
@./$(BIN)/stress-tests
test-app: $(TARGETS)
@bash ./scripts/test-app.sh
test-utils: $(TARGETS)
@bash ./scripts/test-utils.sh
test-times: $(TARGETS)
@bash ./scripts/test-times.sh
test-scalability: $(TARGETS)
@bash ./scripts/test-scalability.sh
install:
@bash ./scripts/install-libs.sh
report:
@bash ./scripts/make-report.sh
## binary files
$(BIN)/serial: $(OBJ)/serial.o $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
$(BIN)/serial-min:
$(CC) $(LDFLAGS) $(SRC)/serial-min.c -o $@ -lcrypto
$(BIN)/omp: $(OBJ)/omp.o $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) -fopenmp
$(BIN)/mpi: $(OBJ)/mpi.o $(OBJECTS)
$(MPICC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
$(BIN)/encrypt: $(OBJ)/encrypt.o $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
$(BIN)/decrypt: $(OBJ)/decrypt.o $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
## tests files
$(BIN)/unit-tests: $(OBJ)/unit-tests.o $(OBJECTS)
$(CC) $(LDFLAGS) -L/usr/local/lib $^ -o $@ $(LDLIBS) $(CUNITLIB)
$(BIN)/stress-tests: $(OBJ)/stress-tests.o $(OBJECTS)
$(CC) $(LDFLAGS) -L/usr/local/lib $^ -o $@ $(LDLIBS) $(CUNITLIB)
## object files
$(OBJ)/serial.o: $(SRC)/serial.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(SRC)/serial.c -o $@ $(LDLIBS)
$(OBJ)/omp.o: $(SRC)/omp.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(SRC)/omp.c -o $@ $(LDLIBS) -fopenmp
$(OBJ)/mpi.o: $(SRC)/mpi.c $(HEADERS)
$(MPICC) $(LDFLAGS) -c $(SRC)/mpi.c -o $@
$(OBJ)/unit-tests.o: $(TEST)/unit-tests.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(TEST)/unit-tests.c -o $@ $(LDLIBS)
$(OBJ)/stress-tests.o: $(TEST)/stress-tests.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(TEST)/stress-tests.c -o $@ $(LDLIBS)
$(OBJ)/encrypt.o: $(SRC)/encrypt.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(SRC)/encrypt.c -o $@ $(LDLIBS)
$(OBJ)/decrypt.o: $(SRC)/decrypt.c $(HEADERS)
$(CC) $(LDFLAGS) -c $(SRC)/decrypt.c -o $@ $(LDLIBS)
$(OBJ)/keygen.o: $(SRC)/keygen.c $(INCLUDE)/keygen.h
$(CC) $(LDFLAGS) -c $(SRC)/keygen.c -o $@
$(OBJ)/fs.o: $(SRC)/fs.c $(INCLUDE)/fs.h
$(CC) $(LDFLAGS) -c $(SRC)/fs.c -o $@
$(OBJ)/encryptor.o: $(SRC)/encryptor.c $(INCLUDE)/encryptor.h
$(CC) $(LDFLAGS) -c $(SRC)/encryptor.c -o $@ $(LDLIBS)
$(OBJ)/commons.o: $(SRC)/commons.c $(INCLUDE)/commons.h
$(CC) $(LDFLAGS) -c $(SRC)/commons.c -o $@ $(LDLIBS)
# commands
gcov: clean-bin
LDFLAGS="-std=c99 -Wall -O0 --coverage -g" $(MAKE) all
lcov:
lcov -o cov.info -c -d obj/
genhtml -o cov cov.info
gprof: clean-bin
LDFLAGS="-std=c99 -Wall -O0 -pg -g" $(MAKE) all
memcheck: clean-bin
LDFLAGS="-std=c99 -Wall -O0 -g" $(MAKE) all
cachegrind: clean-bin
LDFLAGS="-std=c99 -Wall -O0 -g" $(MAKE) all
gcov-serial: gcov
echo "Frase: Never be led astray onto the path of virtue." > tmp/testfile
./bin/encrypt tmp/testfile 499999 cast5 tmp/encryptedfile
CANT_KEYS=500000 ./bin/serial tmp/encryptedfile
$(MAKE) lcov
gprof-serial:
echo "Frase: Never be led astray onto the path of virtue." > tmp/testfile
./bin/encrypt tmp/testfile 499999 blowfish tmp/encryptedfile
CANT_KEYS=500 ./bin/serial-min tmp/encryptedfile
gprof ./bin/serial-min gmon.out > gprof.out
memcheck-serial: memcheck
echo "Frase: Never be led astray onto the path of virtue." > testfile
./bin/encrypt testfile 499999 cast5 encryptedfile
CANT_KEYS=500000 valgrind --leak-check=yes bin/serial encryptedfile
cachegrind-serial: cachegrind
echo "Frase: Never be led astray onto the path of virtue." > testfile
./bin/encrypt testfile 50000 cast5 encryptedfile
CANT_KEYS=50000 valgrind --tool=cachegrind bin/serial encryptedfile
clean: clean-bin clean-gprof clean-gcov
clean-bin:
rm -f $(BIN)/* $(OBJ)/*
clean-gprof:
rm -fr gmon.out gprof.out
clean-gcov:
rm -fr cov cov.info