include ./VERSION
include ./install.inc

BINFILES    = src/icewm src/icewmhint src/icewmbg
LIBFILES    = lib/preferences lib/menu lib/toolbar lib/winoptions
XPMDIRS     = icons ledclock taskbar mailbox
THEMES      = nice motif win95 warp3 warp4 win31 metal metal2 gtk \
              metal-big blueice monte-carlo jaywalk bluePlastic \
              aesthetech aesthetech-big

all:
	cd src ; $(MAKE) LIBDIR=$(LIBDIR) ETCDIR=$(ETCDIR)
	cd doc ; $(MAKE)

doc:
	cd doc ; $(MAKE)

clean:
	cd doc ; $(MAKE) clean
	cd src ; $(MAKE) clean

dist:
	cd doc ; $(MAKE) clean
	cd doc ; $(MAKE)
	cd src ; $(MAKE) clean


# Makefile TABS *SUCK*
install: all
	@echo ------------------------------------------
	@echo Installing icewm to $(BINDIR)
	@$(INSTALLDIR) $(BINDIR)
	@for a in $(BINFILES) ; do \
            $(INSTALLBIN) $$a $(BINDIR); \
        done
	@echo Installing defaults, icons and themes to $(LIBDIR)
	@$(INSTALLDIR) $(LIBDIR)
	@$(INSTALLDIR) $(ETCDIR)
	@for a in $(LIBFILES) ; do \
            $(INSTALLLIB) $$a $(LIBDIR); \
        done
	@for l in $(XPMDIRS) ; do \
            $(INSTALLDIR) $(LIBDIR)/$$l; \
            for f in lib/$$l/* ; do \
                $(INSTALLLIB) $$f $(LIBDIR)/$$l; \
            done; \
        done
	@for theme in $(THEMES) ; do \
            echo Installing theme: $$theme; \
            $(INSTALLDIR) $(LIBDIR)/themes/$$theme; \
            for pixmap in lib/themes/$$theme/*.xpm ; do \
                $(INSTALLLIB) $$pixmap $(LIBDIR)/themes/$$theme; \
            done; \
            for config in lib/themes/$$theme/*.theme ; do \
                $(INSTALLLIB) $$config $(LIBDIR)/themes/$$theme; \
            done; \
            for l in $(XPMDIRS) ; do \
                if [ -f lib/themes/$$theme/$$l ] ; then \
                    $(INSTALLDIR) $(LIBDIR)/themes/$$theme/$$l; \
                    for f in lib/themes/$$theme/$$l/* ; do \
                        $(INSTALLLIB) $$f $(LIBDIR)/themes/$$theme/$$l; \
                    done;\
                fi;\
            done;\
        done
	@#for a in $(ETCFILES) ; do $(INSTALLETC) $$a $(ETCDIR) ; done

installdoc:
	echo #mkdir /usr/doc/icewm-$(VERSION)
	echo #cp -r doc /usr/doc/icewm-$(VERSION)
