#        file: Makefile
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2018)
#     license: GNU General Public License, version 3
# description: build shellia debian package

SHARE    = $(DESTDIR)/usr/share/shellia
TESTS    = $(shell /bin/ls test.*)
EXAMPLES = $(shell /bin/ls example.* | grep -v "tmp")
HELLO    = $(shell /bin/ls hello_world*)
LIBS     = $(shell /bin/ls ia*)

all: shellia

clean:		
	@# to clean debian files, run make clean from parent directory
	@rm -f shellia.?
	@rm -f example*.tmp.* hello_world*.tmp.*
	@rm -f res exp r4s res.org

install: $(LIBS)
	mkdir -p $(SHARE); \
	for i in $^; do \
		install -o root -g root -m 0755 $$i $(SHARE)/; \
	done

shellia: shellia-tested-stamp shellia.1 shellia.3 shellia.7

shellia-tested-stamp: run_tests $(LIBS) $(TESTS) $(EXAMPLES) $(HELLO)
	rm -f $@
	./run_tests && touch $@

shellia.1: shellia-1.rst
	rst2man $< $@

shellia.3: shellia-3.rst
	rst2man $< $@

shellia.7: shellia-7.rst
	rst2man $< $@

dbg:
	@echo "TESTS=<$(TESTS)>"
	@echo "EXAMPLES=<$(EXAMPLES)>"
	@echo "HELLO=<$(HELLO)>"
