##
#
# Makefile
#   IIRC root Makefile
#
# $Id: Makefile.in,v 1.1.1.1 2002/01/24 20:18:27 sembera Exp $
#
##
#
# IIRC - IIRC Is a Real Client (Modular IRC Client)
# Copyright (C) 2001,2002  Jan Sembera <fis@ji.cz>
# Copyright (C) 2001,2002  Petr Baudis <pasky@ji.cz>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
##
#
# Possible targets:
# all, everything - compiles iirc
# clean           - remove all the mess
# distclean	  - remove everything but files from cvs
# install	  - installs everything ;) 
#
# WARNING! DO NOT EDIT MAKEFILES DIRECTLY! WARNING! 
# Ok, you have been warned, but take it as _SERIOUS_ warning. Result is undefined
##

###
# Dirs

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sysconfdir = @sysconfdir@
libdir = @libdir@
datadir = @datadir@
includedir = @includedir@

###
# Commons
CC = @CC@
MAKE = @MAKE@ 
VERSION = @VERSION@
install = @INSTALL@

# Main CFLAGS
CFLAGS = @CFLAGS@
DEFS = @DEFS@

# Flags for ld
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

# Internals
RECURSIVES = src doc include
RECURSIVES_CLEAN = $(foreach tget, $(RECURSIVES), $(tget)-clean)
RECURSIVES_DISTCLEAN = $(foreach tget, $(RECURSIVES), $(tget)-distclean)
RECURSIVES_INSTALL = $(foreach tget, $(RECURSIVES), $(tget)-install)

###
# And targets

#
##### BUILD
#

all:	recursive
everything: all

recursive: $(RECURSIVES)
	@echo "Recursive targets done..."

.PHONY:	$(RECURSIVES)
$(RECURSIVES):
	@dir=`echo $@`; \
	r=`pwd`; export r; \
	if [ -f ./$${dir}/Makefile ] ; then \
	  s=`cd $(srcdir); pwd`; export s; \
	  (cd $${dir}; $(MAKE) all); \
	else \
	  echo "Warning, directory $${dir} skipped."; \
	  true; \
	fi
	
#
##### CLEAN
#

.PHONY:	clean
clean:	recursive-clean iirc-clean

recursive-clean: $(RECURSIVES_CLEAN)
	@echo "Recursive targets cleaned..."

.PHONY:	$(RECURSIVES_CLEAN)
$(RECURSIVES_CLEAN):
	@dir=`echo $@ | sed s/-clean$$//`; \
	r=`pwd`; export r; \
	if [ -f ./$${dir}/Makefile ] ; then \
	  s=`cd $(srcdir); pwd`; export s; \
	  (cd $${dir}; $(MAKE) clean); \
	else \
	  echo "Warning, directory $${dir} skipped."; \
	  true; \
	fi

iirc-clean:
	rm -f *~ *.o *.a iirc config.cache config.log config.status

#
##### DISTCLEAN
#

.PHONY: distclean
distclean: recursive-distclean iirc-distclean

recursive-distclean: $(RECURSIVES_DISTCLEAN)
	@echo "Recursive targets dist-cleaned..."

.PHONY: $(RECURSIVES_DISTCLEAN)
$(RECURSIVES_DISTCLEAN):
	@dir=`echo $@ | sed s/-distclean$$//`; \
         r=`pwd`; export r; \
         if [ -f ./$${dir}/Makefile ] ; then \
           s=`cd $(srcdir); pwd`; export s; \
           (cd $${dir}; $(MAKE) distclean); \
         else \
           echo "Warning, directory $${dir} skipped."; \
           true; \
         fi

iirc-distclean:
	rm -f *~ *.o *.a iirc Makefile configure include/config.h config.log config.cache config.status

#
#####
#

.PHONY: install
install: all iirc-install recursive-install 

recursive-install: $(RECURSIVES_INSTALL)
	@echo "Recursive targets installed..." 

.PHONY: $(RECURSIVES_INSTALL)
$(RECURSIVES_INSTALL):
	@dir=`echo $@ | sed s/-install$$//`; \
	r=`pwd`; export r; \
	if [ -f ./$${dir}/Makefile ] ; then \
	  s=`cd $(srcdir); pwd`; export s; \
	  (cd $${dir}; $(MAKE) install); \
	else \
	  echo "Warning, directory $${dir} skipped."; \
	  true; \
	fi

.PHONY: iirc-install 
iirc-install: 
	if [ ! -d $(prefix) ]; then $(install) -d $(prefix) -m 755; fi
	if [ ! -d $(exec_prefix) ]; then $(install) -d $(exec_prefix) -m 755; fi
	if [ ! -d $(bindir) ]; then $(install) -d $(bindir) -m 755; fi
	if [ ! -d $(sysconfdir) ]; then $(install) -d $(sysconfdir) -m 755; fi
	if [ ! -d $(libdir) ]; then $(install) -d $(libdir) -m 755; fi
	if [ ! -d $(datadir) ]; then $(install) -d $(datadir) -m 755; fi
	if [ ! -d $(includedir) ]; then $(install) -d $(includedir) -m 755; fi
	if [ -d $(datadir)/doc/iirc-$(VERSION) ]; then rm -rf $(datadir)/doc/iirc-$(VERSION); fi
	$(install) -d $(datadir)/doc/iirc-$(VERSION) -m 755
	$(install) -m 644 AUTHORS $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 CONCEPT $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 CodingStyle $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 COPYING $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 HISTORY $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 README  $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 TODO $(datadir)/doc/iirc-$(VERSION)
	$(install) -m 644 VERSION $(datadir)/doc/iirc-$(VERSION)
		
