
libkusp_shared:
    ldir = os.getcwd()+'/libkusp/'
    libkusp_files = ['configfile.c',
                     'linkedlist.c',
                     'hashtable.c',
                     'hashtable_types.c',
                     'misc.c',
                     'kusp_common.c',
                     'rdwr.c',
                     'vector.c',
                     'exception.c',
                     'configverify.c',
                     'net.c',
                     'kusp_private.h',
                     'preproc_lex.c',
                     'configfile_yacc.c',
                     'configfile_lex.c'

                     ]

    libkusp_files = map(lambda s: ldir+s, libkusp_files)
    libkusp_files = filter(lambda s: s.endswith('.c'), libkusp_files)
    compile_shared_library('kusp', include_dirs=['./libkusp', './include'], *libkusp_files)
    pass


libkusp_static:
    ldir = os.getcwd()+'/libkusp/'
    libkusp_files = ['configfile.c',
                     'linkedlist.c',
                     'hashtable.c',
                     'hashtable_types.c',
                     'misc.c',
                     'kusp_common.c',
                     'rdwr.c',
                     'vector.c',
                     'exception.c',
                     'configverify.c',
                     'net.c',
                     'kusp_private.h',
                     'preproc_lex.c',
                     'configfile_yacc.c',
                     'configfile_lex.c'
                     ]

    libkusp_files = map(lambda s: ldir+s, libkusp_files)
    libkusp_files = filter(lambda s: s.endswith('.c'), libkusp_files)
    compile_shared_library('kusp', include_dirs=['./libkusp', './include'], *libkusp_files)
    pass


printconfig:
    compile_executable('printconfig', 'libkusp/printconfig.c',
                       include_dirs=['./libkusp', './include', env.current_build_path], 
                       libs=['kusp','m'])
    pass

calib:
    compile_executable('calib', 'libperf/calib.c', 
                       include_dirs=['./libperf', './include'],
                       libs=['kusp','m'])
    pass

pykusp: libkusp_shared
    build_dir = env.current_build_path

    configfile_module = build_python_extension('configfile_mod',
        sources = ['libkusp/configfilemodule.c'],
        include_dirs = ['include'],
        libraries = ['kusp'],
        library_dirs = [build_dir],
        extra_compile_args = ["-g", "-fPIC"])
    
    build_python_package(name = 'configfile_mod',
        version = '1.0',
        description = 'parser python wrappers',
        author = 'Andrew Boie',
        ext_modules = [configfile_module])    

    build_python_package(auto_pkg_dir='pykusp',
          name = "pykusp",
          version = "0.1",  
          description = "Python modules on which most KUSP tools depend.",
          scripts = ["pykusp/trace-me",
                     'pykusp/testparser',
                     'pykusp/metaparser'],
        
          )
    pass


clean_common:
    rm -rfv $env.current_build_path
    pass

all: libkusp_shared libkusp_static pykusp printconfig calib
    pass
