|
176 | 176 | AC_MSG_NOTICE([wolfCrypt path: ${wcpath}]) |
177 | 177 |
|
178 | 178 |
|
| 179 | +# SPI transport — this is the default when no other bus is selected. |
| 180 | +# The flag itself is an intent signal (so hardware-builds can say |
| 181 | +# --enable-spi explicitly); no macro is needed since the SPI HAL is |
| 182 | +# compiled whenever WOLFTPM_I2C isn't set. |
| 183 | +AC_ARG_ENABLE([spi], |
| 184 | + [AS_HELP_STRING([--enable-spi],[Intent signal for SPI hardware build. SPI is the default transport when --enable-i2c is not set; this flag adds no compile-time macro but disables the auto-enabled swTPM/fwTPM defaults. (default: not set)])], |
| 185 | + [ ENABLED_SPI=$enableval ], |
| 186 | + [ ENABLED_SPI=no ] |
| 187 | + ) |
| 188 | + |
179 | 189 | # I2C Support |
180 | 190 | AC_ARG_ENABLE([i2c], |
181 | 191 | [AS_HELP_STRING([--enable-i2c],[Enable I2C TPM Support (default: disabled)])], |
182 | 192 | [ ENABLED_I2C=$enableval ], |
183 | 193 | [ ENABLED_I2C=no ] |
184 | 194 | ) |
185 | 195 |
|
| 196 | +if test "x$ENABLED_SPI" = "xyes" && test "x$ENABLED_I2C" = "xyes" |
| 197 | +then |
| 198 | + AC_MSG_ERROR([Cannot enable both --enable-spi and --enable-i2c]) |
| 199 | +fi |
| 200 | + |
186 | 201 | if test "x$ENABLED_I2C" = "xyes" |
187 | 202 | then |
188 | 203 | AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_I2C" |
@@ -225,29 +240,43 @@ then |
225 | 240 | AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_LINUX_DEV" |
226 | 241 | fi |
227 | 242 |
|
228 | | -# Native host defaults — auto-enable fwTPM and swTPM on Linux/BSD x86_64 / aarch64 |
229 | | -# so `make check` provides full coverage out of the box. Users can still |
230 | | -# explicitly disable with --disable-fwtpm / --disable-swtpm. |
| 243 | +# If the user explicitly picked any hardware path (vendor, bus, kernel |
| 244 | +# driver, autodetect), don't default-enable the software TPMs — the SPI HAL |
| 245 | +# in hal/tpm_io_linux.c is excluded when WOLFTPM_SWTPM is defined. |
| 246 | +WOLFTPM_HW_SELECTED=no |
| 247 | +for _wt_v in "$enable_infineon" "$enable_st" "$enable_st33" \ |
| 248 | + "$enable_microchip" "$enable_mchp" \ |
| 249 | + "$enable_nuvoton" "$enable_nations" \ |
| 250 | + "$enable_spi" "$enable_i2c" "$enable_mmio" \ |
| 251 | + "$enable_devtpm" "$enable_autodetect" \ |
| 252 | + "$enable_winapi" "$enable_wintbs"; do |
| 253 | + if test -n "$_wt_v" && test "x$_wt_v" != "xno"; then |
| 254 | + WOLFTPM_HW_SELECTED=yes |
| 255 | + fi |
| 256 | +done |
| 257 | + |
| 258 | +# Auto-enable fwTPM + swTPM on Linux/BSD x86_64/aarch64 so `make check` |
| 259 | +# works out of the box — unless a hardware path was explicitly selected. |
231 | 260 | WOLFTPM_DEFAULT_FWTPM=no |
232 | 261 | WOLFTPM_DEFAULT_SWTPM=no |
233 | | -case $host_cpu in |
234 | | - x86_64|amd64|aarch64) |
235 | | - # Defensive exclusion: fwtpm_server uses POSIX sockets and is not |
236 | | - # currently portable to Windows / Darwin. Auto-enable on Linux/BSD only. |
237 | | - case $host_os in |
238 | | - *mingw*|*cygwin*|*msys*|*darwin*|*win32*) |
239 | | - ;; |
240 | | - *) |
241 | | - WOLFTPM_DEFAULT_FWTPM=yes |
242 | | - WOLFTPM_DEFAULT_SWTPM=yes |
243 | | - ;; |
244 | | - esac |
245 | | - ;; |
246 | | -esac |
| 262 | +if test "x$WOLFTPM_HW_SELECTED" = "xno"; then |
| 263 | + case $host_cpu in |
| 264 | + x86_64|amd64|aarch64) |
| 265 | + case $host_os in |
| 266 | + *mingw*|*cygwin*|*msys*|*darwin*|*win32*) |
| 267 | + ;; |
| 268 | + *) |
| 269 | + WOLFTPM_DEFAULT_FWTPM=yes |
| 270 | + WOLFTPM_DEFAULT_SWTPM=yes |
| 271 | + ;; |
| 272 | + esac |
| 273 | + ;; |
| 274 | + esac |
| 275 | +fi |
247 | 276 |
|
248 | 277 | # SW TPM device Support |
249 | 278 | AC_ARG_ENABLE([swtpm], |
250 | | - [AS_HELP_STRING([--enable-swtpm],[Enable use of TPM through the SW socket driver (default: enabled on Linux x86_64/aarch64, disabled elsewhere)])], |
| 279 | + [AS_HELP_STRING([--enable-swtpm],[Enable use of TPM through the SW socket driver (default: enabled on Linux x86_64/aarch64, disabled elsewhere or when any --enable-<vendor>/--enable-spi/--enable-i2c/--enable-mmio/--enable-devtpm/--enable-autodetect is explicitly set)])], |
251 | 280 | [ ENABLED_SWTPM=$enableval ], |
252 | 281 | [ ENABLED_SWTPM=$WOLFTPM_DEFAULT_SWTPM ] |
253 | 282 | ) |
@@ -299,7 +328,7 @@ AC_SUBST([DISTCHECK_SWTPM_PORT_FLAG]) |
299 | 328 |
|
300 | 329 | # Firmware TPM (fwTPM) - software TPM 2.0 simulator |
301 | 330 | AC_ARG_ENABLE([fwtpm], |
302 | | - [AS_HELP_STRING([--enable-fwtpm],[Enable firmware TPM (fwTPM) server (default: enabled on Linux x86_64/aarch64, disabled elsewhere)])], |
| 331 | + [AS_HELP_STRING([--enable-fwtpm],[Enable firmware TPM (fwTPM) server (default: enabled on Linux x86_64/aarch64, disabled elsewhere or when any --enable-<vendor>/--enable-spi/--enable-i2c/--enable-mmio/--enable-devtpm/--enable-autodetect is explicitly set)])], |
303 | 332 | [ ENABLED_FWTPM=$enableval ], |
304 | 333 | [ ENABLED_FWTPM=$WOLFTPM_DEFAULT_FWTPM ] |
305 | 334 | ) |
@@ -472,6 +501,11 @@ then |
472 | 501 | else |
473 | 502 | if test "x$ENABLED_INFINEON" = "xslb9673" |
474 | 503 | then |
| 504 | + # slb9673 is I2C-only; reject combos that imply SPI. |
| 505 | + if test "x$ENABLED_SPI" = "xyes" |
| 506 | + then |
| 507 | + AC_MSG_ERROR([--enable-infineon=slb9673 is I2C-only; use --enable-i2c --enable-advio (not --enable-spi)]) |
| 508 | + fi |
475 | 509 | enable_i2c=yes |
476 | 510 | AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_SLB9673" |
477 | 511 | else |
@@ -787,6 +821,19 @@ echo " * Wrappers: $ENABLED_WRAPPER" |
787 | 821 | echo " * Examples: $ENABLED_EXAMPLES" |
788 | 822 | echo " * wolfCrypt: $ENABLED_WOLFCRYPT" |
789 | 823 | echo " * Advanced IO: $ENABLED_ADVIO" |
| 824 | + |
| 825 | +# SPI HAL is actually compiled when no other transport claims the bus. |
| 826 | +# Mirror the #if guards in hal/tpm_io_linux.c so the summary reflects |
| 827 | +# the real build state, matching how ENABLED_I2C is reported below. |
| 828 | +SPI_ACTUAL=yes |
| 829 | +if test "x$ENABLED_I2C" = "xyes" || \ |
| 830 | + test "x$ENABLED_SWTPM" = "xyes" || test "x$ENABLED_SWTPM" = "xuart" || \ |
| 831 | + test "x$ENABLED_DEVTPM" = "xyes" || \ |
| 832 | + test "x$ENABLED_WINAPI" = "xyes" |
| 833 | +then |
| 834 | + SPI_ACTUAL=no |
| 835 | +fi |
| 836 | +echo " * SPI: $SPI_ACTUAL" |
790 | 837 | echo " * I2C: $ENABLED_I2C" |
791 | 838 | echo " * Linux kernel TPM device: $ENABLED_DEVTPM" |
792 | 839 | echo " * SWTPM: $ENABLED_SWTPM" |
|
0 commit comments