
CONFIG_EXISTS := $(wildcard config.mk)

all: ncursesw

clean: test_config
	cd src/ncursesw ; make clean

distclean: test_config clean
	rm fizmo

ifeq ($(strip $(CONFIG_EXISTS)),)

ifeq ($(strip $(CONFIG_FILE)),)

include config.default.mk

test_config:
	@echo
	@echo No file \"config.mk\" was found, using \"config.default.mk\".
	@echo
	cp config.default.mk config.mk

else

include $(CONFIG_FILE)

test_config:
	ln -s $(CONFIG_FILE) config.mk
	@true

endif

else

include config.mk

test_config:
	@true

endif

ifeq ($(FIZMO_BIN_DIR),)
FIZMO_BIN_DIR = games
endif

install: ncursesw
	mkdir -p $(INSTALL_PREFIX)/$(FIZMO_BIN_DIR) $(INSTALL_PREFIX)/share/man/man6
	install fizmo $(INSTALL_PREFIX)/$(FIZMO_BIN_DIR)
	install src/man/fizmo.6 $(INSTALL_PREFIX)/share/man/man6

ncursesw: test_config
	cd src/ncursesw ; make fizmo
	mv src/ncursesw/fizmo .

