/*
 *  ======== package.bld ========
 *  Build script for wolfSSL library
 */
var Build = xdc.useModule('xdc.bld.BuildEnvironment');
var Pkg = xdc.useModule('xdc.bld.PackageContents');

/* make command to search for the srcs */
Pkg.makePrologue = "vpath %.c $(subst ;,  ,$(XPKGPATH))";

/* WOLFSSL sources */
var wolfSSLObjList = [
    "wolfcrypt/src/aes.c",
    "wolfcrypt/src/arc4.c",
    "wolfcrypt/src/asm.c",
    "wolfcrypt/src/asn.c",
    "wolfcrypt/src/blake2b.c",
    "wolfcrypt/src/camellia.c",
    "wolfcrypt/src/chacha.c",
    "wolfcrypt/src/coding.c",
    "wolfcrypt/src/des3.c",
    "wolfcrypt/src/dh.c",
    "wolfcrypt/src/dsa.c",
    "wolfcrypt/src/ecc.c",
    "wolfcrypt/src/error.c",
    "wolfcrypt/src/hc128.c",
    "wolfcrypt/src/hmac.c",
    "wolfcrypt/src/hash.c",
    "wolfcrypt/src/integer.c",
    "wolfcrypt/src/logging.c",
    "wolfcrypt/src/md4.c",
    "wolfcrypt/src/md5.c",
    "wolfcrypt/src/memory.c",
    "wolfcrypt/src/poly1305.c",
    "wolfcrypt/src/pwdbased.c",
    "wolfcrypt/src/rabbit.c",
    "wolfcrypt/src/random.c",
    "wolfcrypt/src/rsa.c",
    "wolfcrypt/src/sha.c",
    "wolfcrypt/src/sha256.c",
    "wolfcrypt/src/sha512.c",
    "wolfcrypt/src/tfm.c",
    "wolfcrypt/src/wc_port.c",

    "src/internal.c",
    "src/io.c",
    "src/keys.c",
    "src/ssl.c",
    "src/tls.c",
];

for each (var targ in Build.targets) {
    var libOptions = {incs: wolfsslPathInclude};
    var lib = Pkg.addLibrary("lib/wolfssl", targ, libOptions);
    lib.addObjects(wolfSSLObjList);

    var hwLibptions = {incs: wolfsslPathInclude, defs: " -DWOLFSSL_TI_HASH "
           + "-DWOLFSSL_TI_CRYPT -DTARGET_IS_SNOWFLAKE_RA2"};

    var hwLib = Pkg.addLibrary("lib/wolfssl_tm4c_hw", targ, hwLibptions);
    hwLib.addObjects(wolfSSLObjList);
}

