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

i386-linux = linux
alpha      = alpha
iris4d     = sgin
sun4       = sun

u = $($(HOSTTYPE))

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

refmac   =   refmac_$(u)_5
libcheck = libcheck_$(u)_5

tar = $(refmac).tar

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

f_alpha = f77 -O2 -fpe0 -assume dummy_aliases -non_shared -check overflow -check bounds
f_linux = g77 -O1 -fno-second-underscore -fno-globals -fno-automatic -unroll-loops -static
f_sgin = f77 -O1  -n32 -OPT:Olimit=7000 -nocpp  -w -c
f_sun = /opt/SUNWspro/bin/f77 -xlang=f77 -ftrap=%none -Xlist -xcheck=%all -O3 -w -KPIC -fpover=yes
f = $(f_$(u))

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

s_alpha = ALPHA
s_linux = LINUX
s_sgin  = SGIn32
s_sun   = SunOS
s = $(s_$(u))

l = $(CLIB)/

t = tmp_$(u)/

SUBR =                          \
$(t)refmac_newdic.o             \
$(t)solvent_contr_mask.o        \
$(t)hkon_secder_tch.o           \
$(t)fast_hessian_tabulation.o   \
$(t)subvag.o                    \
$(t)lsq_symm_atoms.o            \
$(t)oppro_tor1.o                \
$(t)rcard_tor1.o                \
$(t)subcf_scale1.o              \
$(t)subag_scale_hessian.o       \
$(t)extra_eigen.o               \
$(t)rigid_body_newdic.o         \
$(t)aniso_ref_eigen.o           \
$(t)linalgebra.o                \
$(t)make_CIF.o                  \
$(t)make_subr.o                 \
$(t)make_subr_refmac.o          \
$(t)tls_newdic_non.o            \
$(t)vdw_symmetry.o              \
$(t)make_lib.o                  \
$(t)make_crd.o                  \
$(t)make_new.o                  \
$(t)make_rst.o                  \
$(t)make_PDB.o                  \
$(t)makecif.o                   \
$(t)make_refmac_dummy.o         \
$(t)ls_scaling_double.o         \
$(t)interpolate_mod.o           \
$(t)rharvest.o                  \
$(t)newentry_idealise.o         \
$(t)ml_scaling_double.o         \
$(t)ncs_const.o                 \
$(t)gaussian_int.o              \
$(t)subnumrec.o

LIBR =                          \
$(SUBR)                         \
$(l)libccp4f.a                   \
$(l)libccp4c.a                   \
$(l)libccif.a

SUBL =                          \
$(t)main_libcheck.o             \
$(t)make_subr_2.o               \
$(t)make_subr.o                 \
$(t)make_lib.o                  \
$(t)libcheck.o                  \
$(t)make_PDB.o                  \
$(t)make_CIF.o                  \
$(t)make_new.o                  \
$(t)make_crd.o                  \
$(t)make_unix_ccp4.o            \
$(t)emin.o                      \
$(t)libcheck_min.o

LIBL =                          \
$(SUBL)                         \
$(l)libccp4f.a                  \
$(l)libccp4c.a

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

ed = echo 'g/^CMDW-4.2/s//        /@w@q@' | tr "@" "\012" | ed -s

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

all:                             $(refmac) $(libcheck)

gz:                              $(tar).gz

$(tar).gz:                       $(refmac) $(libcheck)
	                         tar -cvf $(tar) $(refmac) $(libcheck)
	                         gzip --best $(tar)

$(refmac):                       $(t) $(LIBR)
	                         $(f) -o $(refmac) $(LIBR)

$(libcheck):                     $(t) $(LIBL)
	                         $(f) -o $(libcheck) $(LIBL)

$(t):
	                         mkdir $(t)

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

clean:
	                         /bin/rm -f $(SUBR) $(SUBL) oppro_tor1.f rcard_tor1.f

cleanall:
	                         /bin/rm -f $(SUBR) $(SUBL) $(refmac) $(libcheck) $(tar) $(tar).gz

vars:
	                         echo ' ' ; echo u        ; echo $(u)
	                         echo ' ' ; echo refmac   ; echo $(refmac)
	                         echo ' ' ; echo libcheck ; echo $(libcheck)
	                         echo ' ' ; echo f        ; echo $(f)
	                         echo ' ' ; echo l        ; echo $(l)
	                         echo ' ' ; echo s        ; echo $(s)
	                         echo ' ' ; echo t        ; echo $(t)
	                         echo ' ' ; echo SUBR     ; echo $(SUBR)
	                         echo ' ' ; echo LIBR     ; echo $(LIBR)
	                         echo ' ' ; echo SUBL     ; echo $(SUBL)
	                         echo ' ' ; echo LIBL     ; echo $(LIBL)

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

$(t)aniso_ref_eigen.o:           aniso_ref_eigen.f atom_com.fh celsym_aniso.fh celsym.fh const.fh pls_incl.fh refi_flags.fh vitals.fh
	                         $(f) -o $(t)aniso_ref_eigen.o \
	                              -c     aniso_ref_eigen.f

$(t)emin.o:                      emin.f atom_com.fh atom_com_str.fh crd_com.fh emin_version.fh ener_com.fh ref_com.fh ref_com_str.fh rstr_com.fh
	                         $(f) -o $(t)emin.o \
	                              -c     emin.f

$(t)extra_eigen.o:               extra_eigen.f agreem.fh atom_com.fh celsym_aniso.fh celsym.fh const.fh expcost.fh files.fh gaussian.fh refi_flags.fh vitals.fh
	                         $(f) -o $(t)extra_eigen.o \
	                              -c     extra_eigen.f

$(t)fast_hessian_tabulation.o:   fast_hessian_tabulation.f atom_com.fh celsym_aniso.fh celsym.fh hessian_impl.fh pls_incl.fh vitals.fh weights.fh
	                         $(f) -o $(t)fast_hessian_tabulation.o \
	                              -c     fast_hessian_tabulation.f

$(t)gaussian_int.o:              gaussian_int.f
	                         $(f) -o $(t)gaussian_int.o \
	                              -c     gaussian_int.f

$(t)hkon_secder_tch.o:           hkon_secder_tch.f agreem.fh atom_com.fh celsym_aniso.fh celsym.fh cif_incl.fh const.fh hessian_impl.fh monitor.fh ncs_rest.fh occupancy_params.fh pls_incl.fh refi_flags.fh restr_files.fh rharvest.fh save_all_params.fh solvent.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)hkon_secder_tch.o \
	                              -c     hkon_secder_tch.f

$(t)interpolate_mod.o:           interpolate_mod.f
	                         $(f) -o $(t)interpolate_mod.o \
	                              -c     interpolate_mod.f

$(t)libcheck_min.o:              libcheck_min.f atom_com.fh atom_com_str.fh crd_com.fh ener_com.fh lib_com.fh ref_com.fh ref_com_str.fh rstr_com.fh
	                         $(f) -o $(t)libcheck_min.o \
	                              -c     libcheck_min.f

$(t)libcheck.o:                  libcheck.f atom_com.fh crd_com.fh libcheck_version.fh lib_com.fh
	                         $(f) -o $(t)libcheck.o \
	                              -c     libcheck.f

$(t)linalgebra.o:                linalgebra.f atom_com.fh pls_incl.fh
	                         $(f) -o $(t)linalgebra.o \
	                              -c     linalgebra.f

$(t)lsq_symm_atoms.o:            lsq_symm_atoms.f atom_com.fh celsym_aniso.fh celsym.fh cif_incl.fh const.fh monitor.fh ncs_rest.fh pls_incl.fh refi_flags.fh restr_files.fh rharvest.fh vitals.fh weights.fh
	                         $(f) -o $(t)lsq_symm_atoms.o \
	                              -c     lsq_symm_atoms.f

$(t)ls_scaling_double.o:         ls_scaling_double.f agreem.fh celsym_aniso.fh celsym.fh const.fh monitor.fh refi_flags.fh weights.fh
	                         $(f) -o $(t)ls_scaling_double.o \
	                              -c     ls_scaling_double.f

$(t)main_libcheck.o:             main_libcheck.f libcheck_version.fh
	                         $(f) -o $(t)main_libcheck.o \
	                              -c     main_libcheck.f

$(t)makecif.o:                   makecif.f crd_com.fh lib_com.fh makecif_version.fh
	                         $(f) -o $(t)makecif.o \
	                              -c     makecif.f

$(t)make_CIF.o:                  make_CIF.f atom_com.fh atom_com_str.fh CIF_items_crd.fh crd_com.fh metal.fh
	                         $(f) -o $(t)make_CIF.o \
	                              -c     make_CIF.f

$(t)make_crd.o:                  make_crd.f atom_com.fh crd_com.fh lib_com.fh link_com.fh metal.fh
	                         $(f) -o $(t)make_crd.o \
	                              -c     make_crd.f

$(t)make_lib.o:                  make_lib.f CIF_items_lib.fh crd_com.fh lib_com.fh
	                         $(f) -o $(t)make_lib.o \
	                              -c     make_lib.f

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

$(t)make_PDB.o:                  make_PDB.f atom_com.fh crd_com.fh link_com.fh metal.fh
	                         $(f) -o $(t)make_PDB.o \
	                              -c     make_PDB.f

$(t)make_refmac_dummy.o:         make_refmac_dummy.f agreem.fh atom_com.fh const.fh makecif.fh makecif_version.fh ncs_rest.fh refi_flags.fh rharvest.fh solvent.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)make_refmac_dummy.o \
	                              -c     make_refmac_dummy.f

$(t)make_rst.o:                  make_rst.f atom_com.fh atom_com_str.fh crd_com.fh lib_com.fh
	                         $(f) -o $(t)make_rst.o \
	                              -c     make_rst.f

$(t)make_subr_2.o:               make_subr_2.f atom_com.fh crd_com.fh
	                         $(f) -o $(t)make_subr_2.o \
	                              -c     make_subr_2.f

$(t)make_subr.o:                 make_subr.f atom_com.fh crd_com.fh metal.fh
	                         $(f) -o $(t)make_subr.o \
	                              -c     make_subr.f

$(t)make_subr_refmac.o:          make_subr_refmac.f
	                         $(f) -o $(t)make_subr_refmac.o \
	                              -c     make_subr_refmac.f

$(t)make_unix_ccp4.o:            make_unix_ccp4.f
	                         $(f) -o $(t)make_unix_ccp4.o \
	                              -c     make_unix_ccp4.f

$(t)ml_scaling_double.o:         ml_scaling_double.f agreem.fh celsym.fh const.fh expcost.fh monitor.fh refi_flags.fh rharvest.fh weights.fh
	                         $(f) -o $(t)ml_scaling_double.o \
	                              -c     ml_scaling_double.f

$(t)ncs_const.o:                 ncs_const.f atom_com.fh const.fh monitor.fh ncs_rest.fh pls_incl.fh restr_files.fh rharvest.fh vitals.fh weights.fh
	                         $(f) -o $(t)ncs_const.o \
	                              -c     ncs_const.f

$(t)newentry_idealise.o:         newentry_idealise.f agreem.fh atom_com.fh celsym.fh const.fh makecif.fh pls_incl.fh refi_flags.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)newentry_idealise.o \
	                              -c     newentry_idealise.f

$(t)oppro_tor1.o:                oppro_tor1.f agreem.fh atom_com.fh atom_com_str.fh celsym.fh const.fh crd_com.fh expcost.fh makecif.fh map_params.fh monitor.fh ncs_rest.fh pls_incl.fh ref_com_str.fh refi_flags.fh restr_files.fh restr_params.fh weights.fh
	                         $(f) -o $(t)oppro_tor1.o \
	                              -c     oppro_tor1.f

$(t)rcard_tor1.o:                rcard_tor1.f agreem.fh atom_com.fh celsym.fh cif_incl.fh const.fh expcost.fh makecif.fh map_params.fh monitor.fh ncs_rest.fh occupancy_params.fh pls_incl.fh refi_flags.fh restr_files.fh restr_params.fh rharvest.fh rigid_body.fh solvent.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)rcard_tor1.o \
	                              -c     rcard_tor1.f

$(t)refmac_newdic.o:             refmac_newdic.f agreem.fh atom_com.fh celsym_aniso.fh celsym.fh cif_incl.fh const.fh expcost.fh makecif.fh makecif_version.fh monitor.fh pls_incl.fh refi_flags.fh restr_files.fh rharvest.fh vitals.fh weights.fh
	                         $(f) -o $(t)refmac_newdic.o \
	                              -c     refmac_newdic.f

$(t)rharvest.o:                  rharvest.f agreem.fh atom_com.fh celsym.fh const.fh makecif.fh makecif_version.fh ncs_rest.fh pls_incl.fh refi_flags.fh rharvest.fh solvent.fh tls.fh weights.fh
	                         $(f) -o $(t)rharvest.o \
	                              -c     rharvest.f

$(t)rigid_body_newdic.o:         rigid_body_newdic.f agreem.fh atom_com.fh celsym.fh const.fh monitor.fh pls_incl.fh refi_flags.fh restr_files.fh rigid_body.fh vitals.fh
	                         $(f) -o $(t)rigid_body_newdic.o \
	                              -c     rigid_body_newdic.f

$(t)solvent_contr_mask.o:        solvent_contr_mask.f agreem.fh atom_com.fh atom_com_str.fh celsym_aniso.fh celsym.fh const.fh monitor.fh pls_incl.fh refi_flags.fh rharvest.fh solvent.fh vitals.fh weights.fh
	                         $(f) -o $(t)solvent_contr_mask.o \
	                              -c     solvent_contr_mask.f

$(t)subag_scale_hessian.o:       subag_scale_hessian.f agreem.fh atom_com.fh celsym_aniso.fh celsym.fh const.fh monitor.fh pls_incl.fh refi_flags.fh rharvest.fh solvent.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)subag_scale_hessian.o \
	                              -c     subag_scale_hessian.f

$(t)subcf_scale1.o:              subcf_scale1.f agreem.fh atom_com.fh celsym.fh const.fh gaussian.fh pls_incl.fh refi_flags.fh rharvest.fh vitals.fh weights.fh
	                         $(f) -o $(t)subcf_scale1.o \
	                              -c     subcf_scale1.f

$(t)subvag.o:                    subvag.f celsym.fh const.fh
	                         $(f) -o $(t)subvag.o \
	                              -c     subvag.f

$(t)tls_newdic_non.o:            tls_newdic_non.f agreem.fh atom_com.fh celsym_aniso.fh celsym.fh const.fh monitor.fh pls_incl.fh refi_flags.fh restr_files.fh save_all_params.fh tls.fh vitals.fh weights.fh
	                         $(f) -o $(t)tls_newdic_non.o \
	                              -c     tls_newdic_non.f

$(t)vdw_symmetry.o:              vdw_symmetry.f atom_com.fh atom_com_str.fh celsym.fh pls_incl.fh restr_files.fh vitals.fh weights.fh
	                         $(f) -o $(t)vdw_symmetry.o \
	                              -c     vdw_symmetry.f

$(t)subnumrec.o:              subnumrec.f
	                         $(f) -o $(t)subnumrec.o \
	                              -c     subnumrec.f
#--------------------------------------------------------------------------------

