# Makefile.in for test of yash
# (C) 2007-2010 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

CC = @CC@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LDLIBS = @LDLIBS@
SOURCES = invoke.c resetsig.c
TEST_SOURCES = *.tst *.out *.err *.oux *.erx *.t

TESTEE = ../yash
BYPRODUCTS = invoke.o invoke resetsig.o resetsig test.log *.dSYM

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

testee:
	@+if [ x'$(TESTEE)' = x'../yash' ]; then cd .. && $(MAKE) yash; fi

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

DISTCONTENTS = $(SOURCES) $(SOURCES:.c=.d) $(TEST_SOURCES) Makefile.in run-test.sh
# "distcontents" depends on object files to ensure all *.d files up-to-date
distcontents: $(DISTCONTENTS) invoke resetsig
copy-distcontents: distcontents
	mkdir -p $(DISTTARGETDIR)
	cp $(DISTCONTENTS) $(DISTTARGETDIR)

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

.PHONY: test test-all test-posix test-yash testee distcontents copy-distcontents clean distclean maintainer-clean

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