DST?=kazan-122b

CPUS?=4
MEM?=1536
DEPTH?=16
IMCOMP?=zip
ENCOMP?=DEFLATE
RGBPROFILE?=../../tools/profiles/RGB.icc
sRGBPROFILE?=../../tools/profiles/sRGB.icm

CONV?=convert -limit area 3GiB
REMAP?=eval nona -v -t ${CPUS} -m TIFF_m -r ldr -p UINT${DEPTH} -z ${ENCOMP} -o tmp-
FFUSE?=eval enfuse -v --compression=${ENCOMP} -m ${MEM} -b 16384 --exposure-weight=0 --saturation-weight=0  --contrast-weight=1 --hard-mask
MERGE?=eval enfuse -v --compression=${ENCOMP} -m ${MEM} -b 16384 --exposure-weight=1.00 --saturation-weight=0.50 --contrast-weight=0.10 --exposure-mu=0.35 --exposure-sigma=0.15 --gray-projector=value
DEGHOST?=deghosting_mask -v -s 60 -c 0.8 -t 150 -i 8 -a mw
BLEND?=eval enblend -v --compression=${ENCOMP} -m ${MEM} -b 16384 --fine-mask --fine-mask --primary-seam-generator=nearest-feature-transform --mask-vectorize=12 -f 6144x6144

EXIFTFF?=exiftool -overwrite_original -P -TagsFromFile
EXIFTAG?=-EXIF:ExposureTime -EXIF:ShutterSpeedValue -EXIF:ApertureValue -EXIF:ISO

RM=echo
MV=mv
LN=ln -f

all: ${DST}.tiff

tmp-0000.tif: ${DST}.pto kazan-122-90.tiff
	@${REMAP} -i 0 -e 0 ${DST}.pto
tmpfkazan-122-90.tiff: tmp-0000.tif
	@${LN} tmp-0000.tif tmpfkazan-122-90.tiff
	@${RM} tmp-0000.tif
tmpekazan-122-90.tiff: tmpfkazan-122-90.tiff
	@${LN} tmpfkazan-122-90.tiff tmpekazan-122-90.tiff
	@${RM} tmpfkazan-122-90.tiff
tmptkazan-122-90.tiff: tmpekazan-122-90.tiff
	@${LN} tmpekazan-122-90.tiff tmptkazan-122-90.tiff
	@${RM} tmpekazan-122-90.tiff
tmpkazan-122-90.tiff: tmptkazan-122-90.tiff
	@${LN} tmptkazan-122-90.tiff tmpkazan-122-90.tiff
	@${RM} tmptkazan-122-90.tiff

tmp.tiff: tmpkazan-122-90.tiff
	@${RM}  kazan-122-90.tiff
	@${BLEND} -o tmp.tiff tmpkazan-122-90.tiff
	@${RM} tmpkazan-122-90.tiff
${DST}.tiff: tmp.tiff
	@${CONV} tmp.tiff \
		+matte +repage   \
		-compress ${IMCOMP} ${DST}.tiff
	@${RM} tmp.tiff
