@@ -2975,48 +2975,158 @@ AC_ARG_WITH([maxq10xx],
29752975 ]
29762976)
29772977
2978+ AC_ARG_ENABLE ( [ microchip] ,
2979+ [ AS_HELP_STRING ( [ --enable-microchip] ,[ Enable wolfSSL support for microchip/atmel 508/608/100 (default: disabled)] ) ] ,
2980+ [ ENABLED_ATMEL=$enableval ] ,
2981+ [ ENABLED_ATMEL=no ]
2982+ )
2983+
2984+ if test "$ENABLED_ATMEL" != "no"
2985+ then
2986+ AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MICROCHIP"
2987+
2988+ for v in `echo $ENABLED_ATMEL | tr "," " "`
2989+ do
2990+ case $v in
2991+ 508)
2992+ AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ATECC508A"
2993+ ;;
2994+
2995+ 608)
2996+ AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ATECC608A"
2997+ ;;
2998+
2999+ 100)
3000+ AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MICROCHIP_TA100 -DMICROCHIP_DEV_TYPE=TA100"
3001+ ;;
3002+ esac
3003+ done
3004+ fi
3005+
3006+
29783007# Microchip/Atmel CryptoAuthLib
29793008ENABLED_CRYPTOAUTHLIB="no"
2980- trylibatcadir=""
29813009AC_ARG_WITH ( [ cryptoauthlib] ,
2982- [ AS_HELP_STRING ( [ --with-cryptoauthlib=PATH] ,[ PATH to CryptoAuthLib install (default /usr/)] ) ] ,
2983- [
2984- AC_MSG_CHECKING ( [ for cryptoauthlib] )
2985- CPPFLAGS="$CPPFLAGS -DWOLFSSL_ATECC508A"
2986- LIBS="$LIBS -lcryptoauth"
3010+ [ AS_HELP_STRING ( [ --with-cryptoauthlib=PATH] ,
3011+ [ PATH to CryptoAuthLib install (default: system paths)] ) ] ,
3012+ [ with_cryptoauthlib=$withval] ,
3013+ [ with_cryptoauthlib=no] )
3014+
3015+ AS_IF ( [ test "x$with_cryptoauthlib" != "xno"] , [
3016+ AS_IF ( [ test "x$ENABLED_ATMEL" = "xno"] , [
3017+ AC_MSG_ERROR ( [ --with-cryptoauthlib requires --enable-microchip=<devices>.] )
3018+ ] )
3019+ AC_MSG_CHECKING ( [ for CryptoAuthLib] )
3020+
3021+ libdir=""
3022+ incdir=""
3023+ cryptoauthlib_found="no"
3024+
3025+ saved_LIBS="$LIBS"
3026+ saved_LDFLAGS="$LDFLAGS"
3027+ saved_CPPFLAGS="$CPPFLAGS"
3028+ saved_CFLAGS="$CFLAGS"
3029+
3030+ # Method 1: Try pkg-config first (most reliable)
3031+ m4_ifdef ( [ PKG_CHECK_MODULES] , [
3032+ PKG_CHECK_MODULES([ CRYPTOAUTHLIB] , [ cryptoauthlib] , [
3033+ CPPFLAGS="$CRYPTOAUTHLIB_CFLAGS $CPPFLAGS"
3034+ CFLAGS="$CRYPTOAUTHLIB_CFLAGS $CFLAGS"
3035+ LIBS="$CRYPTOAUTHLIB_LIBS $LIBS"
3036+ cryptoauthlib_found="pkg-config"
3037+ ] , [ :] )
3038+ ] )
29873039
2988- AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <cryptoauthlib.h>] ] , [ [ atcab_init(0); ] ] ) ] ,[ libatca_linked=yes ] ,[ libatca_linked=no ] )
3040+ # Method 2: Manual search if pkg-config failed
3041+ AS_IF ( [ test "x$cryptoauthlib_found" = "xno"] , [
3042+ AS_IF ( [ test "x$with_cryptoauthlib" = "xyes"] , [
3043+ search_dirs="/usr /usr/local"
3044+ ] , [
3045+ search_dirs="$with_cryptoauthlib"
3046+ ] )
29893047
2990- if test "x$libatca_linked" = "xno" ; then
2991- if test "x$withval" != "xno" ; then
2992- trylibatcadir=$withval
2993- fi
2994- if test "x$withval" = "xyes" ; then
2995- trylibatcadir="/usr"
3048+ for trylibatcadir in $search_dirs; do
3049+ for try_libdir in "$trylibatcadir/lib" "$trylibatcadir/lib64"; do
3050+ if test -f "$try_libdir/libcryptoauth.so" || test -f "$try_libdir/libcryptoauth.a"; then
3051+ libdir="$try_libdir"
3052+ break
3053+ fi
3054+ done
3055+
3056+ if test -z "$libdir"; then
3057+ if test -x /usr/bin/dpkg-architecture; then
3058+ DEB_HOST_MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null`
3059+ if test -n "$DEB_HOST_MULTIARCH"; then
3060+ try_libdir="$trylibatcadir/lib/$DEB_HOST_MULTIARCH"
3061+ if test -f "$try_libdir/libcryptoauth.so" || test -f "$try_libdir/libcryptoauth.a"; then
3062+ libdir="$try_libdir"
3063+ fi
3064+ fi
3065+ fi
29963066 fi
29973067
2998- LDFLAGS="$LDFLAGS -L$trylibatcadir/lib"
2999- CPPFLAGS="$CPPFLAGS -I$trylibatcadir/lib"
3000-
3001- AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <cryptoauthlib.h>] ] , [ [ atcab_init(0); ] ] ) ] ,[ libatca_linked=yes ] ,[ libatca_linked=no ] )
3068+ for try_incdir in "$trylibatcadir/include/cryptoauthlib" "$trylibatcadir/include"; do
3069+ if test -f "$try_incdir/cryptoauthlib.h"; then
3070+ incdir="$try_incdir"
3071+ break
3072+ fi
3073+ done
30023074
3003- if test "x$libatca_linked" = "xno" ; then
3004- AC_MSG_ERROR ( [ cryptoauthlib isn't found.
3005- If it's already installed, specify its path using --with-cryptoauthlib=/dir/] )
3075+ if test -n "$libdir" && test -n "$incdir"; then
3076+ break
30063077 fi
3078+ libdir=""
3079+ incdir=""
3080+ done
30073081
3008- AM_LDFLAGS="$AM_LDFLAGS -L$trylibatcadir/lib"
3009- AM_CFLAGS="$AM_CFLAGS -I$trylibatcadir/lib"
3010- AC_MSG_RESULT ( [ yes] )
3011- else
3012- AC_MSG_RESULT ( [ yes] )
3082+ if test -n "$libdir" && test -n "$incdir"; then
3083+ CPPFLAGS="-I$incdir $CPPFLAGS"
3084+ CFLAGS="-I$incdir $CFLAGS"
3085+ LDFLAGS="-L$libdir $LDFLAGS"
3086+ LIBS="-lcryptoauth $LIBS"
3087+ cryptoauthlib_found="$libdir"
30133088 fi
3089+ ] )
30143090
3015- ENABLED_CRYPTOAUTHLIB="yes"
3016- AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ATECC508A"
3017- ]
3018- )
3091+ AS_IF ( [ test "x$cryptoauthlib_found" != "xno"] , [
3092+ wolfssl_include=""
3093+ AS_IF ( [ test -f "${srcdir}/wolfssl/wolfcrypt/types.h"] , [
3094+ wolfssl_include="-I${srcdir}"
3095+ ] , [ test -f "${srcdir}/wolfssl.h"] , [
3096+ wolfssl_include="-I${srcdir}"
3097+ ] )
30193098
3099+ test_CPPFLAGS="$wolfssl_include $CPPFLAGS"
3100+ test_CFLAGS="$wolfssl_include $CFLAGS"
3101+
3102+ saved_test_CPPFLAGS="$CPPFLAGS"
3103+ saved_test_CFLAGS="$CFLAGS"
3104+ CPPFLAGS="$test_CPPFLAGS"
3105+ CFLAGS="$test_CFLAGS"
3106+
3107+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM (
3108+ [ [ #include <cryptoauthlib.h>] ] ,
3109+ [ [ atcab_init(0); return 0;] ] ) ] ,
3110+ [
3111+ ENABLED_CRYPTOAUTHLIB="yes"
3112+ AC_MSG_RESULT ( [ yes ($cryptoauthlib_found)] )
3113+ AC_DEFINE ( [ HAVE_CRYPTOAUTHLIB] , [ 1] , [ CryptoAuthLib support] )
3114+ CPPFLAGS="$saved_test_CPPFLAGS"
3115+ CFLAGS="$saved_test_CFLAGS"
3116+ ] ,
3117+ [
3118+ LIBS="$saved_LIBS"
3119+ LDFLAGS="$saved_LDFLAGS"
3120+ CPPFLAGS="$saved_CPPFLAGS"
3121+ CFLAGS="$saved_CFLAGS"
3122+ AC_MSG_RESULT ( [ no - compilation failed] )
3123+ AC_MSG_ERROR ( [ CryptoAuthLib found but compilation check failed. Check config.log for details.] )
3124+ ] )
3125+ ] , [
3126+ AC_MSG_RESULT ( [ no - library not found] )
3127+ AC_MSG_ERROR ( [ CryptoAuthLib not found. Install it or specify path with --with-cryptoauthlib=/path] )
3128+ ] )
3129+ ] )
30203130
30213131# TropicSquare TROPIC01
30223132# Example: "./configure --with-tropic01=/home/pi/libtropic"
0 commit comments