-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
179 lines (146 loc) · 7.92 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
# Copyright 2020 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This is a top-level makefile that builds all libraries, programs,
# extensions/apps in this project. This makefile hardcodes dependencies between
# the targets, allowing parallel builds.
# Common definitions ############################
# Declare "all" as the default target that is built when "make" is run without
# extra arguments.
all:
.PHONY: all
# Toolchain-independent targets ####################
APPLICATION_TARGETS :=
LIBRARY_TARGETS := \
common/cpp/build \
smart_card_connector_app/build/cpp_lib \
third_party/ccid/webport/build \
third_party/driver-hid5021/webport/build \
third_party/googletest/webport/build \
third_party/libusb/webport/build \
third_party/pcsc-lite/webport/build_configuration \
third_party/pcsc-lite/webport/common/build \
third_party/pcsc-lite/webport/cpp_client/build \
third_party/pcsc-lite/webport/cpp_demo/build \
third_party/pcsc-lite/webport/server/build \
third_party/pcsc-lite/webport/server_clients_management/build \
example_cpp_smart_card_client_app/build: common/cpp/build
example_cpp_smart_card_client_app/build: third_party/pcsc-lite/webport/common/build
example_cpp_smart_card_client_app/build: third_party/pcsc-lite/webport/cpp_client/build
example_cpp_smart_card_client_app/build: third_party/pcsc-lite/webport/cpp_demo/build
smart_card_connector_app/build: common/cpp/build
smart_card_connector_app/build: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build: third_party/ccid/webport/build
smart_card_connector_app/build: third_party/driver-hid5021/webport/build
smart_card_connector_app/build: third_party/libusb/webport/build
smart_card_connector_app/build: third_party/pcsc-lite/webport/common/build
smart_card_connector_app/build: third_party/pcsc-lite/webport/server/build
smart_card_connector_app/build: third_party/pcsc-lite/webport/server_clients_management/build
third_party/ccid/webport/build: third_party/pcsc-lite/webport/build_configuration
third_party/driver-hid5021/webport/build: third_party/pcsc-lite/webport/build_configuration
third_party/pcsc-lite/webport/common/build: third_party/pcsc-lite/webport/build_configuration
third_party/pcsc-lite/webport/cpp_client/build: third_party/pcsc-lite/webport/build_configuration
third_party/pcsc-lite/webport/cpp_demo/build: third_party/pcsc-lite/webport/build_configuration
third_party/pcsc-lite/webport/server/build: third_party/pcsc-lite/webport/build_configuration
third_party/pcsc-lite/webport/server_clients_management/build: third_party/pcsc-lite/webport/build_configuration
TEST_TARGETS := \
common/cpp/build/tests \
smart_card_connector_app/build/executable_module/cpp_unittests \
third_party/libusb/webport/build/tests \
common/cpp/build/tests: common/cpp/build
common/cpp/build/tests: third_party/googletest/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: common/cpp/build
smart_card_connector_app/build/executable_module/cpp_unittests: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/ccid/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/driver-hid5021/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/googletest/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/libusb/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/webport/common/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/webport/server/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/webport/server_clients_management/build
third_party/libusb/webport/build/tests: common/cpp/build
third_party/libusb/webport/build/tests: third_party/googletest/webport/build
third_party/libusb/webport/build/tests: third_party/libusb/webport/build
# Toolchain related definitions #################
TOOLCHAIN ?= emscripten
# Applications with C/C++ code are built in all non-sanitizer build modes
# ("emscripten" is production-suitable; "coverage" needs the built binaries to
# catch parts of the code that aren't unit-tested but still linked into
# production programs).
ifneq ($(TOOLCHAIN),asan_testing)
APPLICATION_TARGETS += \
example_cpp_smart_card_client_app/build \
smart_card_connector_app/build \
endif
# Enable JS targets in relevant configurations.
ifeq ($(TOOLCHAIN),emscripten)
APPLICATION_TARGETS += \
example_js_smart_card_client_app/build \
LIBRARY_TARGETS += \
common/integration_testing/build \
example_js_standalone_smart_card_client_library \
TEST_TARGETS += \
common/js/build/js_to_cxx_tests \
common/js/build/unittests \
example_cpp_smart_card_client_app/build/js_to_cxx_tests \
smart_card_connector_app/build/js_to_cxx_tests \
smart_card_connector_app/build/js_unittests \
third_party/libusb/webport/build/js_unittests \
third_party/pcsc-lite/webport/server_clients_management/build/js_unittests \
common/js/build/js_to_cxx_tests: common/cpp/build
common/js/build/js_to_cxx_tests: common/integration_testing/build
example_cpp_smart_card_client_app/build/js_to_cxx_tests: common/cpp/build
example_cpp_smart_card_client_app/build/js_to_cxx_tests: common/integration_testing/build
example_cpp_smart_card_client_app/build/js_to_cxx_tests: example_cpp_smart_card_client_app/build
smart_card_connector_app/build/js_to_cxx_tests: common/cpp/build
smart_card_connector_app/build/js_to_cxx_tests: common/integration_testing/build
smart_card_connector_app/build/js_to_cxx_tests: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build/js_to_cxx_tests: third_party/ccid/webport/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/driver-hid5021/webport/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/libusb/webport/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/webport/common/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/webport/server/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/webport/server_clients_management/build
endif
# Combined "all" targets ########################
# "make" or "make all" will recursively compile all targets.
.PHONY: $(APPLICATION_TARGETS) $(LIBRARY_TARGETS) $(TEST_TARGETS)
all: $(APPLICATION_TARGETS) $(LIBRARY_TARGETS) $(TEST_TARGETS)
# Compile applications via "make package".
$(APPLICATION_TARGETS):
+$(MAKE) --directory=$@ package
# Compile libraries and tests via "make".
$(LIBRARY_TARGETS) $(TEST_TARGETS):
+$(MAKE) --directory=$@
define CLEAN_RULE
.PHONY: clean_$(1)
clean_$(1):
+$(MAKE) --directory=$(1) clean
clean: clean_$(1)
endef
# "make clean" will recursively clean all files produced by other targets.
.PHONY: clean
$(foreach target,$(APPLICATION_TARGETS) $(LIBRARY_TARGETS) $(TEST_TARGETS), \
$(eval $(call CLEAN_RULE,$(target))))
# Test targets ##################################
# The trailing blank line is needed, so that the "foreach" result is
# multi-lined, as opposed to squashing all commands into a single line.
define DO_RUN_TEST
+$(MAKE) --directory=$(1) run_test
endef
# "make test" will compile and execute all unit and integration tests.
# Implementation note: A single rule with a sequence of commands in the recipe
# is used, so that tests don't run in parallel (otherwise they might break).
.PHONY: test
test: all
$(foreach target,$(TEST_TARGETS),$(call DO_RUN_TEST,$(target)))