CURSORDIR=$(PREFIX)/crystalgray_nonanim/cursors
BUILDDIR=../../gray_cursors_nonanim


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

#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)/crystalgray_nonanim ;then mkdir $(PREFIX)/crystalgray_nonanim; fi
	if test ! -d $(PREFIX)/crystalgray_nonanim/cursors ;then mkdir $(PREFIX)/crystalgray_nonanim/cursors; fi
	#Copy the cursors

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

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

	#Create some symlinks
	ln -sf left_ptr_watch $(CURSORDIR)/3ecb610c1bf2410f44200f48c40d3599 # left_ptr_watch
	ln -sf left_ptr_watch $(CURSORDIR)/08e8e1c95fe2fc01f976f1e063a24ccd #mozilla's left_ptr_watch


#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))))

left_ptr_watch.png: ../left_ptr_watch/left_ptr_watch12.png
	ln -sf ../left_ptr_watch/left_ptr_watch12.png left_ptr_watch.png

watch.png: ../watch/watch12.png
	ln -sf ../watch/watch12.png watch.png
