#!/usr/bin/env python


def configure(conf):
	from waflib.Build import Logs
	if conf.check_cc(fragment = '''
		#include <sys/types.h>
		#include <linux/fb.h>
		#include <linux/ipu.h>

		int main() { return 0; }
		''',
		uselib_store = 'IMXIPU',
		uselib = 'KERNEL_HEADERS',
		mandatory = False,
		execute = False,
		msg = 'checking for linux/fb.h and the IPU header linux/ipu.h'
	):
		Logs.pprint('GREEN', 'IPU elements will be built')
		conf.env['IPU_ELEMENTS_ENABLED'] = 1
	else:
		Logs.pprint('RED', 'IPU elements will not be built - headers not found')


def build(bld):
	if bld.env['IPU_ELEMENTS_ENABLED']:
		bld(
			features = ['c', bld.env['CLIBTYPE']],
			includes = ['.', '../..'],
			uselib = bld.env['COMMON_USELIB'] + ['IMXIPU', 'KERNEL_HEADERS'],
			use = ['gstimxcommon', 'gstimxblitter', 'gstimxcompositor'],
			target = 'gstimxipu',
			source = bld.path.ant_glob('*.c'),
			install_path = bld.env['PLUGIN_INSTALL_PATH']
		)

