#!/usr/bin/make -f
#
# $Id: uae-confwrap,v 1.1 2002/02/03 22:55:07 absurd Exp $
#
# (c) Stephan A Suerken <absurd@debian.org>, GPLed.
#
# Handling settings for uae
#
# All actual settings in ~/.uaerc-store/.<config>.<display>
#
# !!! THIS SCRIPT WILL OVERWRITE ~/.uaerc WITHOUT WARNING !!!
#

UAERC_FILE=${HOME}/.uaerc
STORE_DIR=${HOME}/.uaerc-store
LOG_FILE=${HOME}/.uaerc-store
PHONY_DUMMY=${STORE_DIR}/.phony_dummy

default:
	@echo "Usage: uae-confwrap .<config>.<display>"
	@echo
	@echo " Wrapper to manage different config files with uae."
	@echo " Runs uae-<display> with config file ${STORE_DIR}/.<config>.<display>,"
	@echo " preserving changes in the config file."

${PHONY_DUMMY}:
	@touch $@

.%: config  = $(shell echo $@ | cut -d. -f2)
    display = $(shell echo $@ | cut -d. -f3)
.%:
	@echo -e "Running config \"${config}\" for display \"${display}\"."
	@echo -e "Logging to ${STORE_DIR}/$@.log...\n"
	@cp ${STORE_DIR}/$@ ${UAERC_FILE} 2>/dev/null || touch ${UAERC_FILE}
	-@uae-${display}  2>&1 | tee ${STORE_DIR}/$@.log
	@cp ${UAERC_FILE} ${STORE_DIR}/$@
	@rm -f ${PHONY_DUMMY}
	
.PHONY: default
