#!/usr/bin/env python

def configuration(parent_package='', top_path=None):
    import distutils.sysconfig as sysc
    from numpy.distutils.misc_util import Configuration
    import os.path as op

    import sys;
    if 'script' not in sys.path:
        sys.path.append('script')
    from config import Config
    system = Config().system()
    os_flag = {'posix' : 0, 'windows' : 1}

    auto_dir = op.dirname(__file__)
    auto_name = op.split(auto_dir)[-1]
    config = Configuration(auto_name, parent_package, top_path)

    defines = [('__SDIR__', "'\"%s\"'" % auto_dir),
               ('DEBUGFMF', None),
               ('SFEPY_PLATFORM', os_flag[system])]

    fem_src = ['common_python.c', 'fmfield.c', 'geommech.c']
    fem_src = [op.join('../../fem/extmods', ii) for ii in fem_src]
    src = ['formSDCC.c', 'terms.c', 'termsBasic.c', 'termsElectric.c',
           'termsMass.c', 'termsNavierStokes.c', 'termsBiot.c', 'termsLaplace.c',
           'termsLinElasticity.c', 'termsHyperElasticity.c', 'termsPiezo.c',
           'termsSurface.c', 'termsVolume.c', 'terms.i']

    depends=['array.i', 'common.i', 'fmfield.i']
    depends = [op.join('../../fem/extmods', ii) for ii in depends]

    config.add_extension('_terms',
                         sources=src + fem_src,
                         depends=depends,
                         extra_compile_args=['-O2'],
                         include_dirs=[auto_dir, '../../fem/extmods'],
                         define_macros=defines)

    return config

if __name__ == '__main__':
    from numpy.distutils.core import setup
    setup(**configuration(top_path='').todict())

@@ -188,16 +188,32 @@
 th as op
+%0A    import glob
 %0A%0A    im
@@ -802,16 +802,17 @@
 em_src%5D%0A
+%0A
     src 
@@ -818,283 +818,174 @@
  = %5B
-'formSDCC.c', 'terms.c', 'termsBasic.c', 'termsElectric.c',%0A           'termsMass.c', 'termsNavierStokes.c', 'termsBiot.c', 'termsLaplace.c',
+op.split(ii)%5B1%5D for ii in glob.glob('sfepy/terms/extmods/*.c')%5D%0A    src += %5B'terms.i'%5D%0A    try:%0A        src.remove('terms_wrap.c')
 %0A    
-       'termsLinElasticity.c', 'termsHyperElasticity.c', 'termsPiezo.c',%0A           'termsSurface.c', 'termsVolume.c', 'terms.i'%5D
+except ValueError:%0A        pass
 %0A%0A  

fix setup.py build