#
# Copyright (C) 2017 FAUmachine Team <info@faumachine.org>.
# This program is free software. You can redistribute it and/or modify it
# under the terms of the GNU General Public License, either version 2 of
# the License, or (at your option) any later version. See COPYING.
#

DVD_IMAGE := Debian-5.0r0-i386-DVD-1
SIMULATION_PC := pc-4.vhdl

ADDITIONAL_USER_VHDL := dummy_user.vhdl
ADDITIONAL_VHDL_FILE := \
	pc1.user.vhdl \
	pc2.user.vhdl

include $(dir $(shell which faum))/../share/faumachine/vhdl/experiment.mk

generate:
	touch $@

dummy_user.vhdl: $(EXP_DIR)/dummy_user.vhdl
	cp $(EXP_DIR)/dummy_user.vhdl dummy_user.vhdl

%.user.vhdl: %.user-begin.vhdl \
	%.generate.vhdl \
	$(HW_USER_END)
	cat $^ > $@

%.user-begin.vhdl: $(EXP_DIR)/user-begin.vhdl.in
	cat $^ \
		| sed -e "s/@USER@/user_$*/" \
		> $@

%.generate.vhdl: %.generate.in
	$(FAUM_GEN_VHDL) $< $(EXP_DIR) >$@

%.generate.in: $(EXP_DIR)/generate.in
	cat $^ \
		| sed -e 's/@DVD@/Debian-5.0r0-i386-DVD-1/' \
		| sed -e "s/debian50/cl$*/" \
		| sed -e "s/@NUM@/$(subst pc,,$*)/" \
		> $@

clean distclean::
	$(RM) dummy_user.vhdl
	$(RM) *.user.vhdl
	$(RM) *.user-begin.vhdl
	$(RM) *.generate.in
	$(RM) *.generate.vhdl
	$(RM) generate
