-- $Source$
-- $State$

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

local makecldef = cprogram {
	cfile (d.."share/makecldef.c")
}

local classdefs_h = simple {
	outputs = {"%U%/classdefs.h"},
	command = {
		"%in[1]% %in[2]% %in[3]% > %out[1]%"
	},
	
	makecldef,
	file ("%HEADERDIR%em_mnem.h"),
	file (d.."share/cldefs.src")
}

local pop_push_h = simple {
	outputs = {"%U%/pop_push.h"},
	command = {
		"awk -f %in[1]% < %in[2]% > %out%"
	},
	
	file (d.."share/pop_push.awk"),
	file ("%ROOTDIR%h/em_table")
}

local cfile_with_headers = cfile {
	class = "cfile_with_headers",
	dynamicheaders = {
		classdefs_h,
		pop_push_h
	}
}

local ego_core = cprogram {
	CINCLUDES = {PARENT, ("-I"..d.."share")},
	
	cfile_with_headers (d.."share/debug.c"),
	cfile_with_headers (d.."share/global.c"),
	cfile_with_headers (d.."share/files.c"),
	cfile_with_headers (d.."share/go.c"),
	cfile_with_headers (d.."share/map.c"),
	cfile_with_headers (d.."share/aux.c"),
	cfile_with_headers (d.."share/get.c"),
	cfile_with_headers (d.."share/put.c"),
	cfile_with_headers (d.."share/alloc.c"),
	cfile_with_headers (d.."share/lset.c"),
	cfile_with_headers (d.."share/cset.c"),
	cfile_with_headers (d.."share/parser.c"),
	cfile_with_headers (d.."share/stack_chg.c"),
	cfile_with_headers (d.."share/locals.c"),
	cfile_with_headers (d.."share/init_glob.c"),
}

tool_ego = group {
	CDEFINES = {PARENT, "VERBOSE", "NOTCOMPACT"},
	
	ego_core {
		cfile_with_headers (d.."bo/bo.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/bo")
	},
	
	ego_core {
		cfile_with_headers (d.."ca/ca.c"),
		cfile_with_headers (d.."ca/ca_put.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/ca")
	},
	
	ego_core {
		cfile_with_headers (d.."cf/cf.c"),
		cfile_with_headers (d.."cf/cf_idom.c"),
		cfile_with_headers (d.."cf/cf_loop.c"),
		cfile_with_headers (d.."cf/cf_succ.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/cf")
	},
	
	ego_core {
		cfile_with_headers (d.."cj/cj.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/cj")
	},
	
	ego_core {
		cfile_with_headers (d.."cs/cs.c"),
		cfile_with_headers (d.."cs/cs_alloc.c"),
		cfile_with_headers (d.."cs/cs_aux.c"),
		cfile_with_headers (d.."cs/cs_avail.c"),
		cfile_with_headers (d.."cs/cs_debug.c"),
		cfile_with_headers (d.."cs/cs_elim.c"),
		cfile_with_headers (d.."cs/cs_entity.c"),
		cfile_with_headers (d.."cs/cs_getent.c"),
		cfile_with_headers (d.."cs/cs_kill.c"),
		cfile_with_headers (d.."cs/cs_partit.c"),
		cfile_with_headers (d.."cs/cs_profit.c"),
		cfile_with_headers (d.."cs/cs_stack.c"),
		cfile_with_headers (d.."cs/cs_vnm.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/cs")
	},
	
	ego_core {
		cfile_with_headers (d.."ic/ic.c"),
		cfile_with_headers (d.."ic/ic_aux.c"),
		cfile_with_headers (d.."ic/ic_io.c"),
		cfile_with_headers (d.."ic/ic_lib.c"),
		cfile_with_headers (d.."ic/ic_lookup.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/ic")
	},
	
	ego_core {
		cfile_with_headers (d.."il/il.c"),
		cfile_with_headers (d.."il/il1_anal.c"),
		cfile_with_headers (d.."il/il1_aux.c"),
		cfile_with_headers (d.."il/il1_cal.c"),
		cfile_with_headers (d.."il/il1_formal.c"),
		cfile_with_headers (d.."il/il2_aux.c"),
		cfile_with_headers (d.."il/il3_aux.c"),
		cfile_with_headers (d.."il/il3_change.c"),
		cfile_with_headers (d.."il/il3_subst.c"),
		cfile_with_headers (d.."il/il_aux.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/il")
	},
	
	ego_core {
		cfile_with_headers (d.."lv/lv.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/lv")
	},
	
	ego_core {
		cfile_with_headers (d.."ra/ra.c"),
		cfile_with_headers (d.."ra/ra_allocl.c"),
		cfile_with_headers (d.."ra/ra_aux.c"),
		cfile_with_headers (d.."ra/ra_interv.c"),
		cfile_with_headers (d.."ra/ra_lifet.c"),
		cfile_with_headers (d.."ra/ra_pack.c"),
		cfile_with_headers (d.."ra/ra_profits.c"),
		cfile_with_headers (d.."ra/ra_xform.c"),
		cfile {
			file (d.."ra/ra_items.c"),
			dynamicheaders = {
				simple {
					outputs = {"%U%/itemtab.h"},
					command = {
						"%in[1]% %in[2]% %in[3]% > %out[1]%"
					},
					
					cprogram {
						cfile (d.."ra/makeitems.c"),
					},
					file (HEADERDIR.."em_mnem.h"),
					file (d.."ra/itemtab.src")
				}
			}
		},
		
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/ra")
	},
	
	ego_core {
		cfile_with_headers (d.."sp/sp.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/sp")
	},
	
	ego_core {
		cfile_with_headers (d.."sr/sr.c"),
		cfile_with_headers (d.."sr/sr_aux.c"),
		cfile_with_headers (d.."sr/sr_cand.c"),
		cfile_with_headers (d.."sr/sr_expr.c"),
		cfile_with_headers (d.."sr/sr_iv.c"),
		cfile_with_headers (d.."sr/sr_reduce.c"),
		cfile_with_headers (d.."sr/sr_xform.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/sr")
	},
	
	ego_core {
		cfile_with_headers (d.."ud/ud.c"),
		cfile_with_headers (d.."ud/ud_aux.c"),
		cfile_with_headers (d.."ud/ud_const.c"),
		cfile_with_headers (d.."ud/ud_copy.c"),
		cfile_with_headers (d.."ud/ud_defs.c"),
		lib_em_data,
		
		install = pm.install("%BINDIR%%PLATDEP%/ego/ud")
	},
	
	cprogram {
		cfile (d.."em_ego/em_ego.c"),
	
		lib_print,
		lib_string,
		lib_system,
			
		install = pm.install("%BINDIR%%PLATDEP%/em_ego")
	}
}

-- This rule is used by the machine description pmfiles to massage and install
-- the ego descr files.

ego_descr = simple {
	outputs = {"%U%-%I%"},
	command = {
		"%BINDIR%%PLATDEP%/cpp -P -I%HEADERDIR% %in[1]% | sed -f %in[2]% > %out[1]%"
	},
	
	file (d.."descr/%ARCH%.descr"),
	file (d.."descr/descr.sed"),
	
	install = pm.install("%BINDIR%%PLATDEP%/ego/%ARCH%descr")
}

-- Revision history
-- $Log$
-- Revision 1.4  2007-02-25 12:49:20  dtrg
-- em_table is now in /h, not /etc.
--
-- Revision 1.3  2006/10/15 00:28:12  dtrg
-- Updated to the version 0.1 of Prime Mover (which involves some syntax changes).
--
-- Revision 1.2  2006/07/23 17:52:23  dtrg
-- cpp now gets installed in the right place.
--
-- Revision 1.1  2006/07/22 00:52:01  dtrg
-- Added support for the ego global optimisation suite.