###########################################################################
# 
# Copyright 1995  by  the  Massachusetts Institute  of Technology.   All  
# rights reserved.
# 
# Developed  by the Perceptual Computing Section 
# at the Media Laboratory, MIT, Cambridge, Massachusetts.
# 
# Permission to use, copy,  or modify this software and  its documentation
# for  educational  and  research purposes only and without fee  is hereby
# granted, provided  that this copyright notice and the original authors's
# names appear  on all copies and supporting documentation.  If individual
# files are  separated from  this  distribution directory  structure, this
# copyright notice must be included.  For any other uses of this software,
# in original or  modified form, including but not limited to distribution
# in whole or in  part, specific  prior permission  must be  obtained from
# MIT.  These programs shall not  be  used, rewritten, or  adapted as  the
#   basis  of  a commercial  software  or  hardware product  without first
# obtaining appropriate licenses  from MIT.  MIT. makes no representations
# about the suitability of this  software for any purpose.  It is provided
# "as is" without express or implied warranty.
# 
###########################################################################

PFINDER = .
TPM = ${PFINDER}/lib/tpm
AJA = ${PFINDER}/lib/aja

CC = cc
C++ = CC
CPPFLAGS = -I${TPM} -I${AJA}
CFLAGS = -O -32 -float -mips2 ${CPPFLAGS}
LDFLAGS = -L${TPM}/lib/iris -L${AJA}/lib/iris

AJALIBS = -lParse -lqmKalmanFilter -lQuickMath
TPMLIBS = -ltpm -llapack -lblas -lf2c
STDLIBS = -lXm -lXt -lX11 -lvl -lm -lInventorXt -lgl
LIBS = ${AJALIBS} ${TPMLIBS} ${STDLIBS}

SRCS = iveBitmap.c iveImage.c \
	bsColor.c bsClassify.c bsSegment.c bsXclient.c \
	pfinder-proc.c++ VLImage.c++ \
	pfinder-rpc.c++ pf-cache.c++ pfinder_svc.c pfinder_xdr.c \
	lite.c++ pfCamera.c++ pfFeatures.c++ pfGesture.c++ pfPersonSize.c++ \
	pfMorphology.c pfContour.c++ pf-proc.cpp

OBJS = iveBitmap.o iveImage.o \
	bsColor.o bsClassify.o bsSegment.o bsXclient.o \
	VLImage.o \
	pfinder-rpc.o pf-cache.o pfinder_svc.o pfinder_xdr.o \
	lite.o pfCamera.o pfFeatures.o pfGesture.o pfPersonSize.o \
	pfMorphology.o pfContour.o pf-proc.o

PROTOS = bsColor.proto bsClassify.proto bsSegment.proto \
	bsXclient.proto iveBitmap.proto 

# CEXTRACT = /mas/vision/projects/ive/Alive/bin/cextract +Cm
CEXTRACT = ${PFINDER}/bin/iris/cextract +Cm

pfinder: pfinder.h $(PROTOS) $(OBJS) vidtowin_seg.c
	$(C++) vidtowin_seg.c $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)

pfinder.h: pfinder.x
	rpc++gen pfinder.x

first: depend pfinder


# callpf: callpf.c++ pfinder.h pfinder_clnt.o pfinder_xdr.o
# 	$(C++) $(CFLAGS) -o callpf callpf.c++  pfinder_clnt.o pfinder_xdr.o
# 
# ICP = invcallpf.o pfinder_clnt.o pfinder_xdr.o
# 
# invcallpf: pfinder.h ${ICP}
# 	$(C++) $(CFLAGS) -o invcallpf ${ICP} -lInventorXt
#

libpfinder.a: pfinder_clnt.o pfinder_xdr.o
	rm -f libpfinder.a
	ar rs libpfinder.a pfinder_clnt.o pfinder_xdr.o


install: libpfinder.a pfinder
	mv pfinder $(PFINDER)/bin/$(MACHTYPE)/pfinder
	mv libpfinder.a $(PFINDER)/lib/client/$(MACHTYPE)/
	cp  pfinder.h pfinder_{clnt,xdr}.[ch] $(PFINDER)/include/

package:
	make -f Makefile.package

###########################################################################

depend:
	@-touch Makedepend
	makedepend -fMakedepend -- $(CFLAGS) -- $(SRCS)

clean:
	@-rm *.o *.proto pfinder.h pfinder_{xdr,clnt,svc}.[ch] 

.SUFFIXES: .proto

.c.proto:
	$(CEXTRACT) $(CPPFLAGS) -H__$*_PROTO__ -o $*.proto $*.c 

.c.o:
	$(CC) $(CFLAGS) -c $*.c

.c++.o:
	$(C++) $(CFLAGS) -c $*.c++

###########################################################################

sinclude Makedepend

