-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·201 lines (137 loc) · 9.95 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#This file is part of transliteration_profile_iconv library.
#
#transliteration_profile_iconv is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#transliteration_profile_iconv is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with transliteration_profile_iconv. If not, see <http://www.gnu.org/licenses/>.
#
#©Copyright 2018 Laurent Lyaudet
CC=gcc
CFLAGS=-Wall
VERSION=1_1_0
.PHONY: run-tests run-tests-dynamic clean run-benchmarks run-benchmarks-dynamic
#-----------------------------------------------------------
#Build library
#-----------------------------------------------------------
build: build-static build-dynamic
#Static library
build-static: ./bin/libtransliteration_profile_iconv_$(VERSION).a
./bin/libtransliteration_profile_iconv_$(VERSION).a: ./bin/transliteration_profile_iconv.o
ar -rcs ./bin/libtransliteration_profile_iconv_$(VERSION).a ./bin/transliteration_profile_iconv.o
# ar -rc ./bin/libtransliteration_profile_iconv_$(VERSION).a ./bin/transliteration_profile_iconv.o
# ranlib ./bin/libtransliteration_profile_iconv_$(VERSION).a
./bin/transliteration_profile_iconv.o: ./transliteration_profile_iconv.h ./transliteration_profile_iconv.c
$(CC) $(CFLAGS) -c ./transliteration_profile_iconv.c -o ./bin/transliteration_profile_iconv.o
#Dynamic library
build-dynamic: ./bin/libtransliteration_profile_iconv_$(VERSION).so
./bin/libtransliteration_profile_iconv_$(VERSION).so: ./bin/transliteration_profile_iconv_dyn.o
$(CC) -shared -o ./bin/libtransliteration_profile_iconv_$(VERSION).so ./bin/transliteration_profile_iconv_dyn.o
./bin/transliteration_profile_iconv_dyn.o: ./transliteration_profile_iconv.h ./transliteration_profile_iconv.c
$(CC) $(CFLAGS) -fPIC -c ./transliteration_profile_iconv.c -o ./bin/transliteration_profile_iconv_dyn.o
#-----------------------------------------------------------
#Build tests
#-----------------------------------------------------------
build-tests: build-test1 build-test2 build-test3 build-test4
#Test 1
build-test1: ./tests_benchmarks/test1/test1.exe ./tests_benchmarks/test1/test1_dyn.exe
#static linking requires the library to come after the test object
./tests_benchmarks/test1/test1.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).a ./tests_benchmarks/test1/test1.o
$(CC) -static -L./bin/ ./tests_benchmarks/test1/test1.o -ltransliteration_profile_iconv_$(VERSION) -o ./tests_benchmarks/test1/test1.exe
./tests_benchmarks/test1/test1_dyn.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).so ./tests_benchmarks/test1/test1.o
$(CC) -L./bin/ -ltransliteration_profile_iconv_$(VERSION) ./tests_benchmarks/test1/test1.o -o ./tests_benchmarks/test1/test1_dyn.exe
./tests_benchmarks/test1/test1.o: ./transliteration_profile_iconv.h ./tests_benchmarks/test_functions.c ./tests_benchmarks/test1/test1.c
$(CC) $(CFLAGS) -c ./tests_benchmarks/test1/test1.c -o ./tests_benchmarks/test1/test1.o
#Test 2
build-test2: ./tests_benchmarks/test2/test2.exe ./tests_benchmarks/test2/test2_dyn.exe
#static linking requires the library to come after the test object
./tests_benchmarks/test2/test2.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).a ./tests_benchmarks/test2/test2.o
$(CC) -static -L./bin/ ./tests_benchmarks/test2/test2.o -ltransliteration_profile_iconv_$(VERSION) -o ./tests_benchmarks/test2/test2.exe
./tests_benchmarks/test2/test2_dyn.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).so ./tests_benchmarks/test2/test2.o
$(CC) -L./bin/ -ltransliteration_profile_iconv_$(VERSION) ./tests_benchmarks/test2/test2.o -o ./tests_benchmarks/test2/test2_dyn.exe
./tests_benchmarks/test2/test2.o: ./transliteration_profile_iconv.h ./tests_benchmarks/test_functions.c ./tests_benchmarks/test2/test2.c
$(CC) $(CFLAGS) -c ./tests_benchmarks/test2/test2.c -o ./tests_benchmarks/test2/test2.o
#Test 3
build-test3: ./tests_benchmarks/test3/test3.exe ./tests_benchmarks/test3/test3_dyn.exe
#static linking requires the library to come after the test object
./tests_benchmarks/test3/test3.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).a ./tests_benchmarks/test3/test3.o
$(CC) -static -L./bin/ ./tests_benchmarks/test3/test3.o -ltransliteration_profile_iconv_$(VERSION) -o ./tests_benchmarks/test3/test3.exe
./tests_benchmarks/test3/test3_dyn.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).so ./tests_benchmarks/test3/test3.o
$(CC) -L./bin/ -ltransliteration_profile_iconv_$(VERSION) ./tests_benchmarks/test3/test3.o -o ./tests_benchmarks/test3/test3_dyn.exe
./tests_benchmarks/test3/test3.o: ./transliteration_profile_iconv.h ./tests_benchmarks/test_functions.c ./tests_benchmarks/test3/test3.c
$(CC) $(CFLAGS) -c ./tests_benchmarks/test3/test3.c -o ./tests_benchmarks/test3/test3.o
#Test 4
build-test4: ./tests_benchmarks/test4/test4.exe ./tests_benchmarks/test4/test4_dyn.exe
#static linking requires the library to come after the test object
./tests_benchmarks/test4/test4.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).a ./tests_benchmarks/test4/test4.o
$(CC) -static -L./bin/ ./tests_benchmarks/test4/test4.o -ltransliteration_profile_iconv_$(VERSION) -o ./tests_benchmarks/test4/test4.exe
./tests_benchmarks/test4/test4_dyn.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).so ./tests_benchmarks/test4/test4.o
$(CC) -L./bin/ -ltransliteration_profile_iconv_$(VERSION) ./tests_benchmarks/test4/test4.o -o ./tests_benchmarks/test4/test4_dyn.exe
./tests_benchmarks/test4/test4.o: ./transliteration_profile_iconv.h ./tests_benchmarks/test_functions.c ./tests_benchmarks/test4/test4.c
$(CC) $(CFLAGS) -c ./tests_benchmarks/test4/test4.c -o ./tests_benchmarks/test4/test4.o
#-----------------------------------------------------------
#Install
#-----------------------------------------------------------
install: /usr/lib/libtransliteration_profile_iconv_$(VERSION).so
/usr/lib/libtransliteration_profile_iconv_$(VERSION).so: ./bin/libtransliteration_profile_iconv_$(VERSION).so
cp -p ./bin/libtransliteration_profile_iconv_$(VERSION).so /usr/lib
chmod 755 /usr/lib/libtransliteration_profile_iconv_$(VERSION).so
#-----------------------------------------------------------
#Run tests
#-----------------------------------------------------------
test: build-tests run-tests
run-tests:
cd ./tests_benchmarks/test1/ && echo "\nTest1:" && ./test1.exe && cd ../..
cd ./tests_benchmarks/test2/ && echo "\nTest2:" && ./test2.exe && cd ../..
cd ./tests_benchmarks/test3/ && echo "\nTest3:" && ./test3.exe && cd ../..
cd ./tests_benchmarks/test4/ && echo "\nTest4:" && ./test4.exe && cd ../..
run-tests-dynamic: install
cd ./tests_benchmarks/test1/ && echo "\nTest1 dyn:" && ./test1_dyn.exe && cd ../..
cd ./tests_benchmarks/test2/ && echo "\nTest2 dyn:" && ./test2_dyn.exe && cd ../..
cd ./tests_benchmarks/test3/ && echo "\nTest3 dyn:" && ./test3_dyn.exe && cd ../..
cd ./tests_benchmarks/test4/ && echo "\nTest4 dyn:" && ./test4_dyn.exe && cd ../..
#-----------------------------------------------------------
#Build benchmarks
#-----------------------------------------------------------
build-benchmarks: build-benchmark1
#Benchmark 1
build-benchmark1: ./tests_benchmarks/benchmark1/benchmark1.exe ./tests_benchmarks/benchmark1/benchmark1_dyn.exe
#/usr/share/i18n/locales/fr_FR@test /usr/share/i18n/charmaps/ISO-8859-1-test.gz
# echo "\nfr_FR@test ISO-8859-1-test\n" >> /etc/locale.gen
# locale-gen
#static linking requires the library to come after the test object
./tests_benchmarks/benchmark1/benchmark1.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).a ./tests_benchmarks/benchmark1/benchmark1.o
$(CC) -static -L./bin/ ./tests_benchmarks/benchmark1/benchmark1.o -ltransliteration_profile_iconv_$(VERSION) -o ./tests_benchmarks/benchmark1/benchmark1.exe
./tests_benchmarks/benchmark1/benchmark1_dyn.exe: ./bin/libtransliteration_profile_iconv_$(VERSION).so ./tests_benchmarks/benchmark1/benchmark1.o
$(CC) -L./bin/ -ltransliteration_profile_iconv_$(VERSION) ./tests_benchmarks/benchmark1/benchmark1.o -o ./tests_benchmarks/benchmark1/benchmark1_dyn.exe
./tests_benchmarks/benchmark1/benchmark1.o: ./transliteration_profile_iconv.h ./tests_benchmarks/test_functions.c ./tests_benchmarks/benchmark1/benchmark1.c
$(CC) $(CFLAGS) -c ./tests_benchmarks/benchmark1/benchmark1.c -o ./tests_benchmarks/benchmark1/benchmark1.o
/usr/share/i18n/locales/fr_FR@test: ./tests_benchmarks/benchmark1/fr_FR@test
cp ./tests_benchmarks/benchmark1/fr_FR@test /usr/share/i18n/locales/
/usr/share/i18n/charmaps/ISO-8859-1-test.gz: ./tests_benchmarks/benchmark1/ISO-8859-1-test.gz
cp ./tests_benchmarks/benchmark1/ISO-8859-1-test.gz /usr/share/i18n/charmaps/
#-----------------------------------------------------------
#Run benchmarks
#-----------------------------------------------------------
benchmarks: build-benchmarks run-benchmarks
run-benchmarks:
cd ./tests_benchmarks/benchmark1/ && echo "\nBenchmark1:" && ./benchmark1.exe && cd ../..
run-benchmarks-dynamic: install
cd ./tests_benchmarks/benchmark1/ && echo "\nBenchmark1 dyn:" && ./benchmark1_dyn.exe && cd ../..
#-----------------------------------------------------------
#Clean
#-----------------------------------------------------------
clean:
rm -f ./bin/*
rm -f ./tests_benchmarks/test1/*.o ./tests_benchmarks/test1/*.exe ./tests_benchmarks/test1/*.test_result
rm -f ./tests_benchmarks/test2/*.o ./tests_benchmarks/test2/*.exe ./tests_benchmarks/test2/*.test_result
rm -f ./tests_benchmarks/test3/*.o ./tests_benchmarks/test3/*.exe ./tests_benchmarks/test3/*.test_result
rm -f ./tests_benchmarks/test4/*.o ./tests_benchmarks/test4/*.exe ./tests_benchmarks/test4/*.test_result
rm -f ./tests_benchmarks/benchmark1/*.o ./tests_benchmarks/benchmark1/*.exe ./tests_benchmarks/benchmark1/*.test_result