#
# File:		makefile.unx
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for wxHelp
# To make wxHelp and test (to test out wxHelp), type
#
# make -f makefile.unx all test

CC = gcc-2.1
GUISUFFIX=_ol

# 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$(WXINC)/base -I$(WXINC)/x

WXHELPDIR = $(WXDIR)/utils/wxhelp
WXHELPINC = $(WXHELPDIR)/src
DOCDIR = $(WXHELPDIR)/docs
OBJDIR = objects$(GUISUFFIX)

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

DOCUTILSDIR = $(WXDIR)/utils/tex2rtf/src

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

CPPFLAGS = $(XINCLUDE) $(INC) -I$(HYINC) $(GUI) $(DEBUG) $(WARN)
LDFLAGS = $(XLIB) -L$(WXDIR)/lib -L$(HYDIR)/lib -L$(WXHELPDIR)/lib
LDLIBS = -lhytext_ol -lwx_ol -lxview -lolgx -lX11 -lm -lg++
# LDLIBS = -lhytext_motif -lwx_motif -lXm -lXt -lX11 -lm -lg++

# Make wxHelp only
all:	$(OBJDIR) wxhelp$(GUISUFFIX)

.SUFFIXES:

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

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

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 -lhytext_hp -lXm -lXt -lX11 -lm'

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

wxhelp$(GUISUFFIX):		$(OBJDIR)/wxhelp.o $(HYLIB) $(WXLIB)
	$(CC) $(CPPFLAGS) $(LDFLAGS) -o wxhelp$(GUISUFFIX) $(OBJDIR)/wxhelp.o $(XVIEW_LINK) $(LDLIBS)

$(OBJDIR):
	mkdir $(OBJDIR)

# A demo app calling wxhelp
$(OBJDIR)/test.o:	test.cc $(WXINC)/wx_help.h
	$(CC) -c $(CPPFLAGS) -o $@ test.cc

test$(GUISUFFIX):		$(OBJDIR)/test.o $(WXLIB)
	$(CC) $(CPPFLAGS) $(LDFLAGS) -o test$(GUISUFFIX) $(XVIEW_LINK) $(OBJDIR)/test.o $(LDLIBS)

wx:
	cd $(WXDIR)/src/x; make -f makefile.unx

hylib:
	cd $(HYDIR)/src; \
	make -f makefile.unx DEBUG=

docs:	ps xlp
ps:	$(DOCDIR)/manual.ps
xlp:	$(DOCDIR)/wxhelp.xlp
html:	manualhtml tex2rtfhtml
manualhtml:	$(DOCDIR)/wxhelp_contents.html
tex2rtfhtml:	$(DOCDIR)/tex2rtf_contents.html

$(WXHELPDIR)/docs/wxhelp.xlp:	$(WXHELPDIR)/docs/manual.tex
	$(DOCUTILSDIR)/tex2rtf_ol $(WXHELPDIR)/docs/manual.tex $(WXHELPDIR)/docs/tmp.xlp -twice -xlp
	sed -e "s/WXHELPCONTENTS/wxHelp Manual/g" < $(WXHELPDIR)/docs/tmp.xlp > $(WXHELPDIR)/docs/wxhelp.xlp
	/bin/rm -f $(WXHELPDIR)/docs/tmp.xlp

$(WXHELPDIR)/docs/manual.dvi:	$(WXHELPDIR)/docs/manual.tex
	cd $(WXHELPDIR)/docs; latex manual; latex manual; makeindex manual; latex manual

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

$(WXHELPDIR)/docs/wxhelp_contents.html:	$(WXHELPDIR)/docs/manual.tex
	$(DOCUTILSDIR)/tex2rtf $(WXHELPDIR)/docs/manual.tex $(WXHELPDIR)/docs/wxhelp.html -twice -html
	/bin/cp ../docs/*.html /user/11/jacs/html/wxhelp
	/bin/rm -f ../docs/*.html

cleaneach:
	rm -f $(OBJDIR)/*.o test$(GUISUFFIX) wxhelp$(GUISUFFIX) 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 


