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

CC = gcc-2.1

#
# If your compiler cannnot understand both C++/C, it can be
# useful to have separate commands, since sb_scrol.c is pure 'C',  not C++
# So, fixmake.sh can patch this line
# Typical: CC=g++ , CCSB=gcc
#          CC=cl386 /Tp, CCSB=cl386
#
# (Used only for XView, file sb_scrol.c)
#
CCSB = $(CC)

# Options for ar archiver
# AROPTIONS = crs # For IRIX. Also, comment out ranlib line.
AROPTIONS = ruv

# 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

# Replace this with your own path if necessary
WXDIR = ../..

# Generic from here onwards
WXINC = $(WXDIR)/include/x
WXBASEINC = $(WXDIR)/include/base
WXLIB = $(WXDIR)/lib/libwx$(GUISUFFIX).a
OBJDIR = objects$(GUISUFFIX)

INC = -I$(WXBASEINC) -I$(WXINC)

OPTIONS=

# Compiler flags.
DEBUG = -ggdb
WARN = -Wall
GUI = -Dwx_xview
# OPT = -O
OPT =

# May need to add -D_HPUX_SOURCE_ for HPUX
CPPFLAGS =  $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUG) $(WARN) $(OPT)
CFLAGS =
LDFLAGS =  $(XLIB) -L$(WXDIR)/lib

OBJECTS = $(OBJDIR)/wx_main.o $(OBJDIR)/wx_win.o $(OBJDIR)/wx_frame.o\
 $(OBJDIR)/wx_canvs.o $(OBJDIR)/wx_panel.o $(OBJDIR)/wx_item.o\
 $(OBJDIR)/wx_clipb.o $(OBJDIR)/wx_text.o $(OBJDIR)/wx_utils.o $(OBJDIR)/wx_mf.o\
 $(OBJDIR)/wx_gdi.o $(OBJDIR)/wx_dialg.o $(OBJDIR)/wx_dc.o $(OBJDIR)/wx_ipc.o\
 $(OBJDIR)/wx_timer.o

BASEOBJECTS = ../base/$(OBJDIR)/wb_win.o ../base/$(OBJDIR)/wb_frame.o ../base/$(OBJDIR)/wb_panel.o\
  ../base/$(OBJDIR)/wb_utils.o ../base/$(OBJDIR)/wb_main.o ../base/$(OBJDIR)/wb_item.o\
  ../base/$(OBJDIR)/wb_list.o ../base/$(OBJDIR)/wxstring.o ../base/$(OBJDIR)/wb_obj.o ../base/$(OBJDIR)/wb_ps.o\
  ../base/$(OBJDIR)/wb_text.o ../base/$(OBJDIR)/wb_gdi.o ../base/$(OBJDIR)/wb_dialg.o\
  ../base/$(OBJDIR)/wb_canvs.o ../base/$(OBJDIR)/wb_dc.o ../base/$(OBJDIR)/wb_mf.o\
  ../base/$(OBJDIR)/wb_hash.o ../base/$(OBJDIR)/wb_ipc.o ../base/$(OBJDIR)/wb_form.o\
  ../base/$(OBJDIR)/wb_timer.o ../base/$(OBJDIR)/wb_help.o ../base/$(OBJDIR)/wb_types.o\
  ../base/$(OBJDIR)/wb_sysev.o ../base/$(OBJDIR)/wb_stdev.o ../base/$(OBJDIR)/wb_mgstr.o ../base/$(OBJDIR)/wx_enhdg.o


all:    base $(OBJDIR) $(WXLIB)

# Clears all default suffixes
.SUFFIXES:

base:
	cd $(WXDIR)/src/base; make -f makefile.unx GUI=$(GUI) GUISUFFIX=$(GUISUFFIX) CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)'


$(WXLIB): $(OBJECTS) $(BASEOBJECTS)
	ar $(AROPTIONS) $@ $(OBJECTS) $(BASEOBJECTS)
	ranlib $@

#	rm -f $@

motif:
	make -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_motif

xview:
	make -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol

$(OBJDIR):
	mkdir $(OBJDIR)

hp:
	make -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='-g' WARN='-w' \
           XINCLUDE='-I/usr/include/Motif1.2 -I/usr/include/X11R5' \
           XLIB='-L/usr/lib/Motif1.2 -L/usr/lib/X11R5'


# THE FOLLOWING IS FOR MAKING A DYNAMIC LIBRARY USING AT&T C++
# DEBUG = -ggdb -DDEBUG -v
# CPPFLAGS =  -I/usr/openwin/include $(INC) -I$(WXDIR)/dummy -Dwx_xview $(DEBUG) -fPIC
# CFLAGS =   -v
# LDFLAGS =  -L/usr/openwin/lib -L$(WXDIR)/lib
# LDLIBS = -lwx -lxview -lolgx -lX11 -lm

# $(WXDYNLIB):	$(OBJECTS)
#	rm -f $@
#	ld -o $@ -assert pure-text $(OBJECTS)

$(OBJECTS):	$(WXBASEINC)/common.h $(WXBASEINC)/wx_obj.h
$(OBJDIR)/wx_win.o:	wx_win.cc $(WXINC)/wx_win.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_win.cc

$(OBJDIR)/wx_frame.o:	wx_frame.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXBASEINC)/wx_stdev.h $(WXINC)/wx_main.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_frame.cc

$(OBJDIR)/wx_panel.o:	wx_panel.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h \
                $(WXINC)/wx_panel.h $(WXBASEINC)/wx_stdev.h $(WXBASEINC)/wx_list.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_panel.cc

$(OBJDIR)/wx_canvs.o:	wx_canvs.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXINC)/wx_canvs.h $(WXBASEINC)/wx_stdev.h $(WXINC)/wx_gdi.h\
                $(WXBASEINC)/wx_list.h $(WXINC)/wx_dc.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_canvs.cc

$(OBJDIR)/wx_dc.o:        wx_dc.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXINC)/wx_canvs.h $(WXBASEINC)/wx_stdev.h $(WXINC)/wx_gdi.h\
                $(WXBASEINC)/wx_list.h $(WXINC)/wx_dc.h $(WXINC)/wx_dccan.h $(WXINC)/wx_dcmem.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_dc.cc

$(OBJDIR)/wx_mf.o:        wx_mf.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXINC)/wx_canvs.h $(WXBASEINC)/wx_stdev.h $(WXINC)/wx_gdi.h\
                $(WXINC)/wx_mf.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_mf.cc

$(OBJDIR)/wx_text.o:	wx_text.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXINC)/wx_text.h $(WXBASEINC)/wx_stdev.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_text.cc

$(OBJDIR)/wx_item.o:	wx_item.cc $(WXINC)/wx_win.h $(WXINC)/wx_frame.h\
                $(WXINC)/wx_panel.h $(WXINC)/wx_item.h $(WXBASEINC)/wx_stdev.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_item.cc

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

$(OBJDIR)/wx_event.o:     wx_event.cc $(WXBASEINC)/wx_stdev.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_event.cc

$(OBJDIR)/wx_gdi.o:	wx_gdi.cc $(WXINC)/wx_gdi.h $(WXBASEINC)/wx_list.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_gdi.cc

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

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

$(OBJDIR)/wx_dialg.o:	wx_dialg.cc $(WXINC)/wx_dialg.h $(WXINC)/wx_panel.h $(WXINC)/wx_win.h $(WXINC)/wx_item.h
	$(CC) -c $(CPPFLAGS) -o $@ wx_dialg.cc

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

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

objects_ol/sb_scrol.o:	sb_scrol.c
	$(CCSB) -c $(CPPFLAGS) -o $@ sb_scrol.c

$(WXINC)/wx_win.h:  $(WXBASEINC)/wb_win.h
$(WXINC)/wx_main.h:  $(WXBASEINC)/wb_main.h
$(WXINC)/wx_frame.h:  $(WXBASEINC)/wb_frame.h
$(WXINC)/wx_panel.h:  $(WXBASEINC)/wb_panel.h
$(WXINC)/wx_text.h:  $(WXBASEINC)/wb_text.h
$(WXINC)/wx_dialg.h:  $(WXBASEINC)/wb_dialg.h
$(WXINC)/wx_ipc.h:  $(WXBASEINC)/wb_ipc.h
$(WXINC)/wx_gdi.h:  $(WXBASEINC)/wb_gdi.h
$(WXINC)/wx_canvs.h:  $(WXBASEINC)/wb_canvs.h
$(WXINC)/wx_mf.h:  $(WXBASEINC)/wb_mf.h
$(WXINC)/wx_item.h:  $(WXBASEINC)/wb_item.h
$(WXINC)/wx_buttn.h:  $(WXBASEINC)/wb_buttn.h
$(WXINC)/wx_messg.h:  $(WXBASEINC)/wb_messg.h
$(WXINC)/wx_choic.h:  $(WXBASEINC)/wb_choic.h
$(WXINC)/wx_check.h:  $(WXBASEINC)/wb_check.h
$(WXINC)/wx_lbox.h:  $(WXBASEINC)/wb_lbox.h
$(WXINC)/wx_txt.h:  $(WXBASEINC)/wb_txt.h
$(WXINC)/wx_mtxt.h:  $(WXBASEINC)/wb_mtxt.h
$(WXINC)/wx_slidr.h:  $(WXBASEINC)/wb_slidr.h
$(WXINC)/wx_menu.h:  $(WXBASEINC)/wb_menu.h

$(OBJECTS):	$(WXBASEINC)/wx_setup.h

# .cc.o:	
#	$(CC) -c $(CPPFLAGS) -o $@ $*.cc

clean:
	echo OBSOLETE TARGET: You must specify cleanmotif or cleanol.

cleaneach:
	rm -f $(OBJECTS) $(BASEOBJECTS) $(WXDIR)/lib/libwx$(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 

