# Makefile for MAKECIF

#
# For unix
#
# Use `make makecif'      to build makecif program.
# Use `make libcheck'     to build sir program.
# Use `make modcheck'     to build modcheck program.
# Use `make emin'         to build emin program
#
# For unix with CCP4
#
# Use `make makecif_ccp4'      to build makecif program.
# Use `make libcheck_ccp4'     to build sir program.
# Use `make modcheck_ccp4'     to build modcheck program.
# Use `make emin_ccp4'         to build emin program
#
# For Linux
#
# Use `make makecif_ln'      to build makecif program.
# Use `make libcheck_ln'     to build sir program.
# Use `make modcheck_ln'     to build modcheck program.
# Use `make emin_ln'         to build emin program
#
# Use `make clean'    to remove objects
#
MAKECIF = `cd ..;pwd`
BIN = $(MAKECIF)/bin

F77 = f77 -trapuv -O2 -NC198

C77 = f77 -32 -trapuv -O2 -NC198

#L77 = fort77 -Nn2406 -Nx1200 -NC198
L77 = f77 -O 

clean:
	rm -f temp_makecif_path.fh
	rm -f $(BIN)/*
	rm -f ./*.o
	rm -f ./*~ ./#*

# ------------- unix ( not for ccp4 ) --------------

makecif: make_edit mkcif

libcheck: make_edit lbcheck

modcheck: make_edit mdcheck

emin: make_edit emn

make_edit:
	sed -e "s|+'|+'$(MAKECIF)|" \
	makecif_path.fh > temp_makecif_path.fh

main_makecif.o: main_makecif.f makecif_version.fh
	$(F77) -c main_makecif.f

make_subr.o: make_subr.f atom_com.fh
	$(F77) -c make_subr.f 

make_subr_2.o: make_subr_2.f
	$(F77) -c make_subr_2.f 

make_set_path.o: make_set_path.f temp_makecif_path.fh
	$(F77) -c make_set_path.f 

make_lib.o: make_lib.f lib_com.fh 
	$(F77) -c -Olimit 2000 make_lib.f

make_rst.o: make_rst.f  lib_com.fh crd_com.fh atom_com.fh
	$(F77) -c make_rst.f 

make_crd.o: make_crd.f  lib_com.fh atom_com.fh link_com.fh metal.fh 
	$(F77) -c make_crd.f 

make_vdw.o: make_vdw.f  lib_com.fh atom_com.fh crd_com.fh 
	$(F77) -c make_vdw.f 

make_unix.o: make_unix.f 
	$(F77) -c make_unix.f 


make_new.o: make_new.f  lib_com.fh crd_com.fh link_com.fh atom_com.fh metal.fh CIF_items_crd.fh
	$(F77) -c make_new.f 

make_PDB.o: make_PDB.f  crd_com.fh atom_com.fh link_com.fh lib_com.fh metal.fh
	$(F77) -c make_PDB.f 

make_CIF.o: make_CIF.f  crd_com.fh atom_com.fh lib_com.fh CIF_items_crd.fh
	$(F77) -c  -Olimit 2000 make_CIF.f 

makecif.o: makecif.f  lib_com.fh crd_com.fh 
	$(F77) -c makecif.f  

make_DPDB.o: make_DPDB.f  lib_com.fh atom_com.fh 
	$(F77) -c make_DPDB.f  

mkcif: main_makecif.o make_lib.o make_set_path.o make_vdw.o make_CIF.o make_crd.o make_new.o make_rst.o make_PDB.o makecif.o make_unix.o make_subr_2.o make_subr.o
	$(F77) -o ../bin/makecif main_makecif.o makecif.o make_set_path.o make_vdw.o make_CIF.o make_PDB.o make_crd.o make_new.o make_rst.o make_unix.o make_subr_2.o make_subr.o make_lib.o
# -------------
libcheck.o: libcheck.f  lib_com.fh crd_com.fh 
	$(F77) -c -trapuv -O2 libcheck.f

main_libcheck.o: main_libcheck.f libcheck_version.fh 
	$(F77) -c  -trapuv -O2 main_libcheck.f

lbcheck: main_libcheck.o make_subr_2.o make_subr.o make_lib.o libcheck.o make_DPDB.o make_PDB.o make_CIF.o make_new.o make_set_path.o make_crd.o make_unix.o
	$(F77) -o ../bin/libcheck main_libcheck.o libcheck.o make_PDB.o make_CIF.o make_new.o make_DPDB.o make_set_path.o make_crd.o make_lib.o make_unix.o make_subr_2.o make_subr.o
# ------------

emin.o: emin.f crd_com.fh atom_com.fh
	$(F77) -c emin.f 
emin_subr.o: emin_subr.f 
	$(F77) -c emin_subr.f 
main_emin.o: main_emin.f 
	$(F77) -c main_emin.f 

emn: main_emin.o emin.o emin_subr.o make_unix.o make_set_path.o make_CIF.o make_subr_2.o make_subr.o
	$(F77) -o ../bin/emin main_emin.o emin.o make_set_path.o make_CIF.o emin_subr.o make_unix.o make_subr_2.o make_subr.o

# -------------

modcheck.o: modcheck.f crd_com.fh atom_com.fh
	$(F77) -c modcheck.f 
mod_subr.o: mod_subr.f 
	$(F77) -c mod_subr.f 
main_modcheck.o: main_modcheck.f 
	$(F77) -c main_modcheck.f 

mdcheck: main_modcheck.o modcheck.o mod_subr.o make_CIF.o make_set_path.o make_unix.o make_subr_2.o make_subr.o 
	$(F77) -o ../bin/modcheck main_modcheck.o make_CIF.o modcheck.o make_set_path.o mod_subr.o make_unix.o make_subr_2.o make_subr.o  

# ------------- unix ( for ccp4 ) --------------

makecif_ccp4: make_edit mkcif_ccp4

libcheck_ccp4: make_edit lbcheck_ccp4

modcheck_ccp4: make_edit mdcheck_ccp4

emin_ccp4: make_edit emn_ccp4
# -------------

main_makecif_c.o: main_makecif.f makecif_version.fh
	$(C77) -c main_makecif.f

make_subr_c.o: make_subr.f atom_com.fh 
	$(C77) -c make_subr.f 

make_subr_2_c.o: make_subr_2.f
	$(C77) -c make_subr_2.f 

make_set_path_c.o: make_set_path.f temp_makecif_path.fh
	$(C77) -c make_set_path.f 

make_lib_c.o: make_lib.f lib_com.fh
	$(C77) -c -Olimit 2000 make_lib.f

make_rst_c.o: make_rst.f  lib_com.fh crd_com.fh atom_com.fh
	$(C77) -c make_rst.f 

make_crd_c.o: make_crd.f  lib_com.fh atom_com.fh link_com.fh metal.fh 
	$(C77) -c make_crd.f 

make_vdw_c.o: make_vdw.f  lib_com.fh atom_com.fh crd_com.fh 
	$(C77) -c make_vdw.f 

make_new_c.o: make_new.f  lib_com.fh crd_com.fh link_com.fh atom_com.fh metal.fh CIF_items_crd.fh
	$(C77) -c make_new.f 

make_PDB_c.o: make_PDB.f  crd_com.fh atom_com.fh link_com.fh lib_com.fh metal.fh
	$(C77) -c make_PDB.f 

make_CIF_c.o: make_CIF.f  crd_com.fh atom_com.fh lib_com.fh CIF_items_crd.fh
	$(C77) -c make_CIF.f 

makecif_c.o: makecif.f  lib_com.fh crd_com.fh 
	$(C77) -c makecif.f  

make_unix_c.o: make_unix.f 
	$(C77) -c make_unix.f 

make_DPDB_c.o: make_DPDB.f  lib_com.fh atom_com.fh 
	$(C77) -c make_DPDB.f  

mkcif_ccp4: main_makecif_c.o make_lib_c.o make_vdw_c.o make_CIF_c.o make_crd_c.o make_new_c.o make_rst_c.o  make_set_path_c.o make_PDB_c.o make_unix_c.o makecif_c.o make_subr_2_c.o make_subr_c.o
	$(C77) -o ../bin/makecif main_makecif.o makecif.o make_vdw.o make_CIF.o make_PDB.o make_crd.o make_new.o make_set_path.o make_rst.o make_lib.o make_unix.o make_subr_2.o make_subr.o

# -------------

libcheck_c.o: libcheck.f  lib_com.fh crd_com.fh 
	$(C77) -c libcheck.f  

main_libcheck_c.o: main_libcheck.f libcheck_version.fh 
	$(C77) -c main_libcheck.f  

lbcheck_ccp4: main_libcheck_c.o make_subr_2_c.o make_subr_c.o make_lib_c.o libcheck_c.o make_DPDB_c.o make_PDB_c.o make_CIF_c.o make_new_c.o make_set_path_c.o make_crd_c.o make_unix_c.o 
	$(C77) -o ../bin/libcheck main_libcheck.o libcheck.o make_PDB.o make_CIF.o make_new.o make_DPDB.o make_set_path.o make_crd.o make_lib.o make_unix.o make_subr_2.o make_subr.o
# ------------

emin_c.o: emin.f crd_com.fh atom_com.fh
	$(C77) -c emin.f 
emin_subr_c.o: emin_subr.f 
	$(C77) -c emin_subr.f 
main_emin_c.o: main_emin.f 
	$(C77) -c main_emin.f 

emn_ccp4: main_emin_c.o emin_c.o make_subr_2_c.o  make_set_path_c.o  make_CIF_c.o make_subr_c.o make_unix_c.o emin_subr_c.o 
	$(C77) -o ../bin/emin main_emin.o emin.o make_set_path.o  make_CIF.o emin_subr.o make_unix.o make_subr_2.o make_subr.o
# -------------

modcheck_c.o: modcheck.f crd_com.fh atom_com.fh
	$(C77) -c modcheck.f 
mod_subr_c.o: mod_subr.f 
	$(C77) -c mod_subr.f 
main_modcheck_c.o: main_modcheck.f 
	$(C77) -c main_modcheck.f

mdcheck_ccp4: main_modcheck_c.o modcheck_c.o  make_set_path_c.o  make_CIF_c.o make_subr_2_c.o make_subr_c.o mod_subr_c.o make_unix_c.o
	$(C77) -o ../bin/modcheck main_modcheck.o make_set_path.o  make_CIF.o modcheck.o make_unix.o mod_subr.o make_subr_2.o make_subr.o

# -------------

# ----------- Linux ----------------

makecif_ln: make_edit mkcif_ln

libcheck_ln: make_edit lbcheck_ln

modcheck_ln: make_edit mdcheck_ln

emin_ln: make_edit emn_ln
# -------------

main_makecif_l.o: main_makecif.f makecif_version.fh
	$(L77) -c main_makecif.f

make_subr_l.o: make_subr.f atom_com.fh temp_makecif_path.fh
	$(L77) -c make_subr.f 

make_subr_2_l.o: make_subr_2.f
	$(L77) -c make_subr_2.f 

make_lib_l.o: make_lib.f lib_com.fh
	$(L77) -c make_lib.f

make_rst_l.o: make_rst.f  lib_com.fh crd_com.fh atom_com.fh
	$(L77) -c make_rst.f 

make_crd_l.o: make_crd.f  lib_com.fh atom_com.fh link_com.fh metal.fh 
	$(L77) -c make_crd.f 

make_vdw_l.o: make_vdw.f  lib_com.fh atom_com.fh crd_com.fh 
	$(L77) -c make_vdw.f 

make_set_path_l.o: make_set_path.f temp_makecif_path.fh
	$(L77) -c make_set_path.f 

make_new_l.o: make_new.f  lib_com.fh crd_com.fh link_com.fh atom_com.fh metal.fh CIF_items_crd.fh
	$(L77) -c make_new.f 

make_PDB_l.o: make_PDB.f  crd_com.fh atom_com.fh link_com.fh lib_com.fh metal.fh
	$(L77) -c make_PDB.f 

make_CIF_l.o: make_CIF.f  crd_com.fh atom_com.fh lib_com.fh CIF_items_crd.fh
	$(L77) -c make_CIF.f 

makecif_l.o: makecif.f  lib_com.fh crd_com.fh 
	$(L77) -c makecif.f  

make_linux.o: make_unix.f
	$(L77) -c make_unix.f  

make_DPDB_l.o: make_DPDB.f  lib_com.fh atom_com.fh 
	$(L77) -c make_DPDB.f  

mkcif_ln: main_makecif_l.o make_lib_l.o make_vdw_l.o make_CIF_l.o make_set_path_l.o make_crd_l.o make_new_l.o make_rst_l.o make_PDB_l.o make_linux.o makecif_l.o make_subr_2_l.o make_subr_l.o
	$(L77) -o ../bin/makecif main_makecif.o make_set_path_c.o makecif.o make_vdw.o make_CIF.o make_PDB.o make_crd.o make_new.o make_rst.o make_lib.o make_unix.o make_subr_2.o make_subr.o

# -------------

libcheck_l.o: libcheck.f  lib_com.fh crd_com.fh 
	$(L77) -c libcheck.f  

main_libcheck_l.o: main_libcheck.f libcheck_version.fh 
	$(L77) -c main_libcheck.f  

lbcheck_ln: main_libcheck_l.o make_subr_2_l.o make_subr_l.o make_lib_l.o libcheck_l.o make_DPDB_l.o make_PDB_l.o make_CIF_l.o make_new_l.o make_crd_l.o make_linux.o 
	$(L77) -o ../bin/libcheck main_libcheck.o libcheck.o make_PDB.o make_CIF.o make_new.o make_DPDB.o make_crd.o make_lib.o make_unix.o make_subr_2.o make_subr.o
# ------------

emin_l.o: emin.f crd_com.fh atom_com.fh
	$(L77) -c emin.f 
emin_subr_l.o: emin_subr.f 
	$(L77) -c emin_subr.f 
main_emin_l.o: main_emin.f 
	$(L77) -c main_emin.f 

emn_ln: main_emin_l.o emin_l.o make_subr_2_l.o make_subr_l.o  make_CIF_l.o make_linux_l.o emin_subr_l.o emin_subr_l.o  
	$(L77) -o ../bin/emin main_emin.o emin.o emin_subr.o  make_CIF.o make_unix.o make_subr_2.o make_subr.o
# -------------

modcheck_l.o: modcheck.f crd_com.fh atom_com.fh
	$(L77) -c modcheck.f 
mod_subr_l.o: mod_subr.f 
	$(L77) -c mod_subr.f 
main_modcheck_l.o: main_modcheck.f 
	$(L77) -c main_modcheck.f

mdcheck_ln: main_modcheck_l.o modcheck_l.o make_subr_2_l.o  make_CIF_l.o mod_subr_l.o mod_subr_l.o make_linux_l.o
	$(L77) -o ../bin/modcheck main_modcheck.o modcheck.o make_CIF.o make_unix.o mod_subr.o make_subr_2.o make_subr.o

# =======================================











