GENCONFIG=	$(GATED_TOOLS_PATH)/scripts/gen_config
TESTG=		$(GATED_TOOLS_PATH)/scripts/testg
THEHOST=	`hostname | sed -e 's/\([^.]\)\..*/\1/'`

TEST_FLAGS=	-q -a -M

AUTO1=		martians-2.auto
AUTO2=		martians-3.auto
AUTO3=		martians-4.auto
AUTO=		$(AUTO1) $(AUTO2) $(AUTO3)

CONFIG=		martians.cfg

TESTFILES=gated.conf.martians.cannes.1.1 \
expected.martians.cannes.1.1 \
gated.conf.martians.mole.1.1 \
expected.martians.mole.1.1 \
gated.conf.martians.cannes.2.1 \
expected.martians.cannes.2.1 \
gated.conf.martians.mole.2.1 \
expected.martians.mole.2.1 \
gated.conf.martians.cannes.3.1 \
expected.martians.cannes.3.1 \
gated.conf.martians.mole.3.1 \
expected.martians.mole.3.1 \
gated.conf.martians.cannes.4.1 \
expected.martians.cannes.4.1 \
gated.conf.martians.mole.4.1 \
expected.martians.mole.4.1 \
gated.conf.martians.idrp.5.1 \
expected.martians.idrp.5.1 \
gated.conf.martians.cannes.5.1 \
expected.martians.cannes.5.1 \
gated.conf.martians.mole.5.1 \
expected.martians.mole.5.1 \
gated.conf.martians.idrp.6.1 \
gated.conf.martians.cannes.6.1 \
expected.martians.cannes.6.1 \
gated.conf.martians.mole.6.1 \
expected.martians.mole.6.1 \
gated.conf.martians.idrp.7.1 \
expected.martians.idrp.7.1 \
gated.conf.martians.mole.7.1 \
expected.martians.mole.7.1 \
gated.conf.martians.obelix.7.1 \
expected.martians.obelix.7.1 \
gated.conf.martians.cannes.7.1 \
expected.martians.cannes.7.1 \
gated.conf.martians.idrp.8.1 \
expected.martians.idrp.8.1 \
gated.conf.martians.mole.8.1 \
expected.martians.mole.8.1 \
gated.conf.martians.obelix.8.1 \
expected.martians.obelix.8.1 \
gated.conf.martians.cannes.8.1 \
expected.martians.cannes.8.1


$(TESTFILES):	$(CONFIG)
	$(GENCONFIG) $(CONFIG)

config: $(TESTFILES)

test: test_done


test_done: config $(AUTO) 
	@rm -f test_done
	# no mole or obelix in 2 machine test
	@( THEHOST=$(THEHOST); export THEHOST; \
		if [ "$$THEHOST" = "mole" -o "$$THEHOST" = "cannes" ]; \
			then $(TESTG) $(TEST_FLAGS) < $(AUTO1); \
		else echo "Skipping, $$THEHOST not a part of test."; \
		fi )
	# no mole in 3 machine test
	@( THEHOST=$(THEHOST); export THEHOST; \
		if [ "$$THEHOST" = "mole" -o "$$THEHOST" = "cannes" -o \
		    "$$THEHOST" = "idrp" ]; \
			then $(TESTG) $(TEST_FLAGS) < $(AUTO2); \
		else echo "Skipping, $$THEHOST not a part of test."; \
		fi )
	@( THEHOST=$(THEHOST); export THEHOST; \
		if [ "$$THEHOST" = "mole" -o "$$THEHOST" = "idrp" -o \
		    "$$THEHOST" = "obelix" -o "$$THEHOST" = "cannes" ]; \
			then $(TESTG) $(TEST_FLAGS) < $(AUTO3); \
		else echo "Skipping, $$THEHOST not a part of test."; \
		fi )
	@touch test_done

clean:
	rm -f expected.* gated.conf.* test_done

cleantest:
	rm -f test_done
