# Makefile.in for mpd2


prefix    = /proj/tpfimos/larour/Libraries/linux/mpich2-gnu/
exec_prefix = ${prefix}
bindir    = ${exec_prefix}/bin
mandir    = ${prefix}/man
srcdir	  = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/pm/mpd
SHELL	  = /bin/sh
CC	  = gcc
INCLUDES  = -I. -I${srcdir}
CPPFLAGS  =  -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/binding/f77 -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/binding/f77 -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/datatype -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/datatype -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/channels/sock/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/channels/sock/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock/poll -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock/poll
CLINKER	  = gcc
COPTIONS  = 
LDFLAGS	  = 
LIBS	  =        -lpthread  -lrt    
PYTHON    = python
DO_MTV    = 
INSTALL   = /usr/bin/install -c

C_COMPILE = ${CC} ${INCLUDES} ${CFLAGS} ${COPTIONS}
C_LINK	  = ${CLINKER} ${CFLAGS} ${COPTIONS} ${LDFLAGS}

VPATH     = .:/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/pm/mpd

PROGRAMS  = mpdroot
EXAMPLES  = sigcatcher infloop

SOURCES   = ${mpdroot_SOURCES} ${example_SOURCES}
OBJECTS   = ${mpdroot_OBJECTS} ${example_OBJECTS}
HEADERS   = mpdconf.h mpdroot.h

MPD      = mpd
MPDBOOT  = mpdboot
CMDS     = mpiexec mpdrun mpdtrace mpdringtest mpdlistjobs mpdkilljob mpdsigjob \
           mpdexit mpdallexit mpdcleanup mpdhelp mpdcheck
HELPERS  = mpdgdbdrv mpdman mpdlib mpdchkpyver

PYTHON_SOURCE =  ${MPD} ${MPDBOOT} ${CMDS} ${HELPERS}

mpdroot_SOURCES  = mpdroot.c
example_SOURCES	 = sigcatcher.c infloop.c

mpdroot_OBJECTS	= ${mpdroot_SOURCES:.c=.o}
example_OBJECTS	= ${example_SOURCES:.c=.o}


all: Makefile ${PROGRAMS}
	@if [ ! -x ${srcdir}/install.sh ] ; then \
	    echo "chmod a+x ${srcdir}/install.sh" ;\
	    if [ ! `chmod a+x ${srcdir}/install.sh` ] ; then \
	        echo "  chmod ok" ;\
	    else \
	        echo "Unable to set ${srcdir}/install.sh file to be executable." ;\
		echo "Please fix and rerun make" ;\
	        exit 1 ;\
	    fi ;\
	fi
	@if [ "${DO_MTV}" = "yes" ] ; then \
	    currdir=`pwd` ; cd ${srcdir}  &&  ${PYTHON} ./mtv_setup.py build_ext --build-lib=$$currdir --build-temp=$$currdir ;\
	fi



.SUFFIXES:
.SUFFIXES: .o .dep .c 

etags:  ${HEADERS} ${SOURCES}
	etags ${HEADERS} ${SOURCES}

mpdroot: ${mpdroot_OBJECTS}
	$(C_LINK) -o mpdroot ${mpdroot_OBJECTS} $(LIBS)

mpdroot.o: ${srcdir}/mpdroot.c ${srcdir}/mpdroot.h mpdconf.h
	${C_COMPILE} -c  $< 

# The following lines provide the right libraries for all example programs
.c:
	${C_LINK} -o $* $*.c $(LIBS)
.o:     
	$(C_LINK) -o $* $*.o $(LIBS)

clean: 
	@-/bin/rm -f *.o *.dep *~ ${EXAMPLES} core* *.1 *.pyc

# echo "some of the following might be executables you want to remove"
# ls -l | grep rwx
distclean: clean
	/bin/rm -f Makefile mpdconf.h ${PROGRAMS} ${PYTHON_SOURCE} \
                   config.status config.cache config.log mtv.so


maintainer-clean: distclean
	/bin/rm -f configure mpdconf.h.in
	/bin/rm -rf autom4te.cache

configure: configure.in
	./makeconfigure

Makefile: ${srcdir}/Makefile.in config.status
	./config.status

.c.o:	
	${C_COMPILE} -c $<

# if configured with wrong prefix, use:
#     make prefix=new_install_dir install
install: all
	@if [ ! -d ${bindir} ] ; then \
	    echo "mkdir -p ${bindir} " ;\
	    mkdir -p ${bindir} ;\
	fi   
	-@if [ -n "`id | grep uid=0`" ] ; then \
	    ${INSTALL} -m 4755 mpdroot ${bindir}/mpdroot ;\
        else \
	    ${INSTALL} -m  755 mpdroot ${bindir}/mpdroot ;\
	fi
	@echo "copying python files/links into " ${bindir}
	-@for cmd in ${PYTHON_SOURCE} ; do \
	    sed -e 's#/usr/bin/env python.*#/usr/bin/env ${PYTHON}#' ${srcdir}/$$cmd.py > ${bindir}/temp$$cmd.py ; \
	    ${INSTALL} -m 755 ${bindir}/temp$$cmd.py ${bindir}/$$cmd.py; \
	    ( rm -f ${bindir}/temp$$cmd.py >/dev/null 2>&1 || exit 0 ) ; \
	done
	-@cd ${bindir} && rm -f mpd
	-@cd ${bindir} && ln -s mpd.py mpd
	-@cd ${bindir} && rm -f mpdboot
	-@cd ${bindir} && ln -s mpdboot.py mpdboot
	-@for cmd in ${CMDS} ; do \
	    ( cd ${bindir} && rm -f $$cmd ; ) ; \
	    ( cd ${bindir} && ln -s mpdroot $$cmd ; ) \
	done
	-@( rm -f ${bindir}/mpirun >/dev/null 2>&1 || exit 0 )
	-@cd ${bindir} && rm -f mpirun
	-@cd ${bindir} && ln -s mpdrun mpirun
	-@cd ${bindir} && rm -f mpirun.py
	-@cd ${bindir} && ln -s mpdrun.py mpirun.py
	-@if [ "${DO_MTV}" = "yes" ] ; then \
	    ${INSTALL} -m 755 mtv.so ${bindir}/mtv.so ;\
	fi


mpich2-build-install: mpich2-mpdroot install
	-@if [ -n "`id | grep uid=0`" ] ; then \
            ${INSTALL} -m 4755 mpich2-mpdroot ${bindir}/mpdroot ;\
	else \
            ${INSTALL} -m  755 mpich2-mpdroot ${bindir}/mpdroot ;\
	fi
	/bin/rm -f mpich2-mpdroot

mpich2-build-uninstall:
	/bin/rm -f ${bindir}/mpdroot

mpich2-mpdroot: mpich2-mpdroot.o
	$(C_LINK) -o mpich2-mpdroot mpich2-mpdroot.o $(LIBS)
	/bin/rm -f mpich2-mpdroot.o

mpich2-mpdroot.o: ${srcdir}/mpdroot.c ${srcdir}/mpdroot.h mpdconf.h
	${INSTALL} -m 644 ${srcdir}/mpdroot.c mpich2-mpdroot.c
	${C_COMPILE} -c mpich2-mpdroot.c
	/bin/rm -f mpich2-mpdroot.c

# Empty dependencies target (MPICH2 wants this target)
dependencies:
# Empty documentations targets (MPICH2 wants this target)
htmldoc:
latexdoc:
mandoc:
# Empty tags targets (MPICH2 wants this target)
tags: TAGS
TAGS:


# EXPERIMENTAL TOTALVIEW STUFF

# EXPERIMENTAL MAN STUFF
man:
	-@for cmd in ${PYTHON_SOURCE} ; do \
	    currdir=`pwd` ; cd ${srcdir} &&  pydoc $$cmd | txt2man -t $$cmd -s 1 -v "mpd cmds" | awk ' !/Help on module/ { print } ' > $$currdir/$$cmd.1 ; \
	done
	# example:  nroff -man mpd.1 | less

install-man:
	-@for cmd in ${PYTHON_SOURCE} ; do \
		${INSTALL} -m 644 $$cmd.1 ${mandir}/$$cmd.1 ; \
	done
