@MAKEFILECOMMON@

#CREATE_SHAREDIR_LIST= desktop backgrounds

IMAGE_DIR_LIST= backgrounds backgrounds/Gradient_Textures backgrounds/Plain_Textures \
				backgrounds/Mirrored_Tiles \
				desktop/bars desktop/buttons desktop/icons \
				desktop/icons/dots desktop/icons/large desktop/icons/logos \
				desktop/icons/mini desktop/icons/normal desktop/tiles

MISC_FILES_DIR_LIST= desktop/cursors desktop/fonts desktop/sounds

CONFIG_DIR_LIST= feels colorschemes looks scripts themes


install:
	@if [ -d $(AFTER_SHAREDIR) ] ; then \
	  echo $(RMF) -r $(AFTER_SHAREDIR)_old; \
	  echo $(MV) $(AFTER_SHAREDIR) $(AFTER_SHAREDIR)_old; \
	  $(RMF) -r $(AFTER_SHAREDIR)_old; \
	  $(MV) $(AFTER_SHAREDIR) $(AFTER_SHAREDIR)_old; \
	fi; \
	$(MKDIR) -p $(AFTER_SHAREDIR); \
	$(MKDIR) -p $(AFTER_DOC_DIR) ; \
	$(MKDIR) -p $(AFTER_SHAREDIR)/desktop
	@for D in ${IMAGE_DIR_LIST}; do \
		$(MKDIR) -p $(AFTER_SHAREDIR)/$$D; \
		echo "Installing images from $$D to $(AFTER_SHAREDIR)/$$D "; \
		if [ -d $$D/xml ] ; then \
			list=`$(FIND) $$D/xml/ -type f -maxdepth 1`; \
			for I in $$list; do \
				fname=`basename $$I`; \
				echo -n "."; \
			    $(INSTALL_DATA) $$D/xml/$$fname $(AFTER_SHAREDIR)/$$D/$$fname; \
			done ; \
		fi; \
		if [ -d $$D/$(IMAGE_FORMAT) ] ; then \
			list=`$(FIND) $$D/$(IMAGE_FORMAT)/ -type f -maxdepth 1`; \
			for I in $$list; do \
				fname=`basename $$I`; \
				echo -n "."; \
				$(INSTALL_DATA) $$D/$(IMAGE_FORMAT)/$$fname $(AFTER_SHAREDIR)/$$D/$$fname; \
			done ; \
		fi; \
		if [ -r $$D/jpg ] ; then \
			list=`$(FIND) $$D/jpg/ -type f  -maxdepth 1`; \
			for I in $$list; do \
				fname=`basename $$I`; \
				echo -n "."; \
		    	$(INSTALL_DATA) $$D/jpg/$$fname $(AFTER_SHAREDIR)/$$D/$$fname; \
			done ; \
		fi; \
		echo ""; \
	done ; \
	$(INSTALL_DATA) desktop/icons/CREDITS $(AFTER_SHAREDIR)/desktop/icons/
	@for D in ${MISC_FILES_DIR_LIST} ${CONFIG_DIR_LIST} non-configurable; do \
		echo "$(MKDIR) -p $(AFTER_SHAREDIR)/$$D"; \
		$(MKDIR) -p $(AFTER_SHAREDIR)/$$D; \
		echo "Installing config files from $$D to $(AFTER_SHAREDIR)/$$D "; \
		for I in $$D/*; do \
			if [ -f $$I ] ; then \
					echo -n "."; \
			    	$(INSTALL_DATA) $$I $(AFTER_SHAREDIR)/$$I; \
			fi; \
		done; \
		echo ""; \
	done
	@echo "$(MKDIR) -p $(AFTER_SHAREDIR)/start"; \
	$(MKDIR) -p $(AFTER_SHAREDIR)/start; \
	echo "$(CP) -r start/* $(AFTER_SHAREDIR)/start/"; \
	$(CP) -r start/* $(AFTER_SHAREDIR)/start/; 
	@$(RMF) $(AFTER_SHAREDIR)/start/.include.in; \
	$(INSTALL_DATA) start/.include $(AFTER_SHAREDIR)/start/.include; \
	$(RMF) $(AFTER_SHAREDIR)/start/Desktop/Feel/.include.in; \
	$(RMF) $(AFTER_SHAREDIR)/start/Desktop/Color_Scheme/.include.in; \
	$(RMF) $(AFTER_SHAREDIR)/start/Desktop/Look/.include.in; \
	$(RMF) $(AFTER_SHAREDIR)/start/Desktop/Theme/.include.in; \
	$(RMF) $(AFTER_SHAREDIR)/start/Desktop/Pictures/.include.in; \
	$(RMF) $(AFTER_SHAREDIR)/non-configurable/*.in
	$(FIND) $(AFTER_SHAREDIR) -name '*.in' -print | $(XARGS) $(RMF) -r
	$(FIND) $(AFTER_SHAREDIR) -name '*.orig' -print | $(XARGS) $(RMF) -r
	$(FIND) $(AFTER_SHAREDIR) -name CVS -print | $(XARGS) $(RMF) -r
	$(FIND) $(AFTER_SHAREDIR) -name .cvsignore -print | $(XARGS) $(RMF)
	@for f in animate autoexec banner base database pager wharf winlist ; do \
		echo "$(INSTALL_DATA) $$f $(AFTER_SHAREDIR)/$$f"; \
		$(INSTALL_DATA) $$f $(AFTER_SHAREDIR)/$$f; \
	done 
	

uninstall:
	$(RMF) -r $(AFTER_SHAREDIR)
	@if [ -d $(AFTER_SHAREDIR)_old ] ; then \
	  echo $(MV) $(AFTER_SHAREDIR)_old $(AFTER_SHAREDIR); \
	  $(MV) $(AFTER_SHAREDIR)_old $(AFTER_SHAREDIR); \
	fi


