
@MAKEFILEDEFINES@

confsdirs= autoconf libAfterBase libAfterImage

####

libdirs         = libAfterBase libAfterImage libAfterStep libAfterConf @LIBASGTKDIR@

gtk_app_dirs    = src/tools/ASFileBrowser src/tools/ASWallpaper
no_gtk_app_dirs =

giolib_app_dirs    = src/ASMount
no_giolib_app_dirs =

desktop_subdirs = $(SYSSHAREDIR)/applications $(SHAREDIR)/applications
session_subdirs = $(SYSCONFDIR)/X11/sessions $(SYSSHAREDIR)/xsessions $(SHAREDIR)/xsessions
gnome_session_subdirs = $(SYSSHAREDIR)/gnome-session/sessions $(SHAREDIR)/gnome-session/sessions

subdirs         = libAfterBase libAfterImage libAfterStep libAfterConf @LIBASGTKDIR@ \
                  src/afterstep \
                  src/Animate \
                  src/Arrange \
                  src/Banner \
                  src/Ident \
                  src/Pager \
                  src/Wharf \
                  src/WinCommand \
                  src/WinList2 \
                  src/WinTabs \
                  src/ascp  \
									src/tools/ASRun \
                  afterstep \
                  src/ASDocGen \
                  $(@GIOLIB_APP_DIRS@) \
                  $(@GTK_APP_DIRS@) \
                  doc tools

RECURSIVE_TARGETS = all libs install install.bin install.lib install.man install.script install.data uninstall clean distclean indent deps

all: AfterStep.desktop.final AfterStep.desktop.session
libs: AfterStep.desktop.final AfterStep.desktop.session
install: install.wmprops install.desktop mkdir
install.bin: mkdir.bin
install.lib: mkdir.lib
install.man: mkdir.man
install.script: mkdir.bin
clean: clean-local
distclean: distclean-local
indent: indent-local
deps: deps-local

clean-local:
	$(RMF) AfterStep.desktop.final AfterStep.desktop.session

distclean-local:
	$(RMF) config.cache config.log config.status Makefile.bak Makefile config.h configure.h *.o *~ *% *.bak \#* core

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

deps-local:
	@for I in ${subdirs}; do if [ -d $$I ]; then touch $$I/.depend || exit 1; fi; done

install.wmprops:
	@if [ -d $(SHAREDIR)/gnome/wm-properties ] ; then \
        if [ -w $(SHAREDIR)/gnome/wm-properties ] ; then \
        echo $(CP) AfterStep.desktop $(SHAREDIR)/gnome/wm-properties/; \
        $(CP) AfterStep.desktop $(SHAREDIR)/gnome/wm-properties/; \
        else \
        echo "$(SHAREDIR)/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

$(RECURSIVE_TARGETS):
	@fail= failcom='exit 1'; \
	for f in x $$MAKEFLAGS; do \
		case $$f in \
			*=* | --[!k]*) ;; \
			*k*) failcom='fail=yes' ;; \
		esac; \
	done; \
	for I in ${subdirs}; do \
		(cd $$I; ${MAKE} $@) || eval $$failcom; \
	done; \
	test -z "$$fail"

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

AfterStep.desktop.session:
	@if test "x$(AFTER_EXEC_COMMAND)" != "x"; then \
			$(CP) AfterStep.desktop AfterStep.desktop.session; \
			echo "Exec=$(AFTER_EXEC_COMMAND)" >> AfterStep.desktop.session ; \
			echo "TryExec=$(AFTER_BIN_DIR)/afterstep" >> AfterStep.desktop.session ; \
		fi;


mkdir:  mkdir.bin mkdir.lib mkdir.man mkdir.share

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

mkdir.share:
	@$(MKDIR) -p $(SHAREDIR); \
         $(MKDIR) -p $(AFTER_SHAREDIR)

module.clean:

install.desktop: AfterStep.desktop.final AfterStep.desktop.session mkdir.share
	@for I in ${desktop_subdirs}; do \
		if [ -d $$I ] && [ -w $$I ] ; then \
			echo "installing AfterStep.desktop $$I" ; \
      $(INSTALL_DATA)  AfterStep.desktop.final $$I/AfterStep.desktop ; \
    fi; done; \
		for I in ${session_subdirs}; do \
		if [ -d $$I ] && [ -w $$I ] ; then \
			echo "installing session AfterStep.desktop $$I" ; \
      $(INSTALL_DATA)  AfterStep.desktop.session $$I/AfterStep.desktop ; \
    fi; done; \
		for I in ${gnome_session_subdirs}; do \
			if [ -d $$I ] && [ -w $$I ] ; then \
      echo "installing AfterStep.session into $$I" ; \
      $(INSTALL_DATA)  AfterStep.session $$I/AfterStep.session ; \
  	fi; done;

#    else if [ -d $(SHAREDIR) ] && [ -w $(SHAREDIR) ] ; then \
#      echo "mkdir $(SHAREDIR)/xsessions"; $(MKDIR) -p $(SHAREDIR)/xsessions; \
#      echo "installing AfterStep.desktop into $(SHAREDIR)/xsessions/" ; $(INSTALL_DATA)  AfterStep.desktop.final $(SHAREDIR)/xsessions/AfterStep.desktop ; \
#    fi;


install.share:
	@cd afterstep && ${MAKE} install

install.data_html:
	@cd src/ASDocGen && ${MAKE} install.data_html

install.menu:
	@cd afterstep && ${MAKE} install.menu

install.config:
	@cd afterstep && ${MAKE} install.config


config:
	@for I in ${confsdirs}; do \
          (cd $$I ;  autoconf configure.in > configure ; chmod 755 configure); \
        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 libAfterImage ; ../tools/cvs2cl.as.pl --hide-filenames --no-times)
	tools/git-cl.sh .; \
	tools/git-cl.sh libAfterBase ; \
	tools/git-cl.sh libAfterImage

