forked from tpm2-software/tpm2-pkcs11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.am
186 lines (150 loc) · 7.29 KB
/
Makefile.am
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
#;**********************************************************************;
# Copyright (c) 2018 Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#;**********************************************************************;
INCLUDE_DIRS = -I$(srcdir)/src -I$(top_srcdir)/src/lib
ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = $(INCLUDE_DIRS) $(EXTRA_CFLAGS) $(CODE_COVERAGE_CFLAGS) \
$(TSS2_ESYS_CFLAGS) $(SQLITE3_CFLAGS) $(PTHREAD_CFLAGS) \
$(CRYPTO_CFLAGS)
AM_LDFLAGS = $(EXTRA_LDFLAGS) $(CODE_COVERAGE_LIBS) $(TSS2_ESYS_LIBS) \
$(SQLITE3_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) \
$(TCTI_DEVICE_LIBS) $(TCTI_SOCKET_LIBS) $(TCTI_MSSIM_LIBS)
@CODE_COVERAGE_RULES@
# Add source code files from bootstrap
include src_vars.mk
EXTRA_DIST = \
LICENSE \
docs \
$(top_srcdir)/test/integration/scripts
# Generate the AUTHORS file from git log
AUTHORS :
$(AM_V_GEN)git log --format='%aN <%aE>' | grep -v 'users.noreply.github.com' | sort | \
uniq -c | sort -nr | sed 's/^\s*//' | cut -d" " -f2- > $@
EXTRA_DIST += AUTHORS
CLEANFILES = AUTHORS
# pkg-config setup. pc-file declarations happen in the corresponding modules
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA =
CLEANFILES += $(nodist_pkgconfig_DATA)
%.pc : %.pc.in
$(AM_V_GEN)$(call make_parent_dir,$@) && \
sed -e "s,[@]VERSION[@],$(PACKAGE_VERSION),g; \
s,[@]libdir[@],$(libdir),g; \
s,[@]includedir[@],$(includedir),g;" $^ > $@
### PKCS#11 Library Definition ###
libtpm2_pkcs11 = src/libtpm2_pkcs11.la
nodist_pkgconfig_DATA += lib/tpm2-pkcs11.pc
EXTRA_DIST += lib/tpm2-pkcs11.map lib/tpm2-pkcs11.pc.in
if HAVE_LD_VERSION_SCRIPT
src_libtpm2_pkcs11_la_LDFLAGS = -Wl,--version-script=$(srcdir)/lib/tpm2-pkcs11.map
endif # HAVE_LD_VERSION_SCRIPT
src_libtpm2_pkcs11_la_LIBADD = $(AM_LDFLAGS) -ldl
src_libtpm2_pkcs11_la_SOURCES = $(LIB_PKCS11_SRC) $(LIB_PKCS11_INTERNAL_LIB_SRC)
if HAVE_P11KIT
# Use P11 kit library module install location
p11libdir=$(P11_MODULE_PATH)
p11lib_LTLIBRARIES = $(libtpm2_pkcs11)
# Use P11 kit module config file install location
p11configdir=$(P11_CONFIGS_PATH)
p11config_DATA = $(top_srcdir)/misc/p11-kit/tpm2_pkcs11.module
else
# Use standard install location when P11Kit is not found
lib_LTLIBRARIES = $(libtpm2_pkcs11)
endif
# test harness configuration
TEST_EXTENSIONS = .int
AM_TESTS_ENVIRONMENT = \
TEST_FUNC_LIB=$(srcdir)/test/integration/scripts/int-test-funcs.sh \
PATH=./src:$(PATH)
INT_LOG_COMPILER = $(srcdir)/test/integration/scripts/int-test-setup.sh
TESTS_LDADD = $(noinst_LTLIBRARIES) $(lib_LTLIBRARIES) $(AM_LDFLAGS) $(CMOCKA_LIBS)
TETS_CFLAGS = $(CMOCKA_CFLAGS)
# Intentionally empty so INTEGRATION and UNIT tests can append to it.
check_PROGRAMS =
### Integration Tests ###
if ENABLE_INTEGRATION
TESTS = $(check_PROGRAMS)
check_PROGRAMS += \
test/integration/pkcs-find-objects.int \
test/integration/pkcs-get-mechanism.int \
test/integration/pkcs-login-logout.int \
test/integration/pkcs-sign-verify.int \
test/integration/pkcs-initialize-finalize.int \
test/integration/pkcs-misc.int \
test/integration/pkcs-crypt.int
XFAIL_TESTS=test/unit/test_pkcs11
test_integration_pkcs_find_objects_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_find_objects_int_LDADD = $(TESTS_LDADD)
test_integration_pkcs_find_objects_int_SOURCES = test/integration/pkcs-find-objects.int.c
test_integration_pkcs_get_mechanism_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_get_mechanism_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_get_mechanism_int_SOURCES = test/integration/pkcs-get-mechanism.int.c
test_integration_pkcs_login_logout_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_login_logout_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_login_logout_int_SOURCES = test/integration/pkcs-login-logout.int.c
test_integration_pkcs_sign_verify_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_sign_verify_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_sign_verify_int_SOURCES = test/integration/pkcs-sign-verify.int.c
test_integration_pkcs_initialize_finalize_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_initialize_finalize_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_initialize_finalize_int_SOURCES = test/integration/pkcs-initialize-finalize.int.c
test_integration_pkcs_misc_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_misc_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_misc_int_SOURCES = test/integration/pkcs-misc.int.c
test_integration_pkcs_crypt_int_CFLAGS = $(AM_CFLAGS) $(TESTS_CFLAGS)
test_integration_pkcs_crypt_int_LDADD = $(TESTS_LDADD) $(SQLITE3_LIBS)
test_integration_pkcs_crypt_int_SOURCES = test/integration/pkcs-crypt.int.c
endif
# END INTEGRATION
### Unit Tests ###
if UNIT
#
# Due to limitations in how cmocka works, we build a seperate library here so we
# can have a PKCS11 shared object with undefined calls into the rest of the lib
# code. This allows us to deploy a single library, but be able to dissect it for
# testing.
#
### PKCS#11 TEST Library Definitions ###
libtpm2_test_internal = src/libtpm2_test_internal.la
src_libtpm2_test_internal_la_LIBADD = $(AM_LDFLAGS) -ldl
src_libtpm2_test_internal_la_SOURCES = $(LIB_PKCS11_INTERNAL_LIB_SRC)
libtpm2_test_pkcs11 = src/libtpm2_test_pkcs11.la
src_libtpm2_test_pkcs11_la_LIBADD = $(AM_LDFLAGS) -ldl $(libtpm2_test_internal) -ldl
src_libtpm2_test_pkcs11_la_SOURCES = $(LIB_PKCS11_SRC)
noinst_LTLIBRARIES = $(libtpm2_test_pkcs11) $(libtpm2_test_internal)
## End of test libraries, start tests ##
TESTS = $(check_PROGRAMS)
check_PROGRAMS += \
test/unit/test_twist
test_unit_test_twist_CFLAGS = $(AM_CFLAGS) $(CMOCKA_CFLAGS)
test_unit_test_twist_LDADD = $(CMOCKA_LIBS) $(libtpm2_test_internal) $(libtpm2_test_pkcs11)
test_unit_test_twist_SOURCES = test/unit/test_twist.c
endif
# END UNIT
### Helper Functions ###
define make_parent_dir
if [ ! -d $(dir $1) ]; then mkdir -p $(dir $1); fi
endef