/*
    matrixssl.me -- MatrixSSL Component
 */

Me.load({ 
    targets: {
        matrixssl: {
            description: 'MatrixSSL SSL',
            config: function (target) {
                if (me.options.gen) {
                    return {
                        path: target.withpath || '/usr/src/matrixssl',
                        libpaths: [ '$(ME_COM_MATRIXSSL_PATH)' ],
                        includes: [ '$(ME_COM_MATRIXSSL_PATH)', '$(ME_COM_MATRIXSSL_PATH)/matrixssl' ],
                        libraries: [(me.platform.os == 'windows') ? 'matrixssl.lib' : 'matrixssl'],
                    }
                }
                let search = getComponentSearch(target, 'matrixssl', (me.platform.os == 'windows') ? 'Release' : '')
                let lib = probe('libmatrixssl.' + me.ext.shobj, {fullpath: true, search: search}).absolute
                let imports, libraries
                if (me.platform.os == 'windows') {
                    libraries = [ 'matrixssl.lib' ],
                    imports = [ lib, lib.replaceExt('lib') ]
                } else {
                    libraries = [ 'matrixssl' ]
                    imports = [ lib ]
                }
                let path = lib.dirname
                let incdir = probe('matrixsslApi.h', {search: [ path.join('matrixssl')]}).absolute
                return {
                    path:       path,
                    includes:   [ incdir, incdir.parent ]
                    libpaths:   [ path ],
                    libraries:  libraries,
                    imports:    imports,
                }
            },
            ifdef:     [ 'ssl' ],
            conflicts: [ 'est', 'nanossl', 'openssl' ],
        },
    },
})
