
@MAKEFILEDEFINES@

confsdirs= autoconf libAfterBase libAfterImage

####

subdirs		= libAfterBase libAfterImage libAfterStep libAfterConf \
		  doc tools \
		  src/afterstep \
		  src/Animate \
		  src/Banner \
		  src/Ident \
		  src/Pager \
		  src/Wharf \
		  src/WinList2 \
		  src/WinTabs \
		  src/ascp  \
		  src/ASDocGen 

#		  src/ascp/fltk \
#		  src/ascp/gtk

#		  src/asetroot \
#		  src/Audio \
#		  src/Cascade \
#		  src/Clean \
#		  src/Form \
#		  src/Gnome \
#		  src/Save \
#		  src/Scroll \
#		  src/Sound \
#		  src/Tile \
#		  src/Zharf @SCRIPT_DIR@

all:	AfterStep.desktop.final
	@for I in ${subdirs}; do (cd $$I; ${MAKE} $@ || exit 1); done

AfterStep.desktop.final:
	@$(CP) AfterStep.desktop AfterStep.desktop.final; \
	echo "Exec=$(AFTER_BIN_DIR)/afterstep" >> AfterStep.desktop.final ; \
	echo "Icon=$(AFTER_SHAREDIR)/desktop/icons/large/AfterStep3" >> AfterStep.desktop.final

mkdir:	mkdir.bin mkdir.lib mkdir.man
  
mkdir.bin:
	@$(MKDIR) -p $(AFTER_BIN_DIR);

mkdir.lib:
	@$(MKDIR) -p $(LIBDIR);

mkdir.man:
	@$(MKDIR) -p $(AFTER_MAN_DIR); $(MKDIR) -p $(AFTER_MAN_API_DIR);
 
install: install.desktop install.data mkdir
	@for I in ${subdirs}; do (cd $$I; ${MAKE} install || exit 1); done

install.bin: mkdir.bin
	@for I in ${subdirs}; do (cd $$I; ${MAKE} install.bin || exit 1); done

install.lib: mkdir.lib
	@for I in ${subdirs}; do (cd $$I; ${MAKE} install.lib || exit 1); done

install.man: mkdir.man
	@for I in ${subdirs}; do (cd $$I; ${MAKE} install.man || exit 1); done
  
install.script: mkdir.bin
	@for I in ${subdirs}; do (cd $$I; ${MAKE} install.script || exit 1); done

install.desktop: AfterStep.desktop.final
	@if [ -d /usr/share/xsessions ] && [ -w /usr/share/xsessions ] ; then \
		echo "installing AfterStep.desktop into /usr/share/xsessions/" ; \
		$(INSTALL_DATA)  AfterStep.desktop.final /usr/share/xsessions/AfterStep.desktop ; \
	else if [ -d /etc/X11/sessions ] && [ -w /etc/X11/sessions ] ; then \
		echo "installing AfterStep.desktop /etc/X11/xsessions/" ; \
		$(INSTALL_DATA)  AfterStep.desktop.final /etc/X11/xsessions/AfterStep.desktop ; \
	fi; fi

install.data:
	@if [ -d /usr/local/share/gnome/wm-properties ] ; then \
	if [ -w /usr/local/share/gnome/wm-properties ] ; then \
	echo $(CP) AfterStep.desktop /usr/local/share/gnome/wm-properties/; \
	$(CP) AfterStep.desktop /usr/local/share/gnome/wm-properties/; \
	else \
	echo "/usr/local/share/gnome/wm-properties exists but is not writable."; \
	echo "If you want AfterStep to appear in your Gnome menu, please install as root."; \
	fi \
	fi
	@if [ -d $(GNOME_SHAREDIR)/wm-properties ] ; then \
	if [ -w $(GNOME_SHAREDIR)/wm-properties ] ; then \
	 echo $(CP) AfterStep.desktop $(GNOME_SHAREDESTDIR)/wm-properties/; \
	 $(MKDIR) -p $(GNOME_SHAREDESTDIR)/wm-properties; \
	 $(CP) AfterStep.desktop $(GNOME_SHAREDESTDIR)/wm-properties/; \
	else \
	echo "$(GNOME_SHAREDIR)/wm-properties exists but is not writable."; \
	echo "If you want AfterStep to appear in your Gnome menu, please install as root."; \
	fi \
	fi
	cd afterstep; ${MAKE} install || exit 1; cd ..

uninstall:
	@for I in ${subdirs}; do (cd $$I; ${MAKE} uninstall || exit 1); done

clean:
	@for I in ${subdirs}; do (cd $$I; ${MAKE} clean || exit 1); done; \
	$(RMF) AfterStep.desktop.final


distclean:
	@for I in ${subdirs}; do (cd $$I; ${MAKE} distclean || exit 1); done
	$(RMF) config.cache config.log config.status Makefile.bak Makefile config.h configure.h *.o *~ *% *.bak \#* core

indent:
	for i in ${subdirs}; do ${MAKE} -C $$i indent; done
	@cd include; \
	for i in *.h; do \
	  if (indent < $$i > /tmp/$$i); then \
	    echo indent $$i; \
	    mv /tmp/$$i $$i; \
	  fi; \
	done

deps:
	for I in ${subdirs}; do (cd $$I; touch .depend || exit 1); done; \
	for I in ${subdirs}; do (cd $$I; ${MAKE} deps || exit 1); done

config:
	for I in ${confsdirs}; do \
	  cd $$I ;  autoconf configure.in > configure ; chmod 755 configure ; cd .. ; \
	done; \
	cd autoconf ; \
	autoconf configure.libs.in > configure.libs; chmod 755 configure.libs ; \
	$(MV) configure.libs ../ ; \
	$(MV) configure ../ ; \
	cd ..

configclean:
	$(RMF) ./config.status ./config.log ./include/config.h ./config.cache ./configure.h ; \
	for I in ${confsdirs}; do \
	  $(RMF) $$I/config.status $$I/config.log $$I/config.h $$I/config.cache $$I/configure.h ; \
	done; \

ChangeLog:
	tools/cvs2cl.as.pl --hide-filenames --no-times;
	cd libAfterBase ; ../tools/cvs2cl.as.pl --hide-filenames --no-times; cd .. ;
	cd libAfterImage ; ../tools/cvs2cl.as.pl --hide-filenames --no-times; cd .. ;

