### $Id: Makefile,v 1.5 2006/04/14 01:48:26 thompson Exp $

# Change the following macros to where MORGAN and the examples 
# are installed on your system.
# This is the only change you need to make in this file.

MORGANDIR = /Users/thompson/Castor/MORGAN_3_CVS_2011/
EXAMPLEDIR = `pwd`
BINDIR = ~/bin

# Note: the paths may happen to be same for MORGANDIR and EXAMPLEDIR. 
# In general they are different: 
#          MORGANDIR is where MORGAN is installed on your system
#          EXAMPLEDIR is the MORGAN_Examples directory you have made
#          BINDIR is your bin directory
# BINDIR is needed only if you prefer to link to executables from your
#    bin directory, rather than running from a current directory: for
#    example, if your current directory is not in your standard path.

# ===== No editing necessary below. ======

LMAUTO = $(MORGANDIR)/Autozyg/lm_auto
LMPVAL = $(MORGANDIR)/Autozyg/lm_pval
LMIBD  = $(MORGANDIR)/Autozyg/lm_ibdtests
LMMAP  = $(MORGANDIR)/Autozyg/lm_map

LMBAYE = $(MORGANDIR)/Lodscore/lm_bayes
LMMRKS = $(MORGANDIR)/Lodscore/lm_markers
LMMULT = $(MORGANDIR)/Lodscore/lm_multiple

PEDCHK = $(MORGANDIR)/PedComp/pedcheck
KIN    = $(MORGANDIR)/PedComp/kin

GENEDP = $(MORGANDIR)/Genedrop/genedrop
IBDDRP = $(MORGANDIR)/Genedrop/ibddrop
MRKDRP = $(MORGANDIR)/Genedrop/markerdrop

MULVAR = $(MORGANDIR)/PolyEM/multivar

RM = rm -f
UL = $(RM)

SHELL = sh


PROGRAMS = $(LMBAYE) $(LMMRKS) $(LMMULT) $(PEDCHK) $(KIN)\
$(GENDRP) $(IBDDRP) $(MRKDRP) $(MULVAR) $(LMPVAL) $(LM_AUTO) $(LMIBD)\
$(LMMAP)

# help information

help :
	@echo " "
	@echo "First make symbolic links to the MORGAN executables: "
	@echo "1. Edit the Makefile, defining MORGANDIR to be the  "
	@echo "   directory main MORGAN directory on your system,  "
	@echo "   and EXAMPLEDIR to be your MORGAN_Examples directory"
	@echo "   (For alternatives using a bin directory: try "
	@echo "          make help.links)                      "
	@echo " "
	@echo "2: use the make command:"
	@echo "          make links "
	@echo " "
	@echo "3: You should now be able to run examples:"
	@echo " In the current setup, examples are run from a subdirectory"
	@echo " For example first "
	@echo "         cd Pedcheck"
	@echo " to move into that subdirectory. Then say  "
	@echo "         pedcheck "
	@echo " to run the program pedcheck"
	@echo "(As yet, this simply checks the link is there: "
	@echo "    we have not yet given it any input data !)"
	@echo " "
	@echo "4: This will work provided the current directory is in your "
	@echo "   PATH. In case is is not:"
	@echo "EITHER  use ./xxxx to run the program xxxx "
	@echo "for example: ./pedcheck to run pedcheck in subdirectory Pedcheck"
	@echo "OR      make alternative links in BINDIR using"
	@echo "    make binlinks "
	@echo "See the README_examples file for details or "
	@echo "     make help.links "
	@echo " "
	@echo "5.  After running your examples you may "
	@echo "       make clean"
	@echo " to remove generated files in subdirectories,"
	@echo " and "
	@echo "    make ultraclean"
	@echo " to remove both extra files and program links"
	@echo " Note these commands remove also any files containing *out*"
	@echo "  from any subdirectory of EXAMPLEDIR"

# additional help information regarding executable links

help.links :
	@echo "Information regarding executable links:"
	@echo "THIS INFO IS NEEDED ONLY IF HAVING PROBLEMS WITH "
	@echo "  RUNNING PROGRAMS AFTER USING    make links "
	@echo "For simplicity, we describe the following with reference "
	@echo "   to the pedcheck program in the Pedcheck subdirectory of "
	@echo "   MORGAN_Examples  (i.e. EXAMPLEDIR)"
	@echo " "
	@echo "1. You, or your system administrator, may prefer that"
	@echo "  you do not have your current directory in your PATH"
	@echo "In this case you may either run an executable link "
	@echo "  pedcheck in a current directory by saying ./pedcheck"
	@echo "Or, you may prefer to set links from your bin directory,"
	@echo "   which should always be in your path."
	@echo " "
	@echo "2. Two useful unix commands: "
	@echo "(a)    printenv PATH     "
	@echo "   will print your current search path for executables"
	@echo "(b)    which pedcheck    "
	@echo "   will tell you which executable pedcheck (if any) the "
	@echo "   system will run when the command "
	@echo "       pedcheck "
	@echo "   is invoked."
	@echo " "
	@echo "3. To make links from your bin directory: "
	@echo "(a) set MORGANDIR as above, to the installed MORGAN programs"
	@echo "    set EXAMPLEDIR as above, to the MORGAN_Examples directory"
	@echo "    and also set BINDIR to your bin directory."
	@echo " "
	@echo "(b) To make the links: say "
	@echo "        make binlinks"
	@echo " "
	@echo "4. Note that the "
	@echo "        make ultraclean "
	@echo "   command will remove exectable links (if such exist) "
	@echo "   both from BINDIR and the relevant subdirectories of "
	@echo "   EXAMPLEDIR  (i.e. This MORGAN_Examples directory)."

# 2. making links to executables

links : $(PROGRAMS)
	ln -sf $(LMAUTO) $(EXAMPLEDIR)/IBD/lm_auto
	ln -sf $(LMPVAL) $(EXAMPLEDIR)/TraitTests/lm_pval
	ln -sf $(LMIBD)  $(EXAMPLEDIR)/TraitTests/lm_ibdtests
	ln -sf $(LMMAP)  $(EXAMPLEDIR)/Map/lm_map
	ln -sf $(LMBAYE) $(EXAMPLEDIR)/Lodscores/lm_bayes
	ln -sf $(LMMRKS) $(EXAMPLEDIR)/Lodscores/lm_markers
	ln -sf $(LMMULT) $(EXAMPLEDIR)/Lodscores/lm_multiple
	ln -sf $(PEDCHK) $(EXAMPLEDIR)/Pedcheck/pedcheck
	ln -sf $(GENEDP) $(EXAMPLEDIR)/Simulation/genedrop
	ln -sf $(MRKDRP) $(EXAMPLEDIR)/Simulation/markerdrop
	ln -sf $(IBDDRP) $(EXAMPLEDIR)/IBD/ibddrop
	ln -sf $(KIN) $(EXAMPLEDIR)/IBD/kin
	ln -sf $(MULVAR) $(EXAMPLEDIR)/PolyEM/multivar

#3.  Alternative links in a bin directory:

binlinks: $(PROGRAMS)
	ln -sf $(LMAUTO) $(BINDIR)/lm_auto
	ln -sf $(LMPVAL) $(BINDIR)/lm_pval
	ln -sf $(LMIBD)  $(BINDIR)/lm_ibdtests
	ln -sf $(LMMAP)  $(BINDIR)/lm_map
	ln -sf $(LMBAYE) $(BINDIR)/lm_bayes
	ln -sf $(LMMRKS) $(BINDIR)/lm_markers
	ln -sf $(LMMULT) $(BINDIR)/lm_multiple
	ln -sf $(PEDCHK) $(BINDIR)/pedcheck
	ln -sf $(GENEDP) $(BINDIR)/genedrop
	ln -sf $(IBDDRP) $(BINDIR)/ibddrop
	ln -sf $(MRKDRP) $(BINDIR)/markerdrop
	ln -sf $(KIN) $(BINDIR)/kin
	ln -sf $(MULVAR) $(BINDIR)/multivar

# 4. making clean etc.

clean:
	$(RM) */*.oped */*out*

ultraclean:
	$(RM) */*.oped  */*out* *.oped
	$(UL) $(EXAMPLEDIR)/Lodscores/lm_multiple
	$(UL) $(EXAMPLEDIR)/Lodscores/lm_markers 
	$(UL) $(EXAMPLEDIR)/Lodscores/lm_bayes 
	$(UL) $(EXAMPLEDIR)/PolyEM/multivar 
	$(UL) $(EXAMPLEDIR)/Simulation/genedrop 
	$(UL) $(EXAMPLEDIR)/Simulation/markerdrop 
	$(UL) $(EXAMPLEDIR)/IBD/ibddrop 
	$(UL) $(EXAMPLEDIR)/IBD/kin 
	$(UL) $(EXAMPLEDIR)/Pedcheck/pedcheck 
	$(UL) $(EXAMPLEDIR)/TraitTests/lm_pval 
	$(UL) $(EXAMPLEDIR)/IBD/lm_auto
	$(UL) $(EXAMPLEDIR)/TraitTests/lm_ibdtests 
	$(UL) $(EXAMPLEDIR)/Map/lm_map
	$(UL) $(BINDIR)/lm_markers 
	$(UL) $(BINDIR)/lm_bayes 
	$(UL) $(BINDIR)/multivar 
	$(UL) $(BINDIR)/genedrop 
	$(UL) $(BINDIR)/markerdrop 
	$(UL) $(BINDIR)/ibddrop 
	$(UL) $(BINDIR)/kin 
	$(UL) $(BINDIR)/pedcheck 
	$(UL) $(BINDIR)/lm_pval 
	$(UL) $(BINDIR)/lm_auto
	$(UL) $(BINDIR)/lm_ibdtests 
	$(UL) $(BINDIR)/lm_map

morgan.help :
	@echo " "
	@echo " To run the MORGAN examples: "
	@echo " "
	@echo " The options using make have been removed."
	@echo " Instead, it is recommended that symbolic links "
	@echo "   are made to  program executables, and that"
	@echo "   the basic examples all be run as described "
	@echo "   in the Tutorial and in the README_examples file. "
	@echo "  "

