CURSORDIR=$(PREFIX)/crystalblue_classic/cursors
BUILDDIR=../../blue_cursors_classic


########################################################################

#Find list of cursors
conffiles = $(wildcard *.conf)
cursorfiles:= $(foreach conffile,$(conffiles),$(BUILDDIR)/$(subst ./,,$(subst .conf,,$(conffile))))
cursornames:= $(foreach conffile,$(conffiles),$(subst ./,,$(subst .conf,,$(conffile))))



CURSORS = $(cursorfiles)
CURSORNAMES= $(cursornames)




.PHONY: all


all: $(CURSORS)

install: all
	#Create necessary directories

	if test ! -d $(PREFIX) ;then mkdir $(PREFIX); fi
	if test ! -d $(PREFIX)/default ;then mkdir $(PREFIX)/default;fi
	if test ! -d $(PREFIX)/crystalblue_classic ;then mkdir $(PREFIX)/crystalblue_classic; fi
	if test ! -d $(PREFIX)/crystalblue_classic/cursors ;then mkdir $(PREFIX)/crystalblue_classic/cursors; fi
	#Copy the cursors

	cp -Rf $(BUILDDIR)/* $(CURSORDIR)

	#Copy the configuration file
	cp -f  index.theme $(PREFIX)/crystalblue_classic/

	#Create some symlinks
	ln -sf hand $(CURSORDIR)/hand1
	ln -sf hand $(CURSORDIR)/hand2
	ln -sf hand1 $(CURSORDIR)/9d800788f1b08800ae810202380a0822 #hand1
	ln -sf hand2 $(CURSORDIR)/e29285e634086352946a0e7090d73106 #hand2

#Normal Cursors
define CURSOR_template
$(BUILDDIR)/$(1): $(1).png $(1).conf
	xcursorgen $(1).conf $(BUILDDIR)/$(1)
endef

$(foreach cursor,$(CURSORNAMES),$(eval $(call CURSOR_template,$(cursor))))

