AMAKELIB = { . , /usr/local/lib/amake } ;

%include std-amake.amk ;
%include ack-defs.amk ;
%include cc_hh_tools.amk ;
%include tok_tools.amk ;
%include op_tools.amk ;
%include char_tools.amk ;

%default grind ;

%declare tokenname.c [
	gen_tokens,
	cc-dest = symbol2str.c,
	LL-dest = tokenfile.g
];

CMD_LLSRC = {
	tokenname.c,
	commands.g
} ;

CSRC = {
	main.c,
	list.c,
	tree.c,
	expr.c,
	position.c,
	idf.c,
	run.c,
	symbol.c,
	print.c,
	type.c,
	rd.c,
	do_comm.c,
	modula-2.c,
	pascal.c,
	c.c
} ;

HSRC = {
	tokenname.h,
	operator.h,
	class.h,
	position.h,
	idf.h,
	message.h,
	avl.h,
	scope.h,
	langdep.h,
	sizes.h,
	token.h,
	expr.h,
	rd.h
} ;

HHSRC = {
	file.hh,
	type.hh,
	symbol.hh,
	tree.hh,
	avl.cc,
	scope.cc,
	itemlist.cc,
	langdep.cc
} ;

LIBRARIES = {
	$EMHOME/modules/lib/libassert.a,
	$EMHOME/modules/lib/liballoc.a,
	$EMHOME/modules/lib/malloc.o,
	$EMHOME/modules/lib/libstring.a,
	$EMHOME/modules/lib/libobject.a,
	$EMHOME/modules/lib/libsystem.a
} ;

DBFLAGS = { -O, -DDEBUG } ;
PROFFLAGS = { } ;

LDFLAGS = {
	-Bstatic,
	$PROFFLAGS,
	$DBFLAGS
} ;

INCLUDES = {
	-I$EMHOME/modules/h,
	-I$EMHOME/modules/pkg,
	-I$EMHOME/h
} ;

CFLAGS = {
	$INCLUDES,
	$PROFFLAGS,
	$DBFLAGS
} ;

DBS_LLTARGETS = {
	db_symtab.c,
	DBSpars.c,
	DBSpars.h
} ;

DBS_LLSRC = {
	db_symtab.g
} ;

%cluster {
	%targets $DBS_LLTARGETS ;
	%sources $DBS_LLSRC ;
	%use LLgen(prefix => DBS) ;
} ;

LINTFLAGS = {
	$INCLUDES
} ;

%cluster {
	%targets lint.out[type = lint-output];
	%sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
	%use lint(realdest => lint.out) ;
} ;

%cluster {
	%targets grind[type = program];
	%sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
} ;