# 
# $Id: Makefile.sendrecv,v 1.1.1.1 1999/11/25 06:26:11 yamauchi Exp $
# 	
# 	Copyright 1999 (C) .Yamauchi
# 	1996, 7, 6
# 
C++    = g++		# for /usr/local/bin/make (gnu make)
CXX    = g++
CC     = g++	
/*
 C++	= mpiCC
 CXX	= mpiCC
 CC	= mpiCC
*/

#if defined(SunArchitecture)
#  if OSMajorVersion > 4
MPI_ROOT 	 = /usr/local/mpich
ARCHI		 = solaris
MPI_LIB_DIR 	  = -L$(MPI_ROOT)/build/$(ARCHI)/ch_p4/lib	
MPI_INCLUDE_DIR   = -I$(MPI_ROOT)/include 
MPI_INCLUDE_DIR  += -I$(MPI_ROOT)/build/$(ARCHI)/ch_p4/include
/*
 * Sun MPI
 */
/*
MPI_ROOT         = /opt/SUNWhpc
MPI_INCLUDE_DIR   = -I$(MPI_ROOT)/include
MPI_LIB_DIR       = -L$(MPI_ROOT)/lib 
*/
#  else
MPI_LIB_DIR 	 = -L$(MPI_ROOT)/lib/sun4/ch_p4		# sun4.x
#  endif
#elif defined(FreeBSDArchitecture)
MPI_ROOT 	 = /usr/local/mpich
ARCHI		 = freebsd
MPI_LIB_DIR 	  = -L$(MPI_ROOT)/build/$(ARCHI)/ch_p4/lib
MPI_INCLUDE_DIR   = -I$(MPI_ROOT)/include 
MPI_INCLUDE_DIR  += -I$(MPI_ROOT)/build/$(ARCHI)/ch_p4/include
#else
# ERROR							# not supported
#endif

INCLUDEOPTION = -I../1PE -I../mpi2dataReader 

/*
 * snprintf
 */ 
#ifdef SparcArchitecture 
#  if OSMajorVersion > 4 && OSMinorVersion < 6
CFLAGS		+= -DNO_SNPRINTF
#  endif
#endif

/*
 * libs
 */
SYS_LIBRARIES   += -lm
/* SYS_LIBRARIES   += -lm -ldl */
LOCAL_LIBRARIES += $(MPI_LIB_DIR) -lmpich

DEPEND  = true

/*
 * for DEBUG
 */
/*
	CDEBUGFLAGS     += -Wwrite-strings
	CXXDEBUGFLAGS    = $(CDEBUGFLAGS)
*/
/* Sun で -pg を使う場合には  -lsocket -lnsl などのリンクするものを外すこと．
   profile 用のリンクパスを見るべき(/usr/lib/libp など)に通常のものを 
   link しようとして失敗する */
/* CDEBUGFLAGS      = -Wall -pg -DNDEBUG */
CDEBUGFLAGS      = -g -Wall -DUSE_MPI ${INCLUDEOPTION}
/* CDEBUGFLAGS      = -Wall -DNDEBUG -O2 -DREDUCE_VERBOSE_INFO */
CXXDEBUGFLAGS    = $(CDEBUGFLAGS)

/*
 * FLAGS
 */
/* CFLAGS          += $(CDEBUGFLAGS) -DFOR_STANDALONE -L/usr/5bin */
/* CFLAGS          += $(CDEBUGFLAGS) -DFOR_STANDALONE -DTRACE_RAY */
CFLAGS          += $(MPI_INCLUDE_DIR) $(CDEBUGFLAGS) $(MPI_LIB_DIR)
CXXFLAGS         = $(CFLAGS)

/*
 * sources and objects
 */
/* 
 * for read datafile (geometry, space, view, material) 	
 *	実装の関係で read data files は 2 つに分割されている。
 *      READMPI2BASEFILES にはテストできる読み込みルーチンが書かれてい
 *	る。
 *	最終的には READMPI2FILES に統一されると良い。
 */
READMPI2BASEFILES = 					\
	Vector3.cc IntVec3.cc mpi2ReaderClass.cc 	\
	triangleObject.cc sphereObject.cc		\
	material.cc ray.cc vector.cc FileInfo.cc	\
	getvals.cc myString.cc fileUtil.cc

READMPI2FILES = ${READMPI2BASEFILES}			\
	spc2PE.cc objectSet.cc objectDatas.cc		\
	readSysinfo.cc readView.cc readSpcParam.cc 	\
	getopt.cc lineParser.cc

/* Ray-Tracing	*/
RAYTRACEFILES	=					\
	calcRayTrFRG.cc calcRayTrIC.cc calcRayTrSRG.cc	\
	PERayTracing.cc calcRayTrSRGDist.cc frustumSRG.cc

/* Radiosity    */
RADIOSITYFILES	=					\
	calcRadioFRG.cc calcRadioIC.cc hemicube.cc	\
	PERadiosity.cc  calcRadioSRG.cc

/* 
 * Multi-Pass Common and Units 
 */
/* 3DDDA */
DDAFILES	=  					\
	ddaInfo.cc searchNextSpcDDA.cc PEGetNextSpace.cc
	
/* Proximitry Clouds */
PRCFILES	=  					\
	PRC_PErecv.cc PRC_readDistInfo.cc 		\
	PRC_searchNextSpc.cc PRC_deliverSkipInfo.cc

COMMONUNITFILES = ${DDAFILES} ${PRCFILES}		\
	host.cc hostForParallel.cc PE.cc netIntUnit.cc	\
	prepareShading.cc frameBuffer.cc


/* for volume rendering	*/
VOLUMEFILES	= 					\
	volumeInit.cc volumeRayCast.cc			\
	PEvolume.cc hostVolume.cc volumeSerializable.cc	\
	readVolumeInfile.cc volumeReader.cc volume.cc	\
	pnmReader.cc volumeSet.cc deliverVolume.cc	\
	boundtest.cc 

/* for MPI version */
MPIFILES = mpi2communicationMPI.cc			\
	PErecv.cc main.cc
/*
 * ALL Source Files
 */
FILES	= 						\
	${MPIFILES}					\
	${COMMONUNITFILES} ${VOLUMEFILES} 		\
	${RAYTRACEFILES}   ${RADIOSITYFILES} 		\
	${READMPI2FILES}


OBJS  = ${FILES:.cc=.o}

TMPFILE	:= $(shell echo /tmp/maketmpfile.$$$$)

ComplexCplusplusProgramTarget(mpi2)
/* ComplexCplusplusProgramTarget(mpi2o) */

versionup:
	echo $(TMPFILE)
	rm -f $(TMPFILE)	
	@echo -i "enter LOG message of this version"
	@cat > $(TMPFILE)	
	for i in do *; do			\
	    if [ ! -h $$i ]; then		\
		cat $(TMPFILE) | ci -l $$i;	\
	    fi;					\
	done;
	rm -f $(TMPFILE)	

depend:: 
	g++ -MM $(CFLAGS) $(FILES) > Makefile.depend


Makefiles::
	@echo "no need to make Makefiles"
	

includes::
	@echo "no need to make includes"
	
etags::
	find . \( -name '*.cc' -o -name '*.h' \) -print | xargs etags -d -t -a
	@echo "\`TAGS' is updated."

clean::
	rm -fr a a.out .xvpics/

#
#----- DO NOT EDIT 
include Makefile.depend
