# ------------------------------------------------------------------------
# Makefile: examples for the SpecC Reference Compiler
# ------------------------------------------------------------------------
#
# Modifications: (most recent first)
#
# RD 12/28/01	added 'test' target to make and run through all examples
# RD 11/12/01	added Exception.sc example
# RD 05/24/01	reduced contents to SCRC requirements
# ------------------------------------------------------------------------

# --- macros

include ../Makefile.macros

DIST	=	Makefile		\
		simple/Makefile		\
		simple/README		\
		simple/Adder.sc		\
		simple/Behaviors.sc	\
		simple/BitVectors.sc	\
		simple/Callback.sc	\
		simple/DataTypes.sc	\
		simple/Exception.sc	\
		simple/FSM.sc		\
		simple/HelloWorld.sc	\
		simple/Notes.sc		\
		simple/Pipeline.sc	\
		simple/Pipeline2.sc	\
		simple/Timing.sc	\
		simple/Handshaking1.sc	\
		simple/Handshaking2.sc	\
		import/Makefile		\
		import/README		\
		import/Testbench.sc	\
		import/Adder/ADD08_1.sc	\
		import/Adder/ADD08_2.sc	\
		import/Adder/ADD16_1.sc	\
		import/Adder/ADD16_2.sc	\
		import/Adder/ADD32_1.sc	\
		import/Adder/ADD32_2.sc	\
		import/Adder/AddLib.sc	\
		import/Gate/AND2.sc	\
		import/Gate/NAND2.sc	\
		import/Gate/NOR2.sc	\
		import/Gate/NOT1.sc	\
		import/Gate/OR2.sc	\
		import/Gate/XOR2.sc	\
		import/Gate/GatesLib.sc

ORIG	=	Makefile		\
		simple/Makefile		\
		simple/README		\
		simple/Adder.sc		\
		simple/Behaviors.sc	\
		simple/BitVectors.sc	\
		simple/Callback.sc	\
		simple/DataTypes.sc	\
		simple/Exception.sc	\
		simple/FSM.sc		\
		simple/HelloWorld.sc	\
		simple/Notes.sc		\
		simple/Pipeline.sc	\
		simple/Pipeline2.sc	\
		simple/Timing.sc	\
		simple/Handshaking1.sc	\
		simple/Handshaking2.sc	\
		import/Makefile		\
		import/README		\
		import/Testbench.sc	\
		import/Adder/ADD08_1.sc	\
		import/Adder/ADD08_2.sc	\
		import/Adder/ADD16_1.sc	\
		import/Adder/ADD16_2.sc	\
		import/Adder/ADD32_1.sc	\
		import/Adder/ADD32_2.sc	\
		import/Adder/AddLib.sc	\
		import/Gate/AND2.sc	\
		import/Gate/NAND2.sc	\
		import/Gate/NOR2.sc	\
		import/Gate/NOT1.sc	\
		import/Gate/OR2.sc	\
		import/Gate/XOR2.sc	\
		import/Gate/GatesLib.sc

EXAMPLE	=	simple			\
		import


# --- production rules

all:
#	we don't go into the subdirectories

test:
	set -e;								\
	. ../bin/setup.sh;						\
	for example in $(EXAMPLE); do					\
		echo "Running example(s) in directory $$example...";	\
		cd $$example;						\
		$(MAKE) clean;						\
		$(MAKE);						\
		$(MAKE) test;						\
		cd ..;							\
	done;								\
	echo "All examples completed successfully."

cleanall:	clean
	set -e;								\
	for example in $(EXAMPLE); do					\
		cd $$example;						\
		$(MAKE) clean;						\
		cd ..;							\
	done


# --- service rules

clean:
	-$(RM) *.bak *.BAK

dist:
	for file in $(DIST); do echo $(DISTPREFIX)/$$file >>$(DISTLIST); done

orig:
	for file in $(ORIG); do echo $(ORIGPREFIX)/$$file >>$(ORIGLIST); done


# --- EOF Makefile ---
