-- $Source$
-- $State$

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

local extract_parameters = simple {
	outputs = {
		"%U%/pathlength.h",
		"%U%/errout.h",
		"%U%/idfsize.h",
		"%U%/numsize.h",
		"%U%/nparams.h",
		"%U%/ifdepth.h",
		"%U%/lapbuf.h",
		"%U%/strsize.h",
		"%U%/botch_free.h",
		"%U%/debug.h",
		"%U%/parbufsize.h",
		"%U%/textsize.h",
		"%U%/inputtype.h",
		"%U%/obufsize.h",
		"%U%/dobits.h",
		"%U%/line_prefix.h",
	},
	
	command = {
		"cd %out[1]:dirname% && %in[1]% %in[2]%"
	},
	
	file (d.."make.hfiles"),
	file (d.."Parameters")
}

local lpars = LLgen {
	simple {
		outputs = {"%U%/tokenfile.g"},
		command = {
			"%in[1]% < %in[2]% > %out[1]%"
		},
		file (d.."make.tokfile"),
		file (d.."tokenname.c")
	},
	file (d.."expression.g")
}


local cfile_with_headers = cfile {
	class = "cfile_with_headers",
	dynamicheaders = {
		file (d),
		extract_parameters,
		lpars
	}
}
	
tool_cpp = cprogram {
	cfile_with_headers (d.."LLlex.c"),
	cfile_with_headers (d.."LLmessage.c"),
	cfile_with_headers (d.."ch7bin.c"),
	cfile_with_headers (d.."ch7mon.c"),
	cfile_with_headers (d.."domacro.c"),
	cfile_with_headers (d.."error.c"),
	cfile_with_headers (d.."idf.c"),
	cfile_with_headers (d.."init.c"),
	cfile_with_headers (d.."input.c"),
	cfile_with_headers (d.."main.c"),
	cfile_with_headers (d.."options.c"),
	cfile_with_headers (d.."preprocess.c"), 
	cfile_with_headers (d.."replace.c"),
	cfile_with_headers (d.."scan.c"),
	cfile_with_headers (d.."skip.c"),
	cfile_with_headers (d.."tokenname.c"),
	cfile_with_headers (d.."next.c"),
	cfile_with_headers (d.."expr.c"),

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

	cfile_with_headers {
		simple {
			outputs = {"%U%-symbol2str.c"},
			command = {
				"%in[1]% < %in[2]% > %out[1]%"
			},
			
			file (d.."make.tokcase"),
			file (d.."tokenname.c")
		}
	},
	
	cfile_with_headers {
		CEXTRAFLAGS = "-I"..d,
		tabgen (d.."char.tab")
	},
	
	lib_assert,
	lib_print,
	lib_alloc,
	lib_system,
	lib_string,
	
	outputs = {"%U%/cpp"},
	install = {
		pm.install("%BINDIR%%PLATDEP%/cpp"),
		pm.install(d.."cpp.6", "%BINDIR%man/man6/cpp.6")
	}
}

-- Revision history
-- $Log$
-- Revision 1.3  2006-07-22 20:58:27  dtrg
-- cpp now gets installed in the right place.
--
-- Revision 1.2  2006/07/22 12:27:31  dtrg
-- Removed a huge, ancient comment dating from the genmake days.
--
-- Revision 1.1  2006/07/20 23:24:28  dtrg
-- First version in CVS.
