#  Makefile for DOCK

include ../../install/rules.h
include ../../install/config.h

BIN= ../../bin
PROGS= dock6$(SFX)

OBJS= amber_typer.o base_mpi.o base_score.o conf_gen.o dock.o dockmol.o \
      library_file.o master_score.o orient.o score.o simplex.o sphere.o \
      score_solvent.o score_amber.o sasa.o score_chemgrid.o utils.o

all:  $(PROGS)

install:  all
	mv $(PROGS) $(BIN)

clean:
	-/bin/rm -f $(OBJS)
	cd nab && make clean

realclean:  clean
	-/bin/rm -f $(PROGS)

uninstall:
	-cd $(BIN) && /bin/rm -f $(PROGS)

dock6$(SFX):  configured $(OBJS) nab_objects
	$(LOAD) $(CFLAGS) -o $@ $(OBJS) nab/nab.a $(LIBS) $(DOCKBUILDFLAGS)

nab_objects:
	cd nab && make

# Since the header file scheme of dock is unusual, these dependencies
# may not be complete.
amber_typer.o:  amber_typer.h
base_mpi.o:     base_mpi.h
base_score.o:   base_score.h
conf_gen.o:     conf_gen.h
dock.o:         dock.h
dockmol.o:      dockmol.h
library_file.o: library_file.h
master_score.o: master_score.h
orient.o:       orient.h sphere.h
sasa.o:         sasa.h
score.o:        score.h
score_amber.o:  score_amber.h
score_chemgrid.o:  score_chemgrid.h
score_solvent.o: score_solvent.h
simplex.o:      simplex.h
utils.o:        utils.h

CONFIG_COMMAND=cd ../../install; ./configure
CONFIG_FILE=../../install/config.h
configured:
	@# abort if the configuration file does not exist
	@(if [ ! -f $(CONFIG_FILE) ] ; then \
	    echo "Error: $(CONFIG_COMMAND) must be executed before make !" ;\
	    exit 2 ;\
	fi ;\
	)

