# Makefile for partiview - please do not edit if the file is named "Makefile",
# since configure would overwrite it on the next configure. Edit "Makefile.in"
# instead, and run configure instead!!!
# If you must change configure.in, run autoconf, and then configure etc.

# the following variables are under AC control
# KIRA_INC, KIRA_LIB
# FLTK_INC, FLTK_LIB
# PV_FLAGS

SHELL = /bin/sh

# TARGET
TARGET   = partiview

#	Override with --with-fltk=
FLTK_INC   = @FLTK_INC@
FLTK_LIB   = @FLTK_LIB@

#KIRA_INC = -I$(STARLAB_PATH)/inc
#KIRA_LIB = -L${STARLAB_PATH)/lib

#  AC variables KIRA_INC and KIRA_LIB automatically created
#  if $STARLAB_PATH present; override with --with-kira=
KIRA_INC = @KIRA_INC@
KIRA_LIB = @KIRA_LIB@

GL_LIB   = @GLLIBS@
X_LIB    = @XLIBS@
M_LIB    = -lm

# FLAGS and BINARIES
PV_FLAGS    = @PV_FLAGS@
DEFS	    = -DNOCAVE -Dunix $(PV_FLAGS) -DUSE_WARP ## -DUSE_KIRA ## -DUSE_IEEEIO
INCL	    = ${FLTK_INC} -I/usr/X11R6/include $(KIRA_INC)
CC          = @CC@
CFLAGS      = ${OPT} ${DEFS} ${INCL}
CXX	    = @CXX@
CXXFLAGS    = ${CFLAGS} 
## OTYPE    = -n32 -mips3
#OPT        = -g3 -Ofast ${OTYPE}
OPT         = -g -O2 ${OTYPE}
LINK        = ${CXX}
LIBS        = ${KIRA_LIB} ${FLTK_LIB} ${GL_LIB} ${X_LIB} ${M_LIB}

APP_CSRCS   = geometry.c partibrains.c mgtexture.c textures.c \
		findfile.c sfont.c warp.c version.c
APP_CXXSRCS = partiview.cc partiviewc.cc partipanel.cc Gview.cc Hist.cc \
		Fl_Log_Slider.cxx kira_parti.cc Plot.cc

# 		parti-ieee.C
#		cat_model.cc cat_modelutil.cc cat_shmutil.cc 

APP_OBJS    = partiview.o partiviewc.o partipanel.o Gview.o Hist.o \
		geometry.o partibrains.o version.o \
		mgtexture.o textures.o futil.o findfile.o sfont.o \
		sclock.o notify.o Fl_Log_Slider.o Plot.o \
		kira_parti.o warp.o \
		${MORE_OBJS}

#		cat_model.o cat_modelutil.o cat_shmutil.o

all:	depended $(TARGET)

Makefile: Makefile.in configure
	@if [ -f config.status ]; then \
		echo "Re-running config.status to regenerate Makefile"; \
		./config.status; \
	else \
		echo "Beware -- you probably need to re-run 'configure'"; \
	fi

depended: Makefile version.c
	${MAKE} depend
	touch depended
	@echo "Re-running 'make'"
	${MAKE}

help:
	@echo  Partiview
	@echo  

clean:
	rm -f *.o core Makedepend $(TARGET)
	touch Makedepend

cleanall: clean
	rm -f Makefile config.log config.status config.h config.cache

$(TARGET):  $(APP_OBJS)
	$(CXX) -o $@ $(OPT)  $(APP_OBJS) $(LIBS)

version.c: VERSION
	echo "char partiview_version[] = \"`cat VERSION`\";" > version.c

version.o: version.c

ptest:  ptest.o
	$(CXX) -o $@ $(OPT) ptest.o $(LIBS)

dometest:  dometest.o geometry.o
	$(CXX) -o $@ $(OPT) dometest.o geometry.o $(LIBS)

partipanel.H partipanel.cc: partipanel.fl
	fluid -c partipanel.fl

.PHONEY: depend

# dep: depend
# depend:	_always

depend:
	rm -f Makedepend
	${CC} -M ${CFLAGS} ${APP_CSRCS} > Makedepend
	${CXX} -M ${CXXFLAGS} ${APP_CXXSRCS} >> Makedepend

_always:

.SUFFIXES: .C .cc .cxx .cpp

.C.o:
	${CXX} -c $< ${CXXFLAGS} 
.cc.o:
	${CXX} -c $< ${CXXFLAGS} 
.cxx.o:
	${CXX} -c $< ${CXXFLAGS}
.cpp.o:
	${CXX} -c $< ${CXXFLAGS} 

include Makedepend
