# explicit rules: .y -> .c (bison)
#  do not assume old yacc to work to different file names, do the generation
#  in a separate directory to allow parallel compilation with -j
switch /local/rnd/mod/YACC
	case {^$} end
	default
		foreach /local/n in /local/rnd/mod/YACC
			put /local/bn /local/n
			sub {/local/bn} {^.*/} {}
			put /local/dn /local/n
			sub {/local/dn} {/[^/]*$} {}

			if /local/pcb/want_parsgen
			then
				append /local/rnd/RULES [@
# yacc for @/local/rnd/mod@
@/local/n@.c @/local/n@.h: @/local/n@.y
	cd @/local/dn@ && bison --defines=@/local/bn@.h --output=@/local/bn@.c --report-file=@/local/bn@.output -d @/local/bn@.y
@]
			else
				append /local/rnd/RULES [@
# dummy yacc for @/local/rnd/mod@
@/local/n@.c @/local/n@.h:
	echo "skipping yacc..."
@]
			end
		end
	end
end

# explicit rules: .l -> .c (flex)
#  do not assume old lex to work to different file names, do the generation
#  in a separate directory to allow parallel compilation with -j
switch /local/rnd/mod/LEX
	case {^$} end
	default
		foreach /local/n in /local/rnd/mod/LEX
			if /local/pcb/want_parsgen
			then
				put /local/bn /local/n
				sub {/local/bn} {^.*/} {}
				put /local/dn /local/n
				sub {/local/dn} {/[^/]*$} {}

				append /local/rnd/RULES [@
# lex for @/local/rnd/mod@
@/local/n@.c @/local/n@.h: @/local/n@.l
	cd @/local/dn@ && flex --outfile=@/local/bn@.c --header-file=@/local/bn@.h @/local/bn@.l
@]
			else
				append /local/rnd/RULES [@
# dummy lex for @/local/rnd/mod@
@/local/n@.c:
	echo "skipping flex..."
@]
			end
		end
	end
end



# explicit rules: .y -> .c (byaccic)
switch /local/rnd/mod/BYACCIC
	case {^$} end
	default
		foreach /local/n in /local/rnd/mod/BYACCIC
			put /local/bn /local/n
			sub {/local/bn} {^.*/} {}
			put /local/dn /local/n
			sub {/local/dn} {/[^/]*$} {}

			if /local/pcb/want_parsgen_byaccic
			then
				append /local/rnd/RULES [@
# byaccic for @/local/rnd/mod@
@/local/n@.c @/local/n@.h: @/local/n@.y
	byaccic -o ../src_plugins/@/local/rnd/mod@/@/local/bn@.c -H ../src_plugins/@/local/rnd/mod@/@/local/bn@.h -v ../src_plugins/@/local/rnd/mod@/@/local/bn@.desc ../src_plugins/@/local/rnd/mod@/@/local/bn@.y
@]
			else
				append /local/rnd/RULES [@
# dummy byaccic for @/local/rnd/mod@
@/local/n@.c @/local/n@.h:
	echo "skipping byaccic..."
@]
			end
		end
	end
end

# explicit rules: .l -> .c (ureglex)
switch /local/rnd/mod/UREGLEX
	case {^$} end
	default
		foreach /local/n in /local/rnd/mod/UREGLEX
			if /local/pcb/want_parsgen_byaccic
			then
				put /local/bn /local/n
				sub {/local/bn} {^.*/} {}
				put /local/dn /local/n
				sub {/local/dn} {/[^/]*$} {}

				append /local/rnd/RULES [@
# lex for @/local/rnd/mod@
@/local/n@.c @/local/n@.h: @/local/n@.ul
	cd @/local/dn@ && ureglex -C -c @/local/bn@.c -h @/local/bn@.h -l @/local/bn@.ul
@]
			else
				append /local/rnd/RULES [@
# dummy ureglex for @/local/rnd/mod@
@/local/n@.c:
	echo "skipping ureglex..."
@]
			end
		end
	end
end


put /local/rnd/mod/enabled {1}

include  /local/pcb/tmpasm/plugin_conf
include  /local/pcb/tmpasm/plugin_sphash
include  /local/pcb/tmpasm/plugin_intconf
include  /local/pcb/tmpasm/plugin_intmenu

append /local/rnd/CLEANFILES ?/local/rnd/mod/CLEANFILES
append /local/rnd/DISTCLEANFILES ?/local/rnd/mod/DISTCLEANFILES

put /local/rnd/mod/enabled {}
put /local/rnd/mod/OBJS {}
put /local/rnd/mod/OBJS_C99 {}
put /local/rnd/mod/LDFLAGS {}
put /local/rnd/mod/CFLAGS {}
put /local/rnd/mod/YACC {}
put /local/rnd/mod/LEX {}
put /local/rnd/mod/BYACCIC {}
put /local/rnd/mod/UREGLEX {}
put /local/rnd/mod/SPHASH {}
put /local/rnd/mod/SPHASH_ARGS {}
put /local/rnd/mod/CLEANFILES {}
put /local/rnd/mod/DISTCLEANFILES {}
put /local/rnd/mod {}
put /local/rnd/mod/CONFFILE {}
put /local/rnd/mod/CONFVAR  {}
put /local/rnd/mod/MENUFILE {}
put /local/rnd/mod/MENUVAR  {}
