#
# File:		makefile.unx
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for libhytext.a, a library for writing hypertext
# applications

GUISUFFIX=_ol
CC = gcc-2.1

# Replace X include/lib directories with your own, e.g. -I/usr/openwin/include ...
# XINCLUDE=-I/aiai/packages/prokappa2.0/X/usr/include -I/aiai/packages/X.V11R5/include
# XLIB=-L/aiai/packages/X.V11R5/lib -L/aiai/packages/prokappa2.0/X/usr/lib
XINCLUDE=-I/aiai/packages/motif1.2.1/motif/include -I/aiai/packages/X.V11R5/include
XLIB=-L/aiai/packages/motif1.2.1/motif/sun4/lib -L/aiai/packages/X.V11R5/lib

WXDIR = ../../..
WXINC = $(WXDIR)/include
WXLIB = $(WXDIR)/lib/libwx$(GUISUFFIX).a

INC = -I$(WXDIR)/include/base -I$(WXDIR)/include/x

HYDIR = $(WXDIR)/utils/hytext
HYINC = $(HYDIR)/src
HYLIB = $(HYDIR)/lib/libhytext$(GUISUFFIX).a
OBJDIR = $(HYDIR)/src/objects$(GUISUFFIX)
DOCUTILSDIR = $(WXDIR)/utils/tex2rtf/src

SOURCES = hytext.cc
HEADERS = hytext.h
OBJECTS = $(OBJDIR)/hytext.o

# Default is to use XView
DEBUG = -ggdb
WARN = -Wall
OPT = -O
GUI = -Dwx_xview
XVIEW_LINK = $(WXDIR)/src/x/xview_objects/sb_scrol.o

CPPFLAGS = $(XINCLUDE) $(INC) -I$(WXDIR)/dummy $(GUI) $(DEBUG) $(WARN)
LDFLAGS =  $(XLIB) -L$(WXDIR)/lib
LDLIBS = -lwx_ol -lxview -lolgx -lX11 -lm -lg++

all:	$(OBJDIR) $(HYLIB)

.SUFFIXES:

motif:
	cd $(WXDIR)/src/x; make -f makefile.unx motif OPT='$(OPT)'
	make -f makefile.unx GUI=-Dwx_motif OPT='$(OPT)' GUISUFFIX=_motif LDLIBS='-lwx_motif -lXm -lXt -lX11 -lm -lg++' XVIEW_LINK=

xview:
	cd $(WXDIR)/src/x; make -f makefile.unx xview OPT='$(OPT)'
	make -f makefile.unx GUI=-Dwx_xview OPT='$(OPT)' GUISUFFIX=_ol

hp:
	make -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='' WARN='-w' \
           XINCLUDE='-I/usr/include/Motif1.2 -I/usr/include/X11R5' \
           XLIB='-L/usr/lib/Motif1.2 -L/usr/lib/X11R5' \
           XVIEW_LINK='' \
           LDLIBS='-lwx_hp -lXm -lXt -lX11 -lm'

$(HYLIB): $(OBJECTS)
	rm -f $@
	ar rv $@ $(OBJECTS)
	ranlib $@

$(OBJECTS):     $(HYINC)/hytext.h

$(OBJDIR):
	mkdir $(OBJDIR)

$(OBJDIR)/hytext.o:	hytext.cc
	$(CC) -c $(CPPFLAGS) -o $@ hytext.cc

docs:	ps xlp
ps:	$(HYDIR)/docs/manual.ps
xlp:	$(HYDIR)/docs/hytext.xlp
html:	$(HYDIR)/docs/hytext_contents.html

$(HYDIR)/docs/hytext.xlp:	$(HYDIR)/docs/classes.tex $(HYDIR)/docs/manual.tex
	tex2rtf /project/2/gryphon/jacs/wx/utils/hytext/docs/manual.tex $(HYDIR)/docs/tmp.xlp -xlp -twice
	sed -e "s/WXHELPCONTENTS/hyText Manual/g" < $(HYDIR)/docs/tmp.xlp > $(HYDIR)/docs/hytext.xlp
	/bin/rm -f $(HYDIR)/docs/tmp.xlp

$(HYDIR)/docs/hytext_contents.html:	$(HYDIR)/docs/classes.tex $(HYDIR)/docs/manual.tex
	cd $(HYDIR)/docs
	tex2rtf /project/2/gryphon/jacs/wx/utils/hytext/docs/manual.tex /project/2/gryphon/jacs/wx/utils/hytext/docs/hytext -twice -html
	/bin/cp ../docs/*.html /user/11/jacs/html/hytext
	/bin/rm -f ../docs/*.html

$(HYDIR)/docs/manual.dvi:	$(HYDIR)/docs/manual.tex $(HYDIR)/docs/classes.tex
	cd $(HYDIR)/docs; latex manual; latex manual; makeindex manual; latex manual; \

$(HYDIR)/docs/manual.ps:	$(HYDIR)/docs/manual.dvi
	cd $(HYDIR)/docs; dvips -f -r < manual.dvi > manual.ps

cleaneach:
	rm -f $(OBJECTS) $(HYDIR)/lib/libhytext$(GUISUFFIX).a core

clean_motif:
	make -f makefile.unx GUISUFFIX=_motif cleaneach 

clean_ol:
	make -f makefile.unx GUISUFFIX=_ol cleaneach 

clean_hp:
	make -f makefile.unx GUISUFFIX=_hp cleaneach 
