# Makefile for PASIF.x

# Michael E Sparks (mespar1@iastate.edu)
# Last modified: 14 June 2007

# Copyright (C) 2006,2007 Michael E Sparks
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# Relevant directories ########################################################

BIN=../bin
INCLUDE=../include
LIB=../lib
SRC=.

# C compiler of choice ########################################################

#use gcc on serial machines
CC=gcc
#use mpicc on parallel computers
#CC=mpicc

# Compiler flag descriptions ##################################################

#These are set to seemingly reasonable defaults.
# MPI compiles a PASIF for execution on parallel
#   machines with the MPI library installed.
# MPIDBG compiles in code potentially useful for
#   debugging the parallelized version of PASIF.
# SHADOWSTRAND develops a seven-class model for
#   the six coding phases and noncoding sequences.
#   Defining this option REQUIRES for THREEPERIODIC
#   to be set, also!
# STRICTTEST mandates that there be no ambiguous
#   symbols encountered in an input test sequence
#   to compute the smoothed log-probability of.
#   If not set, then a residue is randomly chosen
#   in place of the ambiguous symbol, and that is
#   instead used in computing the estimate.
# THREEPERIODIC compiles IMMpractical to accommodate
#   models taking the periodicity of nucleic acid
#   sequences into account.
# TRACKERROR compiles the learnclassifier utility
#   so that it reports the error resulting from the
#   current state of neuronal weights at each epoch
# VERBOSEPASIF incorporates code to report progress
#   on isoform identification to stderr

CFLAGS=-c -std=c99 -pedantic-errors -O2 -Wall -Werror -I${INCLUDE} \
       -DTHREEPERIODIC \
       -DTRACKERROR \
       -DVERBOSEPASIF \
       #-DMPI \
       #-DMPIDBG \
       #-DSHADOWSTRAND \
       #-DSTRICTTEST \

# Default target ##############################################################

DEFAULT : ${BIN}/PASIF.x ${BIN}/learnclassifier.x

# Objects #####################################################################

STDOBJ=classifiers.o \
       confparsing.o \
       dm_utils.o \
       errors.o \
       fo_utils.o \
       immpractical.o \
       pasif_utils.o \
       sequence_parse.o \
       simplex.o \
       splice_utils.o

classifiers.o : ${SRC}/classifiers.c
	${CC} ${CFLAGS} ${SRC}/classifiers.c -o $@

confparsing.o : ${SRC}/confparsing.c
	${CC} ${CFLAGS} ${SRC}/confparsing.c -o $@

dm_utils.o : ${SRC}/dm_utils.c
	${CC} ${CFLAGS} ${SRC}/dm_utils.c -o $@

errors.o : ${SRC}/errors.c
	${CC} ${CFLAGS} ${SRC}/errors.c -o $@

fo_utils.o : ${SRC}/fo_utils.c
	${CC} ${CFLAGS} ${SRC}/fo_utils.c -o $@

immpractical.o : ${SRC}/immpractical.c
	${CC} ${CFLAGS} ${SRC}/immpractical.c -o $@

pasif_utils.o : ${SRC}/pasif_utils.c
	${CC} ${CFLAGS} ${SRC}/pasif_utils.c -o $@

sequence_parse.o : ${SRC}/sequence_parse.c
	${CC} ${CFLAGS} ${SRC}/sequence_parse.c -o $@

simplex.o : ${SRC}/simplex.c
	${CC} ${CFLAGS} ${SRC}/simplex.c -o $@

splice_utils.o : ${SRC}/splice_utils.c
	${CC} ${CFLAGS} ${SRC}/splice_utils.c -o $@

# Library #####################################################################

# Libraries for driver programs to link with
LINK=-L${LIB} -lm -llib4pasif

# commands for building static library
STDLIB=${LIB}/liblib4pasif.a
${LIB}/liblib4pasif.a : ${STDOBJ}
	ar -rc $@ ${STDOBJ}
	ranlib $@

# PASIF #######################################################################

${BIN}/PASIF.x : ${STDLIB} PASIF.o
	${CC} PASIF.o ${LINK} -o $@

PASIF.o : ${SRC}/PASIF.c
	${CC} ${CFLAGS} ${SRC}/PASIF.c -o $@

# Perceptron training #########################################################

${BIN}/learnclassifier.x : learnclassifier.o classifiers.o errors.o
	${CC} learnclassifier.o classifiers.o errors.o -lm -o $@

learnclassifier.o : ${SRC}/learnclassifier.c
	${CC} ${CFLAGS} ${SRC}/learnclassifier.c -o $@

# Additional targets ##########################################################
clean :
	rm -f ${SRC}/*.o
cleaner : clean
	rm -f ${LIB}/*.a ${BIN}/*.x
redo : cleaner
	make
