# Copyright (c) 2000-2001 by Wayne C. Gramlich.
# All rights reserved.

# Permission to use, copy, modify, distribute, and sell this software
# for any purpose is hereby granted without fee provided that the above
# copyright notice and this permission are retained.  The author makes
# no representations about the suitability of this software for any purpose.
# It is provided "as is" without express or implied warranty.

ROOT = ..

include $(ROOT)/Makefile_common.mk
include $(ROOT)/Makefile_private.mk

STIPPLE_DIRECTORY = $(ROOT)/stipple
STC_DIRECTORY = $(STIPPLE_DIRECTORY)/stc
NSTC_DIRECTORY = $(STIPPLE_DIRECTORY)/nstc
LIBSTIPPLE_DIRECTORY = $(STIPPLE_DIRECTORY)/libstipple

STC = $(STC_DIRECTORY)/$(PLATFORM)/stc
STL = $(STC_DIRECTORY)/$(PLATFORM)/stl
NSTC = $(NSTC_DIRECTORY)/$(PLATFORM)/nstc

STC_INCLUDES =					\
	-I $(LIBSTIPPLE_DIRECTORY)/$(PLATFORM)	\
	-I $(PLATFORM)
STC_FLAGS = $(STC_OPTIONS) $(STC_INCLUDES)

OS_LDOPTS_X11 = -L/usr/X11/lib

PARALLEL_SERVER_BASES =			\
	parallel_server
PARALLEL_SERVER_SOURCES = ${PARALLEL_SERVER_BASES:%=%.sts}
PARALLEL_SERVER_INTERFACES = ${PARALLEL_SERVER_BASES:%=$(PLATFORM)/%.sti}
PARALLEL_SERVER_OBJECTS = ${PARALLEL_SERVER_BASES:%=$(PLATFORM)/%.o}
PARALLEL_SERVER = $(PLATFORM)/parallel_server

STS_BASES =				\
	${PARALLEL_SERVER_BASES}

STS_SOURCES = 				\
	${PARALLEL_SERVER_SOURCES}

STS_HTMLS = ${STS_SOURCES:%.sts=%.html}


INTERFACES =				\
	${PARALLEL_SERVER_INTERFACES}
OBJECTS =				\
	${PARALLEL_SERVER_OBJECTS}

PROGRAMS =				\
	$(PARALLEL_SERVER)

OTHER_HTMLS =				\
	index.html
HTMLS =					\
	${STS_HTMLS}			\
	${OTHER_HTMLS}			\
	source.html

OTHER_SOURCES =				\
	Makefile
SOURCES =				\
	${STS_SOURCES}			\
	${OTHER_SOURCES}		\
	${OTHER_HTMLS}

COPY_LIST =				\
	${SOURCES}			\
	${STS_HTMLS}			\
	source.html

.PHONY: all clean copy spell

# Some targets:

all: $(PLATFORM) $(WAIT) ${SOURCES} $(WAIT) ${PROGRAMS} $(WAIT) source.html

$(PARALLEL_SERVER): ${PARALLEL_SERVER_INTERFACES} $(WAIT)		\
    ${PARALLEL_SERVER_OBJECTS}
	$(STL) -o $@ -E $(PLATFORM) 					\
	    ${PARALLEL_SERVER_INTERFACES} ${PARALLEL_SERVER_OBJECTS}

clean:
	rm -rf $(PLATFORM) ${STS_HTMLS} source.html STDB
	$(CLEAN)

$(PLATFORM):
	rm -rf $@
	mkdir $@

$(NSTC):
	$(MAKE) -C $(NTSC_DIR)

source.html: Makefile $(NSTC) $(WAIT) ${STS_HTMLS}
	@echo -n "Generating $@..."
	@rm -f $@
	@echo '<HTML>' > $@
	@echo '<Head>' >> $@
	@echo '<Title>Parallel Port Server Source Files</Title>' >> $@
	@echo '</Head>' >> $@
	@echo '<Body>' >> $@
	@echo '<P>These are the source files for the' >> $@
	@echo '<A HRef="index.html">Parallel Port Server Program</A>.</P>' >> $@
	@echo '<H1>' >> $@
	@echo 'Parallel Port Server Source Files' >> $@
	@echo '</H1>' >> $@
	@echo '<P>The following extracted documentation is available:</P>'>> $@
	@echo '<UL>' >> $@
	@for i in ${STS_BASES} ; do					\
		echo "  <LI><A HRef='$$i.html'>$$i</A></LI>" >> $@ ;	\
		done
	@echo '</UL>' >> $@
	@echo '<P>The following source files are available:</P>' >> $@
	@echo '<UL>' >> $@
	@for i in `ls Makefile ${STS_SOURCES} | sort`; do \
		echo "  <LI><A HRef='$$i'>$$i</A></LI>" >> $@ ;		\
		done
	@echo '</UL>' >> $@
	@echo '<HR>' >> $@
	@echo '<Address>' >> $@
	@echo '<A HRef="../../copyright.html">' >> $@
	@echo 'Copyright</A> (c) 2000-2001 by' >> $@
	@echo '<A HRef="../../gramlich.html">' >> $@
	@echo 'Wayne Gramlich</A> All rights reserved.' >> $@
	@echo '</Address>' >> $@
	@echo '</Body>' >> $@
	@echo '</HTML>' >> $@
	@echo "Done"

spell:



