/*
    manifest.me - MakeMe manifest for GoAhead
 */

Me.load({
    /*
        Package manifest instructions
        The sets used are: binary, doc, dev, package, source
     */
    manifest: {
        home: me.dir.bin,
        root: true,
        packages:   {
            install: {
                inherit:    'package-manifest',
                prefixes:   [ 'root', 'app', 'vapp', 'bin', 'man', 'web', 'etc'],
                sets:       [ 'core', 'libs', 'doc' ],
                platforms:  [ 'unix', 'windows' ]
            },
            binary: {
                inherit:    'package-manifest',
                prefixes:   [ 'root', 'app', 'vapp', 'bin', 'man', 'web', 'etc'],
                formats:    [ 'native', 'tar' ],
                sets:       [ 'core', 'libs', 'doc', 'package' ],
                platforms:  [ 'freebsd', 'linux', 'macosx', 'windows' ]
            },
            source: {
                inherit:    'package-manifest',
                prefixes:   [ 'root', 'src' ],
                formats:    [ 'tar' ],
                sets:       [ 'source' ],
            },
            pak: {
                inherit:    'package-manifest',
                prefixes:   [ 'src'],
                formats:    [ 'tar' ],
                sets:       [ 'pak' ],
            },
        },

        sets: { 
            core: [
                {   
                    from:       'goahead${EXE}',
                    to:         '${abin}/',
                    symlink:    '${bin}/',

                }, { 
                    from:       '${TOP}/paks/est/dist/ca.crt',
                    to:         '${abin}/',

                }, { 
                    from: [ 
                                '${TOP}/src/web/index.html', 
                                '${TOP}/src/web/favicon.ico' 
                    ],
                    to:     '${web}/',
                    exclude: /mgmt|bench|test/,

                }, { 
                    from: [
                                '${TOP}/src/auth.txt', 
                                '${TOP}/src/route.txt', 
                                '${TOP}/src/self.crt', 
                                '${TOP}/src/self.key'
                    ],
                    to:         '${etc}/'
                }
            ],
            libs: [
                { 
                    from:       'libgo${SHOBJ}',
                    to:         '${abin}/',
                    enable:     '!me.settings.static',

                }, { 
                    from:       'libest${SHOBJ}',
                    to:         '${abin}/',
                    components: 'est',
                    enable:     '!me.settings.static',
                    ifdef:      'est',

                }, { 
                    from: [
                                'libssl*${SHOBJ}*',
                                'libcrypto*${SHOBJ}*',
                    ],
                    to:         '${abin}/',
                    enable:     'me.platform.os != "windows" && !makeme.options.gen',
                    ifdef:      'openssl',

                }, { 
                    from: [
                                'libeay32${SHOBJ}',
                                'ssleay32${SHOBJ}',
                    ],
                    to:         '${abin}/',
                    enable:     'me.platform.os == "windows"',
                    ifdef:      'openssl',
                }
            ],
            doc: [
                { 
                    from:       '${TOP}/doc/dist/man/*.1',
                    to:         '${adoc}/man/man1/',
                    symlink:    '${man}/man1/',
                    enable:     "me.platform.like == 'unix'",
                }
            ],
            source: [
                {
                    from:       '${TOP}/*.md',
                    to:         '${src}/',
                    fold:       true,
                    patch:      true,

                }, { 
                    from:       '${TOP}/configure',
                    to:         '${src}/',
                    permissions: 0755,     

                }, { 
                    home:       '${TOP}',
                    from: [ 
                                'Makefile', 
                                'make.bat', 
                                'main.me', 
                                'package.json', 
                                'paks',
                                'src', 
                                'doc', 
                                'projects', 
                                'installs', 
                                'test' 
                    ],
                    exclude:    /\.old$|\.tmp$|xcuserdata|xcworkspace|project.guid|-mine/,
                    to:         '${src}/',
                    flatten:    false,
                },
            ],
            pak: [
                {
                    from:       '${TOP}/installs/goahead.me',
                    to:         '${src}/dist/goahead.me',

                }, {
                    from:       '${TOP}/src/goahead.h',
                    to:         '${src}/dist/goahead.h',
                    append:     true,
                    filter:     /^#inc.*customize.*$/mg,

                }, {
                    from:       [
                        '${TOP}/src/*.c',
                        '${TOP}/src/ssl/*.c',
                    ],
                    exclude:    /\/crt\/|\/mocana\/|\/utils\//,
                    to:         '${src}/dist/goahead.c',
                    append:     true,
                    header:     '/*\n * ${settings.title} Library Source\n */\n\n#include \"goahead.h\"\n\n#if ME_COM_GOAHEAD',
                    divider:    true,
                    footer:     '#endif /* ME_COM_GOAHEAD */',
                    filter:     /^#inc.*goahead.*$|^#inc.*customize.*$/mg,
                }
            ]
        }
    }
})
