#
#	This is Sub Makefile for FFTExpression.
#
#		Created by template v2.0.2p0050
#

#### Input extention ####
# Defined at Main

#### Suffixes rule ####
.SUFFIXES: .$(IN_FFTEX) .$(FFTEX) .$(OUT_FFTEX)

#### INCLUDE ####
# Use TIPS File.
-include ${EOS_HOME}/tutorial/TIPS/Projection3DImage/Makefile/Makefile-lib

#### Definition ####
# Defined at Main

#### Rules of the list created ####

##### Commands #####
FFTExpression::
	make $(FFTEX_FILE_NAME).$(OUT_FFTEX);

help_FFTExpression::
	@echo
	@echo "FFTExpression"
	@echo "This is Sub Makefile for FFTExpression."
	@echo
	@echo "	(Command):"
	@echo "		FFTExpression:		Express the power spectrum of Real or Fourier image."
	@echo
	@echo "	(Setting Data):"
	@echo "		FFTEX_FILE_NAME:	Input and output file name."
	@echo "		IN_FFTEX:		Input file for FFT.(if it is  already FFT, link it to the FFTEX.)"
	@echo "		FFTEX:			FFT file."
	@echo "		OUT_FFTEX:		Expression image file for FFT."
	@echo

##### Commands(Input to Output) #####
ifdef IN_FFTEX
ifdef FFTEX
.$(IN_FFTEX).$(FFTEX):
	filetype=$$(mrcInfo -i $*.$(IN_FFTEX) | head -2 | tail -1 | awk '{printf("%s", $$3)}'); \
	if [ "$${filetype}" = "0" -o "$${filetype}" = "1" -o "$${filetype}" = "2" ] ; then \
		echo "Real Image -> Fourier Image"; \
		mrcImageFFT -i $*.$(IN_FFTEX) -o $*.$(FFTEX); \
	elif [ "$${filetype}" = "3" -o "$${filetype}" = "4" -o "$${filetype}" = "5" ] ; then \
		echo "Fourier Image"; \
		$(RM) $*.$(FFTEX); \
		ln -s $*.$(IN_FFTEX) $*.$(FFTEX); \
	else \
		echo "Neither Real Image nor Fourier Image."; \
	fi;
endif #FFTEX
endif #IN_FFT_EX

ifdef FFTEX
ifdef OUT_FFTEX
.$(FFTEX).$(OUT_FFTEX):
	mrcFFTExpression -i $*.$(FFTEX) -o $*.$(FFTEX)ex -m 1;
	export PRJ_FILE_NAME=$*; \
	export IN_PRJ=$(FFTEX)ex; \
	export OUT_PRJ=$(OUT_FFTEX); \
	make Projection3DImage;
endif #OUT_FFTEX
endif #FFTEX
