-- $Source$
-- $State$

local d = ROOTDIR.."util/topgen/"

local lpars = LLgen {
	file (d.."topgen.g")
}

local cfile_with_headers = cfile {
	class = "cfile_with_headers",
	dynamicheaders = {
		file (d),
		lpars
	}
}
	
tool_topgen = cprogram {
	cfile_with_headers (d.."LLlex.c"),
	cfile_with_headers (d.."hash.c"),
	cfile_with_headers (d.."main.c"),
	cfile_with_headers (d.."pattern.c"),
	cfile_with_headers (d.."symtab.c"),

	foreach {
		rule = cfile_with_headers,
		ith { lpars, from=2 }
	},

	lib_assert,
	lib_print,
	lib_alloc,
	lib_system,
	lib_string,
	
	outputs = {"%U%/topgen"},
	install = pm.install("%TOOLDIR%topgen")
}

topgen = simple {
	class = "topgen",
	
	outputs = {"%U%/gen.c"},
	command = {
		"mkdir -p %out[1]:dirname%",
		"cd %out[1]:dirname% && %TOOLDIR%topgen %in[1]%"
	},
}
	
-- Revision history
-- $Log$
-- Revision 1.1  2006-07-22 12:31:19  dtrg
-- Added support for the top target peephole optimiser.
--
-- Revision 1.1  2006/07/20 23:24:28  dtrg
-- First version in CVS.
