# Makefile.in for test of yash
# (C) 2007-2012 magicant
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

.POSIX:
.SUFFIXES: .c .h .d .o

@MAKE_SHELL@
topdir = ..
subdir = tests

CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LDLIBS = @LDLIBS@
SOURCES = checkfg.c invoke.c resetsig.c
TEST_SOURCES = *.tst *.out *.err *.oux *.erx *.t
TARGET = @TARGET@
TESTERS = checkfg invoke resetsig
TESTEE = $(topdir)/$(TARGET)
BYPRODUCTS = $(SOURCES:.c=.o) $(TESTERS) test.log *.dSYM

test test-all: tester testee
	@./resetsig $(SHELL) ./run-test.sh
test-posix:
	@$(MAKE) TEST_ITEMS='*.p.tst' test
test-yash:
	@$(MAKE) TEST_ITEMS='*.y.tst' test

tester: $(TESTERS)
$(TESTERS):
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $@.c $(LDLIBS)
testee:
	@+if [ x'$(TESTEE)' = x'$(topdir)/$(TARGET)' ]; then \
		(cd $(topdir) && $(MAKE) $(TARGET)); \
	fi

.c.o:
	@rm -f $@
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

DISTFILES = $(SOURCES) $(SOURCES:.c=.d) Makefile.in run-test.sh
distfiles: makedeps $(DISTFILES)
copy-distfiles: distfiles
	mkdir -p $(topdir)/$(DISTTARGETDIR)
	cp $(DISTFILES) $(TEST_SOURCES) $(topdir)/$(DISTTARGETDIR)
makedeps: _PHONY
	@(cd $(topdir) && $(MAKE) $(TARGET))
	$(topdir)/$(TARGET) $(topdir)/makedeps.yash $(SOURCES)

mostlyclean:
	rm -fr $(BYPRODUCTS)
clean: mostlyclean
distclean: clean
	rm -fr Makefile
maintainer-clean: distclean
	rm -fr $(SOURCES:.c=.d)

Makefile: Makefile.in $(topdir)/config.status
	@+(cd $(topdir) && $(MAKE) config.status)
	@(cd $(topdir) && $(SHELL) config.status $(subdir)/$@)

.PHONY: test test-all test-posix test-yash tester testee distfiles copy-distfiles makedeps mostlyclean clean distclean maintainer-clean
_PHONY:

@MAKE_INCLUDE@ checkfg.d
@MAKE_INCLUDE@ invoke.d
@MAKE_INCLUDE@ resetsig.d
