#
# Makefile for program sib-pair
#

PROGRAM	= sib-pair
SRCS	= main.F pedio.F pedcheck.F gener.F datamod.F describe.F \
          linkage.F assoc.F codomin.F mcmc.F dohaplo.F mche.F \
          writers.F io.F services.F eval.F varcom.F
OBJS	= main.o pedio.o pedcheck.o gener.o datamod.o describe.o \
          linkage.o assoc.o codomin.o mcmc.o dohaplo.o mche.o \
          writers.o io.o services.o eval.o varcom.o
MAKEFILE= Makefile
BINDIR = ../bin

PLATFORM= F2C
VER     = 0.99.9
MY_DATE = (27-May-2003)
HEAD_TXT= Version $(VER) $(MY_DATE)
VERSION = "'Version $(VER) $(MY_DATE)'"

DOS-F77	= dos-f77 
WIN-F77	= /home/mingw/bin/mingw32-g77
F77	= f77
FFLAGS	= -Wall -g -O -D$(PLATFORM) -DVERSION=$(VERSION) 
LINKER	= f77 
LDFLAGS	= -pg -O  

#
# Local variables, notably maximum pedigree size, maximum pedigree size for
# relative-pair-wise statistics, maximum number of loci
#

DOSALL = 40
WIDALL = 100
WIDSIZ = 1000
WIDIBD = 1000
WIDLOC = 1000
WIDLIN = 4000
MAXSIZ = 600
MAXIBD = 600
BIGSIZ = 3500
BIGIBD = 3500
BIGLOC = 200


$(PROGRAM): 	$(OBJS)
		$(LINKER) $(LFLAGS) -o $(BINDIR)/$(PROGRAM) $(OBJS) $(LIBS)
		@echo "program $(BINDIR)/$(PROGRAM) built"
$(OBJS): 	$(HEADERS)

clean:
		rm -f $(OBJS)
		@echo "clean"

export:
		cat $(SRCS) | sed -e "s/MAXSIZ=1000/MAXSIZ=$(MAXSIZ)/" \
		                  -e "s/MAXIBD=1000/MAXIBD=$(MAXIBD)/" \
				  -e "s/HEAD_TXT/$(HEAD_TXT)/" \
				  -e "s/VERSION/\'$(VERSION)\'/" \
			      > $(PROGRAM).f
		gzip $(PROGRAM).f
		@echo "created $(PROGRAM).f.gz"

tar:
		tar cyf sib-pair.tar.bz $(SRCS)
		@echo "created $(PROGRAM).tar.bz"

bigalleles:
		cat $(SRCS) | sed -e "s/MAXSIZ=1000/MAXSIZ=$(WIDSIZ)/" -e "s/MAXALL=60/MAXALL=$(WIDALL)/" -e "s/MAXIBD=1000/MAXIBD=$(WIDIBD)/"> b_$(PROGRAM).F
		@echo "created b_$(PROGRAM).F"

wide:
		cat $(SRCS) | sed -e "s/MAXSIZ=1000/MAXSIZ=$(WIDSIZ)/" \
                                  -e "s/MAXLOC=120/MAXLOC=$(WIDLOC)/" \
                                  -e "s/MAXALL=60/MAXALL=$(WIDALL)/" \
                                  -e "s/MAXIBD=1000/MAXIBD=$(WIDIBD)/" \
                                  -e "s/LINSIZ=1024/LINSIZ=$(WIDLIN)/" \
                              > w_$(PROGRAM).F
		f77 -Wall -O -D$(PLATFORM) -DVERSION=$(VERSION) -o $(BINDIR)/w_$(PROGRAM) w_$(PROGRAM).F
		rm w_$(PROGRAM).F
		@echo "created w_$(PROGRAM)"
#		gcc -E -P -DF2C -D$(PLATFORM) -DVERSION=$(VERSION) w_$(PROGRAM).F > w_$(PROGRAM).f

profile:
		cat $(SRCS) > pgsp.F
		f77 -Wall -O3 -pg -g -D$(PLATFORM) -DVERSION=$(VERSION) -o pgsp pgsp.F
		@echo "created profiled version of sib-pair: pgsp"

big:
		cat $(SRCS) | sed -e "s/MAXSIZ=1000/MAXSIZ=$(BIGSIZ)/" -e "s/MAXLOC=120/MAXLOC=$(BIGLOC)/" -e "s/MAXIBD=1000/MAXIBD=$(BIGIBD)/"> bigsp.F
		f77 -Wall -O3 -D$(PLATFORM) -DVERSION=$(VERSION) -o bigsp bigsp.F
		@echo "created bigsp"

dos:
		cat $(SRCS) | sed -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(MAXSIZ)/" -e "s/MAXIBD=1000/MAXIBD=$(MAXIBD)/" -e "s/MAXALL=60/MAXALL=$(DOSALL)/" -e "s/HEAD_TXT/$(HEAD_TXT)/"  -e "s/VERSION/\'$(VERSION)\'/" > $(PROGRAM).F
		gcc -E -P -DF2C $(PROGRAM).F > $(PROGRAM).f
		$(DOS-F77) $(PROGRAM).f 
		@echo "created $(PROGRAM).exe"
		rm -f $(PROGRAM).F $(PROGRAM).f $(PROGRAM).c
		mv $(PROGRAM).exe /home/HTML/Binaries
        
win:
		cat $(SRCS) | sed -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(MAXSIZ)/" -e "s/MAXIBD=1000/MAXIBD=$(MAXIBD)/" -e "s/MAXALL=60/MAXALL=$(DOSALL)/" -e "s/HEAD_TXT/$(HEAD_TXT)/"  -e "s/VERSION/\'$(VERSION)\'/" > $(PROGRAM).F
		gcc -E -P -DF2C $(PROGRAM).F > $(PROGRAM).f
		$(WIN-F77) $(PROGRAM).f 
		@echo "created $(PROGRAM).exe"
		rm -f $(PROGRAM).F $(PROGRAM).f $(PROGRAM).c
		mv a.exe /home/HTML/Binaries/winNTsp.exe

bigdos:
		cat $(SRCS) | sed -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(BIGSIZ)/" -e "s/MAXLOC=120/MAXLOC=$(BIGLOC)/" -e "s/MAXIBD=1000/MAXIBD=$(BIGIBD)/"> bigsp.F
		gcc -E -P -DF2C bigsp.F > bigsp.f
		$(DOS-F77) bigsp.f 
		@echo "created bigsp.exe"
		rm -f bigsp.F bigsp.f bigsp.c
		mv bigsp.exe /home/HTML/Binaries/bigsp.exe

bigwin:
		cat $(SRCS) | sed -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(BIGSIZ)/" -e "s/MAXLOC=120/MAXLOC=$(BIGLOC)/" -e "s/MAXIBD=1000/MAXIBD=$(BIGIBD)/"> bigsp.F
		gcc -E -P -DF2C bigsp.F > bigsp.f
		$(WIN-F77) bigsp.f 
		@echo "created winbigsp.exe"
		rm -f bigsp.F bigsp.f bigsp.c
		mv a.exe /home/HTML/Binaries/winbigsp.exe

widedos:
		cat $(SRCS) | sed  -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(WIDSIZ)/" -e "s/MAXLOC=120/MAXLOC=$(WIDLOC)/" -e "s/MAXIBD=1000/MAXIBD=$(WIDIBD)/" -e "s/LINSIZ=1024/LINSIZ=$(WIDLIN)/" > w_$(PROGRAM).F
		gcc -E -P -DF2C w_$(PROGRAM).F > w_$(PROGRAM).f
		$(DOS-F77) w_$(PROGRAM).f 
		@echo "created w_$(PROGRAM).exe"
		rm -f w_$(PROGRAM).F w_$(PROGRAM).f w_$(PROGRAM).c
		mv w_$(PROGRAM).exe /home/HTML/Binaries

widewin:
		cat $(SRCS) | sed  -e "/isatty/ d" -e "s/MAXSIZ=1000/MAXSIZ=$(WIDSIZ)/" -e "s/MAXLOC=120/MAXLOC=$(WIDLOC)/" -e "s/MAXIBD=1000/MAXIBD=$(WIDIBD)/" -e "s/LINSIZ=1024/LINSIZ=$(WIDLIN)/" > w_$(PROGRAM).F
		gcc -E -P -DF2C w_$(PROGRAM).F > w_$(PROGRAM).f
		$(WIN-F77) w_$(PROGRAM).f 
		@echo "created w_$(PROGRAM).exe"
		rm -f w_$(PROGRAM).F w_$(PROGRAM).f w_$(PROGRAM).c
		mv a.exe /home/HTML/Binaries/w_winsp.exe

