Hello,

If you just want a subset of the features, change the compile-time configuration to only have the features you want. For example, to only build bignum, edit include/mbedtls/mbedtls_config.h to have only the line
#define MBEDTLS_BIGNUM_C
(and comments).

The build scripts always build all the source files, but the object files will be empty if the corresponding feature isn't included. So you don't need to modify CMakeLists.txt.

If you don't want to edit mbedtls_config.h in place, you can pass an alternative configuration file name by defining MBEDTLS_CONFIG_FILE, e.g.
CFLAGS='-O2 -DMBEDTLS_CONFIG_FILE=\"my_mbedtls_config.h\"'

Alternatively, you can write your own build scripts. If you just want to build core library files, you only need to compile .c files in the library directory, with the include directory on the include path, e.g.
c99 -I library -I include library/*.c
(Building with Everest or p256-m requires additional options because they use files in the 3rdparty directory.)

Best regards,

--
Gilles Peskine
Mbed TLS developer

On 16/03/2024 01:58, Liu Blade via mbed-tls wrote:
Hello,

Bignum is a very useful feature in Mbedtls, which is a part to libmbedcrypto.a. I want to build this module only as a standalone static library.  However, I find it's difficult to modify CMakelists.txt to do this. 

I appreciate your suggestions.

Blade