# Makefile for HMMER: Main project directory: installation, documentation
# RCS $Id: Makefile,v 1.15 1998/05/28 15:15:31 eddy Exp $
##########
# HMMER - Biological sequence analysis with profile HMMs
# Copyright (C) 1992-1998 Washington University School of Medicine
#
#   This source code is distributed under the terms of the 
#   GNU General Public License. See the files COPYING and 
#   LICENSE for details.
#    
###########

# Modify the following stuff to suit your needs.
# On must Unices, you can build the package without modifying anything 
#   by just typing "make".
#
# "make test" should also work without any configuration.
#
# But when you install, you'll want to be sure BINDIR and MANDIR
#   are set properly before doing a "make install".

# where you want things installed
#  Many installations will want to change $(HOME) to /usr/local, for instance  
#
BINDIR  = $(HOME)/bin
MANDIR  = $(HOME)/man

# your compiler and compiler flags
#
CC     = cc
CFLAGS = -O 

# how to install the man pages; 
# cp is generally fine, unless you preformat your pages.
#
INSTMAN   = cp
MANSUFFIX = 1


#######
## HMMER installers should not need to modify below this line
## Much of it is concerned with maintenance of the development version
## and building the release (indeed, several commands will only work in 
## St. Louis)
#######
RELEASE     = "2.0"
RELEASEDATE = "June 1998"
RELCODE     = "beta2_0"

SHELL       = /bin/sh
SQUIDSRCDIR = $(HOME)/src/squid
COMPRESS    = compress
FTPDIR      = /nfs/newftp/eddy/hmmer/

PROGS = hmmalign hmmbuild hmmcalibrate hmmconvert hmmemit hmmpfam hmmsearch 

READMES = 00README COPYING INSTALL GNULICENSE NOTES

MANS =  hmmalign hmmbuild hmmcalibrate hmmconvert hmmemit hmmer hmmpfam hmmsearch 

HDRS =  config.h funcs.h globals.h structs.h version.h

SRC =   hmmalign.c    hmmbuild.c        hmmcalibrate.c    hmmconvert.c\
	hmmemit.c     hmmpfam.c         hmmsearch.c\
	alphabet.c    core_algorithms.c debug.c           emit.c\
	emulation.c   histogram.c       hmmio.c           mathsupport.c\
        masks.c       misc.c            modelmakers.c     plan7.c\
	plan9.c       prior.c           tophits.c         trace.c

SQUIDSRC = aligneval.c  alignio.c   cluster.c   dayhoff.c\
	   file.c       getopt.c    gnuregex.c  interleaved.c\
	   iupac.c      msf.c       revcomp.c   selex.c\
	   sqerror.c    sqio.c      sre_ctype.c sre_math.c\
	   sre_string.c stack.c     translate.c types.c\
           weight.c

SQUIDHDRS = gnuregex.h squid.h sqfuncs.h 

SHIVADIST = README\
	    evd_test.c         masks_test.c parsingviterbi_test.c\
	    tophits_test.c     trace_test.c viterbi_exercise.c\
	    weeviterbi_test.c\
	    Optiontests.pl   Optiontests.fa  Optiontests.nfa Optiontests.nslx\
	    Optiontests.pam  Optiontests.pri Optiontests.slx\
	    fn3.hmm titin.fa\
	    trace_test.hmm trace_test.seq trace_test.slx \
	    weeviterbi_test.hmm weeviterbi_test.seq

DEMOS = globins50.msf  globins630.fa Artemia.fa\
	rrm.slx pkinase.slx fn3.slx\
	rrm.hmm\
	RU1A_HUMAN 7LES_DROME\


# all: compiles the src package, if we don't have precompiled binaries,
#      and moves them into binaries/ subdirectory.
#
all:
	@if test -d binaries; then\
	   echo "You have a precompiled HMMER distribution. No need to make.";\
	else\
	   (cd src; make CC="$(CC)" CFLAGS="$(CFLAGS)");\
	   mkdir binaries;\
	   for prog in $(PROGS); do\
	      mv src/$$prog binaries/;\
	   done;\
	fi

# test: compiles and runs test suite in Shiva/
#       These are public tests, distributed with the package.
#
test:	
	(cd src; make CC="$(CC)" CFLAGS="$(CFLAGS)" libhmmer.a)
	(cd Shiva; make CC="$(CC)" CFLAGS="$(CFLAGS)")
	(cd Shiva; make shiva)


# verify: consistency checks on the package
#         These are private tests, not distributed with HMMER
verify:
	@echo Checking options for consistency...
	@for prog in $(PROGS); do\
	   ./checkoptions.pl $$prog;\
	done


# install: installs the binaries in BINDIR/
#          installs man pages in MANDIR/man1/  (if MANSUFFIX is 1)
install:
	for file in $(PROGS); do\
	   cp binaries/$$file $(BINDIR)/;\
	done
	for file in $(MANS); do\
	   $(INSTMAN) Man/$$file.man $(MANDIR)/man$(MANSUFFIX)/$$file.$(MANSUFFIX);\
	done


# doc:  build the Userguide and on-line manual
#
doc:
	(cd Userguide; make)

# dist: build a new distribution directory in build/hmmer-$RELEASE
#       checks out RCS files read-only
#       tags RCS files with $(RELCODE) for later reconstruction
#       squid RCS files are tagged with hmmer$(RELCODE).
#
#       Thou mayest not use files other than RCS files for a build.
#       (Else reconstruction may not work).
#
dist:
#
# Create directory structure for build
#
	@if test -d build/hmmer-$(RELEASE); then rm -rf build/hmmer-$(RELEASE); fi
	@if test -d build/hmmer-$(RELEASE).tar; then rm -f build/hmmer-$(RELEASE).tar; fi
	@if test -d build/hmmer-$(RELEASE).tar.Z; then rm -f build/hmmer-$(RELEASE).tar.Z; fi
	@if test -d build/hmmer-$(RELEASE).tar.gz; then rm -f build/hmmer-$(RELEASE).tar.gz; fi
	mkdir build/hmmer-$(RELEASE)
	mkdir build/hmmer-$(RELEASE)/src
	mkdir build/hmmer-$(RELEASE)/Demos
	mkdir build/hmmer-$(RELEASE)/Man
	mkdir build/hmmer-$(RELEASE)/Shiva
	mkdir build/hmmer-$(RELEASE)/Userguide
#
# RCS extraction of top level README-type documentation and Makefile
#
	for file in $(READMES) Makefile; do\
	  rcs -N$(RELCODE): RCS/$$file,v;\
	  co RCS/$$file,v build/hmmer-$(RELEASE)/$$file;\
        done
#
# RCS extraction of src/ source code subdirectory
#
	for file in $(SRC) $(HDRS) Makefile; do\
           rcs -N$(RELCODE): src/RCS/$$file,v;\
	   co src/RCS/$$file,v build/hmmer-$(RELEASE)/src/$$file;\
	done
	for file in $(SQUIDSRC) $(SQUIDHDRS); do\
	   rcs -Nhmmer_$(RELCODE): $(SQUIDSRCDIR)/RCS/$$file,v;\
	   co $(SQUIDSRCDIR)/RCS/$$file,v build/hmmer-$(RELEASE)/src/$$file;\
	done
#
# RCS extraction of Demos/ 
#
	for file in $(DEMOS); do\
	  rcs -N$(RELCODE): Demos/RCS/$$file,v;\
	  co Demos/RCS/$$file,v build/hmmer-$(RELEASE)/Demos/$$file;\
        done
#
# RCS extraction of Man/ manual pages
#
	for file in $(MANS); do\
	   rcs -N$(RELCODE): Man/RCS/$$file.man,v;\
	   co Man/RCS/$$file.man,v build/hmmer-$(RELEASE)/Man/$$file.man;\
	done
#
# RCS extraction of Shiva/ testsuite
#
	for file in $(SHIVADIST) Makefile; do\
	   rcs -N$(RELCODE): Shiva/RCS/$$file,v;\
	   co Shiva/RCS/$$file,v build/hmmer-$(RELEASE)/Shiva/$$file;\
	done
# 
# Compilation of documentation: includes hmmer-html.tar.Z and Userguide.ps
# Documentation not provided in source form.
#
	(cd Userguide; make clean)
	(cd Userguide; make)
	cp Userguide/Userguide.ps      build/hmmer-$(RELEASE)/Userguide/
	cp Userguide/hmmer-html.tar.Z  build/hmmer-$(RELEASE)/Userguide/
#
# Packaging commands
#
	tar cvf build/hmmer-$(RELEASE).tar build/hmmer-$(RELEASE)
	$(COMPRESS) build/hmmer-$(RELEASE).tar


# make ftpdist: install FTP distribution. Assumes a "make dist"
#               has already succeeded. Doesn't do the symlink;
#               doesn't install the on-line manual for the Web site.
#
ftpdist:
	cp $(READMES)                   $(FTPDIR)
	cp build/hmmer-$(RELEASE).tar.Z $(FTPDIR)
	cp Userguide/Userguide.ps       $(FTPDIR)
	cp Userguide/hmmer-html.tar.Z   $(FTPDIR)


# make stable: Set up the FTP site symlink to the current stable HMMER release.
#
stable:
	ln -s $(FTPDIR)/hmmer-$(RELEASE).tar.Z $(FTPDIR)/hmmer.tar.Z

# "make clean" removes dreck
# can be used after a "make" to leave a binary distribution, ready to
#   be tar'ed and compressed up.
#
clean:
	-rm -f *.o *~ Makefile.bak core TAGS gmon.out
	(cd Shiva; make clean)
	(cd src; make clean)

# "make veryclean" removes even the binaries directory
#
veryclean:
	-rm -rf binaries
	make clean
