#################################################################
# RSEARCH Makfile
# Modified from INFERNAL's
# CVS $Id: Makefile.in,v 1.7 2003/01/10 21:33:31 rjklein Exp $
#################################################################
SHELL  = /bin/sh

# On most Unices, you can build the package without modifying anything
#   by just typing "./configure; make".
#
# You may want to modify the following make variables:
#   BINDIR  - where the executables will be installed by a 'make install'
#   MANDIR  - where the man pages will be installed by a 'make install'
#   CC      - which compiler to use
#   CFLAGS  - compiler flags to use

# where you want things installed
# Sort of uses GNU coding standards. ${prefix} might be /usr/local.
# ${exec_prefix} gives you some flexibility for installing architecture
# dependent files (e.g. the programs): an example ${exec_prefix} might be
# /nfs/share/irix64/
#
prefix      = /home/rjklein
exec_prefix = ${prefix}
BINDIR      = ${exec_prefix}/bin
MANDIR      = ${prefix}/man
DATADIR     = ${prefix}/share

## your compiler and compiler flags
CC      = mpicc
CFLAGS = -O3 -mp1 -axK -static

## other defined flags. 
#   contains stuff that autoconf 
#  decides on.  contains stuff that we added to
#  the configure script tests.  -lm -lccmalloc -ldl contains system
#  libraries that the configure script decides we need.
#
MDEFS =  -DVERSION=\"1.0\" -DCOPYRIGHT=\"Copyright\ \(C\)\ 1992-1999\ Washington\ University\ School\ of\ Medicine\\nCopyright\ \(C\)\ 2002,2003\ Washington\ University\ School\ of\ Medicine/HHMI\" -DLICENSE=\"Licensed\ under\ the\ terms\ of\ the\ GNU\ General\ Public\ License\ \(GPL\).\ \ See\ file\\nLICENSE\ for\ more\ information.\\n\" -DUSE_MPI=1 -DINTEL_COMPILER=1  -DMATRIX_DIR=\"$(DATADIR)/rsearch/matrices\"
LIBS = 

# Where my libraries/includes (distribured with program) are
MYLIBS   = -lsquid
MYLIBDIR = -Lsquid
MYINCDIR = -Isquid


PROGS = rsearch

OBJS  = alphabet.o\
	cm.o\
	cmio.o\
	globals.o\
	modelmaker.o\
	nstack.o\
	parsetree.o\
	rna_ops.o\
	smallcyk.o\
        rnamat.o\
	buildcm.o\
	histogram.o\
	scancyk.o\
	stats.o\
	mpifuncs.o\
	modelconfig.o\
	display.o
HDRS  = funcs.h\
	nstack.h\
	structs.h\
        rnamat.h\
	scancyk.h\
	mpifuncs.h
.c.o: 
	$(CC) $(CFLAGS) $(MDEFS) $(MYINCDIR) -c $<

#################################################################
## Targets defining how to make RSEARCH executables.
##
all: 	
	(cd squid; make CC="$(CC)" CFLAGS="$(CFLAGS)"; make module)
	make progs

progs:	$(PROGS)

$(PROGS): %: %.o $(OBJS) 
	$(CC) $(CFLAGS) $(MDEFS) $(MYLIBDIR) -o mpi$@ $@.o $(OBJS) $(MYLIBS) $(LIBS)

#################################################################
## Miscellaneous targets.
##
install:
	/usr/bin/install -c -d $(BINDIR)
	for file in $(PROGS); do\
			/usr/bin/install -c mpi$$file $(BINDIR)/;\
	done
	/usr/bin/install -c -d $(DATADIR)/rsearch/matrices
	for file in matrices/*.mat; do\
			/usr/bin/install -c -m 644 $$file $(DATADIR)/rsearch/matrices/;\
	done

distclean:
	make binclean
	-rm -f Makefile version.h config.status config.log
	(cd squid; make distclean)

binclean: 
	make clean
	-rm -f rsearch makernamat mpirsearch  squid/libsquid.a

clean:
	-rm -f *.o *~ Makefile.bak core TAGS gmon.out 
	(cd squid; make clean)

TAGS:
	etags -t *.c *.h Makefile.in


