SHELL=/bin/sh
BASE=../..
include $(BASE)/Makedefs.uni

########################################################
# Manage the construction of the UniDoc program        #
########################################################

# Some variables to reduce typing later...
#
SRCS   := $(wildcard ./*.icn)
UFILES := $(patsubst %.icn, %.u, $(SRCS))

# The first target is the default target.
#    The "@"'s tell make to suppress printing the command before
#    running it.
#

default: UniDoc$(EXE)

help:
	@echo "You may make: "
	@echo ""
	@echo "UniDoc ufiles depends doc clean list print printall"

.PHONY: ufiles deps depends doc docs clean list print printall

# This is an implicit rule that tells how to build ".u" files from ".icn"
#    files (saves having to enter a bunch of separate rules for each
#    sxbource file).  Make has predefined implicit rules for most of the
#    commonly used suffixes.
#
%.u:	%.icn
	$(UNICON) $(UFLAGS) -c $?

UniDoc$(EXE): $(UFILES)
	$(UNICON) -o UniDoc $(UFILES)
	$(CP) UniDoc$(EXE) $(BIN)
	@date >.lastbuild        # remembers when things were last built.

ufiles: $(SRCS)
	$(UNICON) $(UFLAGS) -c $?

doc docs:	UniDoc
	./buildDocs.sh

deps depends:
	unidep $(SRCS)

# Clean up the directory.
#
clean:
	$(RM) UniDoc$(EXE) *.u uniclass.dir uniclass.pag uniclass.db *~


# List all source files that have been modified since the last build.
#
list: .lastbuild

.lastbuild: $(SRCS)
	@echo "Out-of-date files:" $?

# Print all the source files that have modified since the last printing.
#
print: .lastprint

# Note the command that is continued across multiple lines - you *still*
#    need the semicolon's however!
#
.lastprint: $(SRCS)
	@for i in $?; do  \
	    prn -1 $$i;   \
	done
	@date >.lastprint

# Print all the source files.
#
printall:
	@for i in $(SRCS); do     \
	    prn -1 $$i;           \
	 done
	@date >.lastprint
### Autogenerated dependencies
./UniAll.u : ./UniAll.icn ./UniFile.u ./UniForm.u ./UniToken.u
./UniDoc.u : ./UniDoc.icn ./UniAll.u ./UniHTML.u
./UniFile.u : ./UniFile.icn ./UniToken.u
./UniForm.u : ./UniForm.icn
./UniHTML.u : ./UniHTML.icn ./UniAll.u
./UniToken.u : ./UniToken.icn
