#!/usr/bin/env python
# encoding: utf8

import Options

def build(bld):
    all_libs = [
        # 'clangSema',
        # 'clangCodeGen',
        # 'clangAnalysis',
        # 'clangAST',
        # 'clangDriver',
        # 'clangLex',
        # 'clangParse',
        # 'clangRewrite',
        # 'clangBasic',
        'LLVMArchive',
        'LLVMBitReader',
        'LLVMBitWriter',
        'LLVMCodeGen',
        'LLVMCore',
        'LLVMInstrumentation',
        'LLVMScalarOpts',
        'LLVMSupport',
        'LLVMSystem',
        'LLVMTarget',
        'LLVMTransformUtils',
        'LLVMipa',
        'LLVMipo',
        'LLVMAnalysis'
        ]

    scheme_dir_header = bld.new_task_gen(
        features = 'subst',
        source = 'SchemeLibrary.hpp.in')
    scheme_dir_header.env.table.update({
            'DIR': Options.options.schemelibdir
            })

    bld.add_group('subst-header-clang')

    obj = bld.new_task_gen(
        target = 'clang',
        features = 'cxx cprogram',
        source = [
            'AnalysisConsumer.cpp',
            'ASTConsumers.cpp',
            'clang.cpp',
            'DiagChecker.cpp',
            'HTMLPrint.cpp',
            'PrintParserCallbacks.cpp',
            'PrintPreprocessedOutput.cpp',
            'RewriteBlocks.cpp',
            'RewriteMacros.cpp',
            'RewriteObjC.cpp',
            'SerializationTest.cpp',
            'SexpWriter.cpp'
            ],
        includes = ['.', '../include'],
        cxxflags = ['-fexceptions'],
        lib = all_libs,
        uselib = ['GUILE'],
        uselib_local = [
            'clangSema',
            'clangCodeGen',
            'clangAnalysis',
            'clangAST',
            'clangDriver',
            'clangLex',
            'clangParse',
            'clangRewrite',
            'clangBasic'
            ],
        install_path = '${PREFIX}/bin')
