VL=2.15
#	Makefile for WorldWideWeb    Line Mode browser (www)
#
#	(c) CERN 1990, 1991 -- see Copyright.html for conditions
#
CC=gcc -s -O2 -Wall -DOS2
# SHELL=C:\\bin\\ksh
LMD=Defaults
CMN=../Library/
DEFAULTS=/Defaults

CFLAGS=-I$(CMN) -I.

USELIBDIR=..
OBJ=.

WWWLIB=-L$(USELIBDIR) -llibwww -lsocket

OBJS=GridText.o HTBrowse.o DefaultStyles.o

OBJS-CYR=HTBrowse-cyr.o GridText-cyr.o DefaultStyles-cyr.o a_stdio.o

# Final main product
PROD=www

SOURCES=HTBrowse.c HTBrowse.h GridText.c GridText.h \
	GridStyle.c GridStyle.html GridStyle.h \
	HTFont.h Version.make \
	DefaultStyles.c	CommonMakefile \
 	a_stdio.g a_stdio.h

DISTRIBUTION=DefaultStyles.c.classic DefaultStyles.c.modern

# a_stdio.g a_stdio.h were added to support -DCYRILLIC

INCLUDES=GridStyle.h a_stdio.h

# a_stdio.h was added to support -DCYRILLIC

# Bug: This path, if relative, is taken relative to the directory
# in which this makefile is, not the pwd.  This screws up the
# recursive invocation

# This is now done by cat in WWW/All/Makefile
# include $(ABS)Version.make

.html.h:
	www -w90 -na -to text/x-c $*.html > $*.h

.c.o:
	$(CC) -c $(CFLAGS) -DVL=\"$(VL)\" $<

$(PROD).exe: $(OBJS) $(USELIBDIR)/libwww.a
	$(CC) -o $(PROD).exe $(OBJS) $(LFLAGS) $(WWWLIB) $(WAISLIB) $(MATHLIB)

GridStyle.html: GridStyle.h
	www -w90 -na -to text/x-c GridStyle.html > GridStyle.h

cyrillic: $(OBJS-CYR) $(USELIBDIR)/libwww.a
	$(CC) -o $(PROD)-c.exe $(OBJS) a_stdio.o $(LFLAGS) $(WWWLIB) \
	$(WAISLIB) $(MATHLIB)
	
$(USELIBDIR)/libwww.a:
	@echo You must get and make the WWWLibrary product first!
	(cd ../Library && make)

lib:
	(cd ../Library && make)

inc: $(INLCUDES)
	echo Line mode browser include files up to date from html's.
	(cd ../Library && make inc)

#	Make a copy of the binary and documentation on this machine
install: $(PROD).exe
#	cp $(PROD).exe /bin
#	cp $(DEFAULTS)/*.html /usr/local/lib/WWW

#	Link system to the binary and documentation in this tree
uninstall:
#	rm bin/$(PROD).exe
#	rm -r /usr/local/lib/WWW

#	Clean up everything generatable except final products
#	Including obj directory UNLESS there is anything else in it
clean:
	rm .created *.o
	-rmdir $(OBJ)

#	Clean up everything generatable including final products

cleanall: clean
	rm $(PROD).exe

# Compiling the Objects (Dependenies incomplete)

HTBrowse.o: HTBrowse.c GridText.h Version.make $(CMN)HTUtils.h $(CMN)HTAccess.h

GridText.o: GridText.c GridText.h GridStyle.h $(CMN)HTAnchor.h $(CMN)HTStyle.h

DefaultStyles.o: DefaultStyles.c $(CMN)HTStyle.h

# the cyrillic version
HTBrowse-cyr.o: HTBrowse.c GridText.h \
Version.make $(CMN)HTUtils.h $(CMN)HTAccess.h
	$(CC) -c -o $@ $(CFLAGS) -DCYRILLIC -DVL=\"$(VL)\" HTBrowse.c

GridText-cyr.o: GridText.c GridText.h \
GridStyle.h $(CMN)HTAnchor.h $(CMN)HTStyle.h
	$(CC) -c -o $@ $(CFLAGS) -DCYRILLIC GridText.c

DefaultStyles-cyr.o: DefaultStyles.c $(CMN)HTStyle.h
	$(CC) -c -o $@ $(CFLAGS) -DCYRILLIC DefaultStyles.c

a_stdio.o: a_stdio.g a_stdio.h
#	$(CC) -c -o $@ $(CFLAGS) -xc a_stdio.g

#		Hypertext supplied in text format
#		---------------------------------

README.txt: ../README.html
	www -n -p66 http://info.cern.ch/hypertext/README.html \
	>README.txt

Copyright.txt: ../Copyright.html
	www -n -p66 http://info.cern.ch/hypertext/Copyright.html \
	>Copyright.txt
#	Line Mode Manual

QUICKGUIDE=\
$(LMD)/QuickGuide.html $(LMD)/Commands.html \
$(LMD)/SourceExamples.html $(LMD)/CommandLine.html \
$(LMD)/Shortcuts.html $(LMD)/VMS_Shortcuts.html \
$(LMD)/Installation.html $(LMD)/Installation_VMS.html \
$(LMD)/Installation_VMS_NewTCP.html $(LMD)/Distribution.html \
$(LMD)/Porting.html $(LMD)/MachineTypes.html \
$(LMD)/InstallNotSU.html $(LMD)/Path.html \
$(LMD)/LoginScript.html $(LMD)/Customisation.html \
$(LMD)/EnvVariables.html $(LMD)/GlobalV.html \
$(LMD)/NewsServer.html $(LMD)/Bugs.html $(LMD)/Features.html

$(LMD)/line-mode-guide.txt: $(QUICKGUIDE)
	-rm $@
	for i in $(QUICKGUIDE) ; do www -n -na -p66 $$i >> $@; done
