-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathMakefile
242 lines (209 loc) · 9.55 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# This file is part of the HörTech Open Master Hearing Aid (openMHA)
# Copyright © 2013 2014 2015 2016 2017 2018 2019 2020 HörTech gGmbH
# Copyright © 2022 2024 Hörzentrum Oldenburg gGmbH
#
# openMHA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# openMHA 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 Affero General Public License, version 3 for more details.
#
# You should have received a copy of the GNU Affero General Public License,
# version 3 along with openMHA. If not, see <http://www.gnu.org/licenses/>.
# This is the main MHA Makefile.
#
# The MHA is organized in modules. Each module is a
# subdirectory. Inter-module dependencies are defined in in this file.
#
# For cross-compilers please set the variable COMPILERPREFIX, e.g.:
#
# make COMPILERPREFIX=arm-linux-gnueabihf-
#
# or add the COMPILERPREFIX variable to config.mk
include config.mk
MODULES = \
mha/libmha \
mha/frameworks \
mha/plugins \
external_libs
DOCMODULES = \
mha/doc \
all: $(MODULES)
config.mk:
./configure
test: all
$(MAKE) -C mha/mhatest
.PHONY : $(MODULES) $(DOCMODULES) coverage
$(MODULES:external_libs=) $(DOCMODULES):
$(MAKE) -C $@
external_libs:
$(MAKE) -C $@
doc: mha/doc
/bin/cp -lv --remove-destination mha/doc/*.pdf .
zip -r pdf-$$(cat version).zip *.pdf
clean:
for m in $(MODULES) $(DOCMODULES); do $(MAKE) -C $$m clean; done
ifeq "$(PLATFORM)" "Darwin"
install: all
@mkdir -p $(abspath $(DESTDIR)$(PREFIX))/bin
@mkdir -p $(abspath $(DESTDIR)$(PREFIX))/lib
@find ./external_libs/ ./mha/ -path '*tools/packaging*' -prune -o -type f -name '*$(DYNAMIC_LIB_EXT)' \
! -name Info.plist \
-execdir rm -f $(abspath $(DESTDIR)$(PREFIX))/lib/{} \; \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/lib/ \; \
-execdir install_name_tool -change $(shell pwd)/mha/libmha/$(BUILD_DIR)/libopenmha$(DYNAMIC_LIB_EXT) \
$(PREFIX)/lib/libopenmha$(DYNAMIC_LIB_EXT) \
$(abspath $(DESTDIR)$(PREFIX))/lib/{} \; \
-execdir install_name_tool -id $(PREFIX)/lib/{} \
$(abspath $(DESTDIR)$(PREFIX))/lib/{} \;
@find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" ! -name ".*" ! -name unit-test-runner \
! -name Info.plist \
-execdir rm -f $(abspath $(DESTDIR)$(PREFIX))/bin/{} \; \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/bin/ \; \
-execdir install_name_tool -change $(shell pwd)/mha/libmha/$(BUILD_DIR)/libopenmha$(DYNAMIC_LIB_EXT) \
$(PREFIX)/lib/libopenmha$(DYNAMIC_LIB_EXT) \
$(abspath $(DESTDIR)$(PREFIX))/bin/{} \;
@cp mha/tools/thismha.sh $(abspath $(DESTDIR)$(PREFIX))/bin/.
uninstall:
@rm -f $(shell find ./external_libs/ ./mha/ -type f -name *$(DYNAMIC_LIB_EXT) -execdir echo $(abspath $(DESTDIR)$(PREFIX))/lib/{} \;)
@rm -f $(shell find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" -execdir echo $(abspath $(DESTDIR)$(PREFIX))/bin/{} \;)
@rm -f $(abspath $(DESTDIR)$(PREFIX))/bin/mha.sh
else ifeq "$(PLATFORM)" "MinGW"
install: all
@mkdir -p $(abspath $(DESTDIR)$(PREFIX))/bin
@find ./external_libs/ ./mha/ -path '*tools/packaging*' -prune -o -type f -name *$(DYNAMIC_LIB_EXT) \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/bin/ \;
@find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" ! -name "unit-test-runner*" \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/bin/ \;
@cp mha/tools/thismha.sh $(abspath $(DESTDIR)$(PREFIX))/bin/.
uninstall:
@rm -f $(shell find ./external_libs/ ./mha/ -type f -name *$(DYNAMIC_LIB_EXT) -execdir echo $(abspath $(DESTDIR)$(PREFIX))/bin/{} \;)
@rm -f $(shell find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" -execdir echo $(abspath $(DESTDIR)$(PREFIX))/bin/{} \;)
@rm -f $(abspath $(DESTDIR)$(PREFIX))/bin/mha.sh
else
install: all
@mkdir -p $(abspath $(DESTDIR)$(PREFIX))/bin
@mkdir -p $(abspath $(DESTDIR)$(PREFIX))/lib
@find ./external_libs/ ./mha/ -path '*tools/packaging*' -prune -o -type f -name *$(DYNAMIC_LIB_EXT) \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/lib/ \;
@find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" ! -name ".*" ! -name unit-test-runner \
-exec cp {} $(abspath $(DESTDIR)$(PREFIX))/bin/ \;
@cp mha/tools/thismha.sh $(abspath $(DESTDIR)$(PREFIX))/bin/.
uninstall:
@rm -f $(shell find ./external_libs/ ./mha/ -type f -name *$(DYNAMIC_LIB_EXT) -execdir echo $(abspath $(DESTDIR)$(PREFIX))/lib/{} \;)
@rm -f $(shell find ./mha/frameworks/${BUILD_DIR} -type f ! -name "*.o" -execdir echo $(abspath $(DESTDIR)$(PREFIX))/bin/{} \;)
@rm -f $(abspath $(DESTDIR)$(PREFIX))/bin/mha.sh
endif
googletest:
$(MAKE) -C external_libs googlemock
unit-tests: $(patsubst %,%-subdir-unit-tests,$(MODULES))
$(patsubst %,%-subdir-unit-tests,$(MODULES)): all googletest
$(MAKE) -C $(@:-subdir-unit-tests=) unit-tests
coverage: unit-tests
lcov --capture --directory mha --output-file coverage.info
genhtml coverage.info --prefix $$PWD/mha --output-directory $@
x-www-browser ./coverage/index.html
# Unit-test can not be run when cross-compiling
ifeq "$(ARCH)" "armhf"
deb: install
$(MAKE) -C mha/tools/packaging/deb clean
$(MAKE) -C mha/tools/packaging/deb pack
else
deb: unit-tests
$(MAKE) -C mha/tools/packaging/deb clean
$(MAKE) -C mha/tools/packaging/deb pack
endif
exe: installer-exe unit-tests
installer-exe: install
$(MAKE) -C mha/tools/packaging/exe exe
homebrew: installer-homebrew
installer-homebrew: unit-tests
$(MAKE) -C mha/tools/packaging/homebrew install
release: test unit-tests install
@./mha/tools/release.sh openMHA # 'openMHA' is passed to prevent user from calling script accidentally
# Inter-module dependencies. Required for parallel building (e.g. make -j 4)
mha/libmha: external_libs
mha/frameworks: mha/libmha
mha/plugins: mha/libmha mha/frameworks
mha/mhatest: mha/plugins mha/frameworks
mha/doc: mha/plugins
# Debian package management by Jenkins:
# New Debian Packages are stored in our storage for debian repositories.
# The storage is cleaned of old packages depending on the current branch.
#
# Glossary:
#
# supply:
# The packages stored here have just been built. Location is
# project-specific. For openMHA, it is ./mha/tools/packaging/deb/hoertech/$SYSTEM/
# regardless of $BRANCH_NAME.
# The packages here may be new or they may be rebuilds of
# existing versions (e.g. if someone clicks build-now while
# there is no new revision). Rebuilds of existing versions
# will not be used, but will cause an update of the timestamp of the respective
# files in storage. New packages are copied to storage
#
# storage:
# The packages here are kept persistently across builds.
# Old packets (timestamp older than some threshold) will be deleted for
# branch development.
# Storage location:
# /var/lib/jenkins/packages-for-aptly/STORAGE/$PROJECT/$BRANCH_NAME/$SYSTEM/
# on the host, which is mounted to /STORAGE/$PROJECT/$BRANCH_NAME/$SYSTEM/
# in the container.
#
#
# $PROJECT:
# openMHA, liblsl, liblsl-matlab, tascarpro, more may be added
#
# $BRANCH_NAME:
# master, uploaded to apt.hoertech.de, and development, uploaded to
# aptdev.hoertech.de. BRANCH_NAME is set by Jenkins
#
# SYSTEMs:
# focal, jessie, jammy etc. Available SYSTEMs that
# contain packages are detected automatically with $(wildcard)
# There will by $SYSTEM subdirectories below this directory.
# These subdirectories then contain the package files.
SUPPLY_DIR = ./mha/tools/packaging/deb/hoertech/
PROJECT = openMHA
# There will be $SYSTEM subdirectories below this directory.
STORAGE_DIR = /STORAGE/$(PROJECT)/$(BRANCH_NAME)/
# How many days to keep debian packages in storage that are superceded by a
# newer version
RETENTION = 14
storage: pruned-storage-$(BRANCH_NAME)
# Delete debian packages in storage older than RETENTION days
pruned-storage-%: updated-storage-%
@echo uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@echo Begin pruning storage...
@echo nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
find $(STORAGE_DIR) -name "*.deb" -type f -mtime +$(RETENTION) -delete -print
-rmdir $(STORAGE_DIR)/* # delete empty subdirs if there are any
@echo uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@echo Storage pruning finished.
@echo nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
# Never delete old packages in the master database
pruned-storage-master: updated-storage-master
@echo uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@echo "Keep all existing packages on branch master"
@echo nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
# copy the $SYSTEM/packages.deb tree without overwriting existing package files.
# then, update the timestamps for all files that are now in the supply to
# prevent deletion of latest files because they might be too old.
updated-storage-$(BRANCH_NAME):
@echo uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@echo Begin updating storage...
@echo nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
mkdir -p $(STORAGE_DIR)
cp -rnv $(SUPPLY_DIR)* $(STORAGE_DIR)
cd $(SUPPLY_DIR) && find . -name \*.deb -exec touch $(STORAGE_DIR){} \;
@echo uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@echo Storage update finished.
@echo nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
# Local Variables:
# coding: utf-8-unix
# End: