# $Id: Makefile,v 1.8 2004/04/02 12:17:43 harry Exp $
#
# Makefile for DPS to MOSFLM, Harry Powell
#
# This goes in the top level directory of the MOSFLM distribution with DPS
# indexing.
#
# This has been tested under OSF on an Alpha, Irix 5.3 and 6.2 on SGI, and
# Linux on a Pentium PC. The expected "HOSTTYPE"s are "alpha", "iris4d", 
# "iris4d6.4"
# and "i386-linux" (linked to i486-linux). It's possible that you might have to 
# include another type for MOSFLM to build on your system.
# 
#-----------------------------------------------------------------------------
#

#ifndef MOSHOME
MOSHOME = ${PWD}
#endif
RANLIB  = /usr/bin/ranlib
DPSLIBS = lib/DPSLIB.a
CBFLIBS = cbf/lib/libcbf.a
JPGLIBS = jpg/libjpeg.a

all:	
	make libs
	cd mosflm ; make

##########################################################################
#                                                                        #
# NOTE WELL! Digital UNIX, OSF/1, Linux don't need the -print for "find" #
#            to work properly below, but IRIX does!                      #
#                                                                        #
##########################################################################

dpslibs:
	touch index/junk.a src/junk.a lib/junk.a util/junk.a cbf/junk.a
	rm -f `find ./index -name "*.a" -print`
	rm -f `find ./src -name "*.a" -print`
	rm -f `find ./lib -name "*.a" -print`
	rm -f `find ./util -name "*.a" -print`
	cd index ; make
	if [ -f $(RANLIB) ]; then $(RANLIB) lib/DPSLIB.a ; fi
	rm -f lib/libdps_bravais.a lib/libdps_index.a lib/libfilec.a \
	lib/libfftpack.a lib/libdps.a

cbflibs:
	rm -f `find ./cbf -name "*.a" -print`
	cd cbf ; make ; if [ -f $(RANLIB) ]; \
	then $(RANLIB) lib/libcbf.a; fi

jpglibs:
	cd jpg ; ./configure ; make libjpeg.a

${DPSLIBS}:
	make dpslibs

${CBFLIBS}:
	make cbflibs

${JPGLIBS}:
	make jpglibs

libs:	${DPSLIBS} ${CBFLIBS} ${JPGLIBS}
	@echo "****************************************************************"
	@echo "             Making libraries for system ${HOSTTYPE}"
	@echo "****************************************************************"

ipmosflm: libs
	@echo "****************************************************************"
	@echo "           Making IPMOSFLM for system ${HOSTTYPE}"
	@echo "****************************************************************"
	cd mosflm ; make ipmosflm

force:
	rm bin/ipmosflm
	make ipmosflm

install:
	@echo "the executable is in ${MOSHOME}/bin/ipmosflm"

clean:
	rm -f `find . -name "*.o" -print`

distclean:
	touch ${MOSHOME}/junk.o ${MOSHOME}/junk.a ${MOSHOME}/junk~
	rm -f `find ${MOSHOME} -name "*.a" -print`
	rm -f `find ${MOSHOME} -name "*.o" -print`
	rm -f `find ${MOSHOME} -name "*~" -print`
	cd ${JPG}; if [ -f Makefile ];then make distclean;fi
	rm -f bin/ipmosflm
