Import('env')

api_xml = Split("""
	api.xml""")

api_xsl = Split("""
	apiheader.xsl		apicache.xsl		apivalidate.xsl		apidebug.xsl""")	

api_install_headers = Split('''
	ri.inl
		''')

apienv = env.Copy()

apienv.UseTargetOptions('api')

apienv.Replace(APIXML = apienv.File('api.xml'))
cachegen = apienv.Command('ri_cache.inl', 'apicache.xsl', ['$XSLTPROC -o $TARGET $SOURCE $APIXML'])
headergen = apienv.Command('ri.inl', 'apiheader.xsl', ['$XSLTPROC -o $TARGET $SOURCE $APIXML'])
validategen = apienv.Command('ri_validate.inl', 'apivalidate.xsl', ['$XSLTPROC -o $TARGET $SOURCE $APIXML'])
debuggen = apienv.Command('ri_debug.inl', 'apidebug.xsl', ['$XSLTPROC -o $TARGET $SOURCE $APIXML'])

apienv.Depends(cachegen, '$APIXML')
apienv.Depends(headergen, '$APIXML')
apienv.Depends(validategen, '$APIXML')
apienv.Depends(debuggen, '$APIXML')

apienv.Install('$INCLUDEDIR', api_install_headers)

Export('cachegen validategen headergen debuggen')

env.Distribute(api_xml)
env.Distribute(api_xsl)
env.Distribute('SConscript')
