#
# File:		makefile.unx
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for tree library and example (UNIX).
# Change the WXDIR directory, and CPPFLAGS and LDFLAGS, for your system.

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
OBJDIR=objects$(GUISUFFIX)

TREEDIR = $(WXDIR)/utils/wxtree
TREEINC = $(TREEDIR)/src
TREELIB = $(TREEDIR)/lib/libwxtree$(GUISUFFIX).a

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

TESTOBJECTS = $(OBJDIR)/test.o
TESTPROGRAM = $(TREEDIR)/src/test$(GUISUFFIX)

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

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

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

.SUFFIXES:

all:	$(OBJDIR) $(TREELIB)

demo:   $(TESTPROGRAM)

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

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

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

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

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

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

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

hp:
	make -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='-g' OPT='' 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 -lwxtree_hp -lXm -lXt -lX11 -lm'

$(OBJDIR):
	mkdir $(OBJDIR)

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

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

$(OBJDIR)/test.o:        test.cc test.h wxtree.h
	$(CC) -c $(CPPFLAGS) -o $@ test.cc

docs:	ps xlp
ps:	$(TREEDIR)/docs/manual.ps
xlp:	$(TREEDIR)/docs/wxtree.xlp
html:	$(TREEDIR)/docs/wxtree_contents.html

$(TREEDIR)/docs/wxtree.xlp:	$(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex
	cd ../docs; tex2rtf manual.tex tmp.xlp -xlp -twice
	sed -e "s/WXHELPCONTENTS/wxTree Manual/g" < $(TREEDIR)/docs/tmp.xlp > $(TREEDIR)/docs/wxtree.xlp
	/bin/rm -f $(TREEDIR)/docs/tmp.xlp

$(TREEDIR)/docs/wxtree_contents.html:	$(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex
	cd ../docs; tex2rtf manual.tex wxtree.html -html -twice
	/bin/cp ../docs/*.html /user/11/jacs/html/wxtree
	/bin/rm ../docs/*.html

$(TREEDIR)/docs/manual.dvi:	$(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex
	cd $(TREEDIR)/docs; latex manual; latex manual; makeindex manual; bibtex manual; latex manual; latex manual

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

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

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

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

cleanany:
	rm -f $(OBJECTS) $(OBJDIR)/*.o test$(GUISUFFIX) $(TREELIB) core

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

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

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