#
# Makefile for "xdf"
#
# this makefile is configured for Linux-Systems and you might need to change some paths
# and options for other systems...
#
# on Linux systems "make ; make install" (run as superuser) should do everything
#

CXX=/opt/sfw/gcc-2/bin/g++
CC=/opt/sfw/gcc-2/bin/gcc
LINK.cc=$(CC)
#LIBSTDCXX = $(shell $(CXX) --print-file-name=libstdc++.a)
OPENWINHOME = /usr/openwin
CCFLAGS = -pipe -O3 -DOWTOOLKIT_WARNING_DISABLED
#CCFLAGS = -pipe -g
CPPFLAGS += $(CCFLAGS) -I /usr/openwin/include -I/usr/lib/g++-include -DMAIN
LDFLAGS += -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -L /usr/X11R6/lib 
LDLIBS +=  -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lxview  -lX11 -lolgx

.KEEP_STATE:

PROGRAM = xdf
SOURCES.cc = xdf.cc
INSTALLPATH = /usr/openwin/bin
SOURCES.h = xdf.H
SOURCES.c = 
SOURCES.G =
STUBS.G =


SOURCES = \
	$(SOURCES.G) \
	$(SOURCES.l) \
	$(SOURCES.y) \
	$(SOURCES.c) \
	$(SOURCES.h) \
	$(SOURCES.cc)

TARGETS.cc = \
	$(SOURCES.G:%.G=%_ui.cc) \
	$(STUBS.G:%.G=%_stubs.cc)

TARGETS.h = \
	$(SOURCES.G:%.G=%_ui.h) \
	$(SOURCES.l:%.l=%.h) \
	$(SOURCES.y:%.y=%.h)

TARGETS.other = \
	$(SOURCES.G:%.G=%.info)

TARGETS = \
	$(TARGETS.other) \
	$(TARGETS.h) \
	$(TARGETS.cc)

OBJECTS = \
	$(SOURCES.c:%.c=%.o) \
	$(SOURCES.cc:%.cc=%.o) \
	$(TARGETS.cc:%.cc=%.o)
# Compiler flags.

debug:=CCFLAGS=-sb -g

# Standard targets.

#this target uses gxv++ to produce the ui file and is dependant on guide
debug all: init $(TARGETS.other) $(PROGRAM)
objects: $(SOURCES.c) $(SOURCES.h) $(SOURCES.cc) $(TARGETS.cc) $(TARGETS.h) $(OBJECTS)
sources: $(SOURCES)
targets: $(SOURCES) $(TARGETS)

init:
#	@-sccs get SCCS
# Next line removed to stop use of Guide
#	@-chmod +w window_stubs.cc window_ui.cc window_ui.h window.window.info


$(PROGRAM): $(SOURCES.c) $(SOURCES.cc) $(TARGETS.cc) $(TARGETS.h) $(OBJECTS)
	LD_RUN_PATH=$(OPENWINHOME)/lib $(LINK.cc) -o $@ $(OBJECTS) $(LDLIBS)

clean:
	@-$(RM) -rf .sb $(OBJECTS) $(PROGRAM) \
	  *.BAK *.delta core .prof .nm mon.out \
	  *.tcov *.d tags *~ 

#clean:
#	@-sccs clean
#	@-$(RM) -rf .sb $(SOURCES.G:%.G=%_ui.cc) \
#	  $(TARGETS.other) $(TARGETS.h) $(OBJECTS) $(PROGRAM) \
#	  *.BAK *.delta core .prof .nm mon.out \
#	  *.tcov *.d tags *~ 

# Don't use Guide
#%_ui.cc: %.G
#	$(GUIDEHOME)/bin/gxv++  $*
#
#%_ui.h: %_ui.cc
#	@touch $@
#
#%_stubs.cc: %_ui.cc
#	@touch $@
#
#%.info: %_ui.cc
#	@touch $@

recompile: clean all

build:
	@sccs get SCCS

ctags:
	ctags++ *.cc >/tmp/ctags 2>&1

install:
	cp $(PROGRAM) $(INSTALLPATH)
	chown root.root $(INSTALLPATH)/$(PROGRAM)
	chmod 755 $(INSTALLPATH)/$(PROGRAM)

run:
	./xdf
