# color={Pink;Yellow;Orange}
COLOR=Pink

BUILDDIR=../.icons/neverhood$(COLOR)/cursors

INSTALLDIR=$(HOME)/.icons/neverhood$(COLOR)/cursors

#Find list of cursors
conffiles = $(wildcard *.conf)

cursorfiles:= $(foreach conffile,$(conffiles),$(BUILDDIR)/$(subst ./,,$(subst .conf,,$(conffile))))

CURSORS = $(cursorfiles)

#rules
.PHONY: all

all: $(CURSORS)

clean:
	rm -f $(BUILDDIR)/*

png/% : png$(COLOR)/%
	ln -sf png$(COLOR) png

$(BUILDDIR)/% : %.conf png/%.png
	xcursorgen $< $@

install: all
#Create necessary directories
	if test ! -d $(HOME)/.icons/default ;then mkdir -p $(HOME)/.icons/default;fi
	if test ! -d $(INSTALLDIR)/cursors ;then mkdir -p $(INSTALLDIR)/cursors; fi
#Copy the cursors
	cp -Rf $(BUILDDIR)/* $(INSTALLDIR)
#Copy the configuration file
	cp -f  $(BUILDDIR)/../index.theme $(INSTALLDIR)/../index.theme
#Create some symlinks
	ln -sf hand $(INSTALLDIR)/hand1
	ln -sf hand $(INSTALLDIR)/hand2
#QT symlinks mess :-(
	ln -sf v_double_arrow	$(INSTALLDIR)/00008160000006810000408080010102 #v_double_arrow
	ln -sf h_double_arrow	$(INSTALLDIR)/028006030e0e7ebffc7f7070c0600140 #h_double_arrow
	ln -sf fd_double_arrow	$(INSTALLDIR)/fcf1c3c7cd4491d801f1e1c78f100000 #fd_double_arrow
	ln -sf bd_double_arrow	$(INSTALLDIR)/c7088f0f3e6c8088236ef8e1e3e70000 #bd_double_arrow
	ln -sf sb_h_double_arrow   $(INSTALLDIR)/14fef782d02440884392942c11205230 #sb_h_double_arrow
	ln -sf sb_v_double_arrow   $(INSTALLDIR)/2870a09082c103050810ffdffffe0204 #sb_v_double_arrow
	ln -sf hand1 $(INSTALLDIR)/9d800788f1b08800ae810202380a0822 #hand1
	ln -sf hand2 $(INSTALLDIR)/e29285e634086352946a0e7090d73106 #hand2
	ln -sf crossed_circle $(INSTALLDIR)/03b6e0fcb3499374a867c041f52298f0 # crossed_circle (dnd forbidden)
	ln -sf move $(INSTALLDIR)/4498f0e0c1937ffe01fd06f973665830 # left_ptr (move_cursor)
	ln -sf copy $(INSTALLDIR)/6407b0e94181790501fd1e167b474872 # copy
	ln -sf link $(INSTALLDIR)/640fb0e74195791501fd1ed57b41487f # link
	ln -sf left_ptr_watch $(INSTALLDIR)/3ecb610c1bf2410f44200f48c40d3599 # left_ptr_watch
	ln -sf question_arrow $(INSTALLDIR)/d9ce0ab605698f320427677b458ad60b # question_arrow
#Other apps' symlinks
	ln -sf left_ptr_watch $(INSTALLDIR)/08e8e1c95fe2fc01f976f1e063a24ccd #mozilla's left_ptr_watch
	ln -sf question_arrow $(INSTALLDIR)/5c6cd98b3f3ebcb1f9c7f1c204630408 #mozilla's question_arrow
	ln -sf copy $(INSTALLDIR)/1081e37283d90000800003c07f3ef6bf #nautilus copy
	ln -sf move $(INSTALLDIR)/9081237383d90e509aa00f00170e968f #nautilus move
	ln -sf link $(INSTALLDIR)/3085a0e285430894940527032f8b26df #nautilus link

# Mozilla alias
# 0876e1c15ff2fc01f906f1c363074c0f (left_ptr with small arrow) 
# 08ffe1cb5fe6fc01f906f1c063814ccf (left_ptr with plus)
# 208530c400c041818281048008011002 (closed hand)
# 5aca4d189052212118709018842178c0 (open hand)
# 08ffe1e65f80fcfdf9fff11263e74c48 (left_ptr with menu)

# Gtk+
# DND copy    1081e37283d90000800003c07f3ef6bf
# DND move    9081237383d90e509aa00f00170e968f
# DND link    3085a0e285430894940527032f8b26df
# DND no drop 1001208387f90000800003000700f6ff
# Eye dropper 90b3018312820b127e5a0b7c8034a301
