#
#	This is Main Makefile for mrcImageROI3D.
#

#### Root Makefile ####
MAKE_ROOT=mrcImageROI3D

#### Input extention ####
INI=ini
OUT=roi

#### Suffixes rule ####
# Defined at Sub

#### INCLUDE ####
# Help-include-file must always be put on top.
-include ${EOS_HOME}/tutorial/TIPS/Help/Makefile/Makefile-lib
-include ${EOS_HOME}/tutorial/TIPS/Debugger/Makefile/Makefile-lib
-include Makefile-lib

#### Definition ####
# Path of Input File
# Basically, use a linked data from /SampleData.
INPUT_PATH=${EOS_HOME}/tutorial/SampleData/1VOM-N.mrc

### FileData
FILE_NAME=Input
OUT_FILE_NAME="$(FILE_NAME)-roi"

### Option ###
## -x
X_START=10
X_END=50
## -y
Y_START=10
Y_END=50
## -z
Z_START=20
Z_END=60

#### Rules of the list created ####
# Defined at Sub

##### Commands #####
# Defined at Sub basically
# By make Initial, Create input data for this command.
Initial::
	make InitialData;

# By make Exe, Execute the sample of this command.
Exe::
	make $(FILE_NAME).$(OUT)

# By make Final, Make visualize Output for this command.
Final::
	make InitialImage;
	make OutputImage

# By make all, Initial -> Exe.
all::
	make Initial;
	make Exe;
	make Final;

help_mrcImageROI3D::
	@echo
	@echo "Makefile for mrcImageROI3D"
	@echo "This is Main Makefile for mrcImageROI3D."
	@echo
	@echo "	(Command):"
	@echo "		Initial:		Create input data for this command."
	@echo "			(Setting Data):"
	@echo "			INI:		input extention for Initial"
	@echo "			OUT:		output extention"
	@echo
	@echo "		Exe:			Execute the sample of this command."
	@echo "			(Setting Data):"
	@echo "			X_START:	-x: start of x"
	@echo "			X_END:		-x: end of x"
	@echo "			Y_START:	-x: start of y"
	@echo "			Y_END:		-x: end of y"
	@echo "			Z_START:	-x: start of z"
	@echo "			Z_END:		-x: end of z"
	@echo
	@echo "		Final:			Make visualize Output for this command."
	@echo
	@echo "		all:			Initial -> Exe."
	@echo
	@echo "	(Setting Data):"
	@echo "		FILE_NAME:		filename of input"
	@echo "		OUT_FILE_NAME:		filename of output"

##### Commands(Input to Output) #####
# Defined at Sub
.$(INI).$(OUT):
	@if [ ! -z "$(X_START)" -a ! -z "$(X_END)" ] ; then \
		OPTION="$$OPTION -x $(X_START) $(X_END)"; \
	fi; \
	if [ ! -z "$(Y_START)" -a ! -z "$(Y_END)" ] ; then \
		OPTION="$$OPTION -y $(Y_START) $(Y_END)"; \
	fi; \
	if [ ! -z "$(Z_START)" -a ! -z "$(Z_END)" ] ; then \
		OPTION="$$OPTION -z $(Z_START) $(Z_END)"; \
	fi; \
	echo "mrcImageROI3D -i $*.$(INI) -o $(OUT_FILE_NAME).$(OUT) $$OPTION"; \
	mrcImageROI3D -i $*.$(INI) -o $(OUT_FILE_NAME).$(OUT) $$OPTION;
