#! /usr/bin/env python
# encoding: utf-8
# DC 2008
# Thomas Nagy 2010 (ita)

top = '.'
out = 'build'

def options(opt):
	opt.load('compiler_c')
	opt.load('compiler_fc')
	opt.recurse('typemap')

def configure(conf):
	conf.load('compiler_c')
	conf.load('compiler_fc')
	if conf.env.FC_NAME == 'IFORT':
		conf.env['FCFLAGS'] = ['-warn']
	elif conf.env.FC_NAME == 'GFORTRAN':
		conf.env['FCFLAGS'] = ['-Wall', '-W']
	#conf.env['INCLUDES'] = ['hfloupi']

	conf.check_fortran()
	conf.check_fortran_verbose_flag()
	conf.check_fortran_clib()
	conf.check_fortran_dummy_main()
	conf.check_fortran_mangling()
	conf.recurse('typemap')

def build(bld):

	bld(
		features = 'fc',
		source   = 'hello.f')

	bld(
		features = 'fc fcprogram',
		source   = 'hello.f',
		target   = 'hello',
		use      = 'DEBUG')

	bld(
		features = 'fc fcshlib',
		source   = 'foo.f',
		target   = 'shlib1',
		vnum     = '2.3.9')

	bld(
		features = 'fc fcstlib',
		source   = 'foo.f',
		target   = 'foo')

	bld(
		features = 'fc fcprogram',
		source   = 'foo_pp.F',
		target   = 'foo',
		defines  = ['USEFOO', 'blah=1'],
		use      = 'shlib1')

	bld.add_group()

	bld(
		features = 'fc fcprogram',
		includes = 'src/include',
		source   = 'src/hello_inc.f',
		target   = 'hello_inc')

	bld(
		features = 'fc',
		source   = 'src/calculator_main.f src/calculator.f',
		target   = 'calc_objs')

	bld(
		features = 'fc fcprogram',
		use      = 'calc_objs',
		target   = 'calculator')

	bld(
		features = 'fc fcstlib',
		source = 'mod/two_mods.f90 mod/uses_two_mods.f90',
		target = 'mod/two_mods')

	bld.recurse('typemap')
