DIR=${ROOT}${AMD_CONF_DIR}

all:

clean:

install:
ifneq (${AMD_CONF_DIR},)
	sed "s|@@AMD_CONF_DIR@@|${AMD_CONF_DIR}|g" amd.shfs >amd.shfs.tmp
	sed "s|@@AMD_CONF_DIR@@|${AMD_CONF_DIR}|g" amd.conf >amd.conf.tmp
	install -m644 -b -D amd.shfs.tmp ${DIR}amd.shfs
	install -m755 -b -D mount ${DIR}mount
	ln -f -s mount ${DIR}umount
	cat amd.conf.tmp >>${DIR}amd.conf
	rm -f amd.shfs.tmp amd.conf.tmp
	if [ ! -d ${ROOT}/shfs ]; then mkdir -m755 ${ROOT}/shfs; fi
endif

uninstall:
ifneq (${AMD_CONF_DIR},)
	rm -f ${DIR}mount ${DIR}umount ${DIR}amd.shfs
	awk '/^# SHFS: AUTO ADDED$$/ { while (getline == 1) { if ($$0 == "# SHFS: END") break; } next; } // { print $$0; }' ${DIR}amd.conf >${DIR}amd.conf.tmp
	mv ${DIR}amd.conf.tmp ${DIR}amd.conf
	if [ -d ${ROOT}/shfs ]; then rmdir ${ROOT}/shfs; fi
endif

.PHONY : all clean install uninstall
