Import("env")

env.Append(
    CPPPATH=[
        "#/lib/mbedtls",
        "#/lib/mbedtls/include",
    ],
    SDK_HEADERS=[
        File("mbedtls/include/mbedtls/des.h"),
        File("mbedtls/include/mbedtls/sha1.h"),
    ],
)


libenv = env.Clone(FW_LIB_NAME="mbedtls")
libenv.ApplyLibFlags()

libenv.AppendUnique(
    CCFLAGS=[
        # Required for lib to be linkable with .faps
        "-mword-relocations",
        "-mlong-calls",
    ],
)

sources = [
    "mbedtls/library/des.c",
    "mbedtls/library/sha1.c",
    "mbedtls/library/platform_util.c",
]

lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")
