#
# File:		makefile.unx
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for image 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
DOCUTILSDIR = $(WXDIR)/utils/tex2rtf/src

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

TOOLBARDIR = $(WXDIR)/utils/toolbar
TOOLBARLIB = $(TOOLBARDIR)/lib/libtbar$(GUISUFFIX).a
OBJDIR = objects$(GUISUFFIX)
OBJECTS = $(OBJDIR)/wx_tbar.o
TESTOBJECTS = $(OBJDIR)/test.o
TESTPROGRAM = $(TOOLBARDIR)/src/test$(GUISUFFIX)

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

CPPFLAGS = $(XINCLUDE) $(INC) -I$(WXDIR)/dummy $(GUI) $(DEBUG) $(WARN) $(OPT)
LDFLAGS =  $(XLIB) -L$(TOOLBARDIR)/lib -L/aiai/packages/prokappa2.0/X/usr/lib -L/aiai/packages/X.V11R5/lib -L$(WXDIR)/lib
LDLIBS = -ltbar_ol -lwx_ol -lxview -lolgx -lX11 -lm -lg++

all:	$(OBJDIR) $(TOOLBARLIB)

demo:	$(TESTPROGRAM)

.SUFFIXES:

# Comment this out if 'say' doesn't speak on your system, or make it beep perhaps!
done:
	say dun

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

motif:
	cd $(WXDIR)/src/x; make -f makefile.unx motif OPT='$(OPT)'
	make -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='-ltbar_motif -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)'

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

motifdemo:
	cd $(WXDIR)/src/x; make -f makefile.unx motif OPT='$(OPT)'
	make -f makefile.unx all demo GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='-ltbar_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 demo GUI=-Dwx_xview OPT='$(OPT)'

$(OBJDIR):
	mkdir $(OBJDIR)

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

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

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

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

docs:	ps xlp
ps:	$(TOOLBARDIR)/docs/manual.ps
xlp:	$(TOOLBARDIR)/docs/toolbar.xlp
html:	$(TOOLBARDIR)/docs/toolbar_contents.html

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

$(TOOLBARDIR)/docs/toolbar_contents.html:	$(TOOLBARDIR)/docs/manual.tex $(TOOLBARDIR)/docs/classes.tex
	cd ../docs; tex2rtf manual.tex toolbar.html -twice -html
	/bin/cp ../docs/*.html /user/11/jacs/html/toolbar
	/bin/rm -f ../docs/*.html

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

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

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

