@@ -22,6 +22,7 @@ AC_CANONICAL_HOST
2222AC_CANONICAL_TARGET
2323AC_CONFIG_MACRO_DIR ( [ m4] )
2424
25+
2526AM_INIT_AUTOMAKE ( [ 1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests] )
2627
2728AC_ARG_PROGRAM
@@ -462,6 +463,52 @@ then
462463 AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_PROVISIONING"
463464fi
464465
466+ # SPDM Support
467+ AC_ARG_ENABLE ( [ spdm] ,
468+ [ AS_HELP_STRING ( [ --enable-spdm] ,[ Enable SPDM support (default: disabled)] ) ] ,
469+ [ ENABLED_SPDM=$enableval ] ,
470+ [ ENABLED_SPDM=no ]
471+ )
472+
473+ AC_ARG_WITH ( [ wolfspdm] ,
474+ [ AS_HELP_STRING ( [ --with-wolfspdm=PATH] ,[ DEPRECATED: Use --enable-spdm instead.] ) ] ,
475+ [ AC_MSG_ERROR ( [ --with-wolfspdm is no longer needed. Use --enable-spdm instead.] ) ] )
476+
477+ # SPDM dynamic memory (default: static/zero-malloc)
478+ AC_ARG_ENABLE ( [ spdm-dynamic-mem] ,
479+ [ AS_HELP_STRING ( [ --enable-spdm-dynamic-mem] ,[ SPDM: Use heap allocation for context (default: static)] ) ] ,
480+ [ ENABLED_SPDM_DYNMEM=$enableval ] ,
481+ [ ENABLED_SPDM_DYNMEM=no ]
482+ )
483+
484+ if test "x$ENABLED_SPDM" = "xyes"
485+ then
486+ AC_DEFINE ( [ WOLFTPM_SPDM] , [ 1] , [ Enable SPDM support] )
487+
488+ # Add spdm/ include path so all targets can find <wolfspdm/spdm.h>
489+ AM_CPPFLAGS="$AM_CPPFLAGS -I\$(srcdir)/spdm"
490+
491+ # Nuvoton SPDM support
492+ if test "x$ENABLED_NUVOTON" = "xyes"
493+ then
494+ if test "x$ENABLED_SWTPM" = "xyes"
495+ then
496+ AC_MSG_ERROR ( [ Cannot enable both swtpm and nuvoton with SPDM. Use --enable-swtpm --enable-spdm for emulator testing, or --enable-nuvoton --enable-spdm for hardware.] )
497+ fi
498+ AC_DEFINE ( [ WOLFSPDM_NUVOTON] , [ 1] , [ Enable SPDM Nuvoton TPM support] )
499+ AC_MSG_NOTICE ( [ Nuvoton SPDM vendor commands enabled] )
500+ fi
501+
502+ if test "x$ENABLED_SPDM_DYNMEM" = "xyes"
503+ then
504+ AC_DEFINE ( [ WOLFSPDM_DYNAMIC_MEMORY] , [ 1] , [ SPDM: Enable dynamic memory allocation] )
505+ fi
506+
507+ if test "x$ax_enable_debug" != "xno"
508+ then
509+ AC_DEFINE ( [ WOLFSPDM_DEBUG] , [ 1] , [ SPDM: Enable debug output] )
510+ fi
511+ fi
465512
466513# HARDEN FLAGS
467514AX_HARDEN_CC_COMPILER_FLAGS
@@ -493,6 +540,7 @@ AM_CONDITIONAL([BUILD_CHECKWAITSTATE], [test "x$ENABLED_CHECKWAITSTATE" = "xyes"
493540AM_CONDITIONAL([ BUILD_AUTODETECT] , [ test "x$ENABLED_AUTODETECT" = "xyes"] )
494541AM_CONDITIONAL([ BUILD_FIRMWARE] , [ test "x$ENABLED_FIRMWARE" = "xyes"] )
495542AM_CONDITIONAL([ BUILD_HAL] , [ test "x$ENABLED_EXAMPLE_HAL" = "xyes" || test "x$ENABLED_MMIO" = "xyes"] )
543+ AM_CONDITIONAL([ BUILD_SPDM] , [ test "x$ENABLED_SPDM" = "xyes"] )
496544
497545
498546CREATE_HEX_VERSION
@@ -578,6 +626,10 @@ for option in $OPTION_FLAGS; do
578626 fi
579627done
580628
629+ # Also capture SPDM defines from config.h (set via AC_DEFINE, not AM_CFLAGS)
630+ grep '^# define WOLFSPDM_' src/config.h >> $OPTION_FILE 2>/dev/null || true
631+ grep '^# define WOLFTPM_SPDM' src/config.h >> $OPTION_FILE 2>/dev/null || true
632+
581633echo "" >> $OPTION_FILE
582634echo "# ifdef __cplusplus" >> $OPTION_FILE
583635echo "}" >> $OPTION_FILE
@@ -622,3 +674,7 @@ echo " * Nuvoton NPCT75x: $ENABLED_NUVOTON"
622674
623675echo " * Runtime Module Detection: $ENABLED_AUTODETECT"
624676echo " * Firmware Upgrade Support: $ENABLED_FIRMWARE"
677+ echo " * SPDM Support: $ENABLED_SPDM"
678+ if test "x$ENABLED_SPDM" = "xyes"; then
679+ echo " * SPDM Dynamic Mem: $ENABLED_SPDM_DYNMEM"
680+ fi
0 commit comments