#************************************************************************
#*   IRC - Internet Relay Chat, Makefile
#*   Copyright (C) 1990, Jarkko Oikarinen
#*
#*   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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#*
#*   $Id: Makefile.in,v 1.10 2004/02/23 22:09:04 jeremy Exp $
#*/

RM=@RM@
AUTOHEADER=@AUTOHEADER@
AUTOCONF=@AUTOCONF@

# Default CFLAGS
# CFLAGS = -g -O2 -DNDEBUG
CFLAGS		= @CFLAGS@
# Developers CFLAGS
#CFLAGS= -g -O2 -Wunused -Wall -ggdb -pedantic -Wshadow -Wmissing-declarations

# Default make flags - you may want to uncomment this on a multicpu machine
#MFLAGS = -j 4

#
# For developers
#CFLAGS= -g -O2 -Wall

# You may need to define the FD_SETSIZE in order to overrule
# the system one.
#CFLAGS= -DNDEBUG -g -O2 -D"FD_SETSIZE=1024"
SHELL=/bin/sh
SUBDIRS=modules adns src tools doc @SUBDIR_MESSAGES@ servlink help
CLEANDIRS = ${SUBDIRS} contrib
RSA_FILES=rsa_respond/README rsa_respond/respond.c rsa_respond/Makefile

MAKE = make ${MFLAGS} 

TARBALL			= FreeWorld-ircd-2.0-rc3.tgz
BZIP_TARBALL	= FreeWorld-ircd-2.0-rc3.tar.bz2

all:	build


autoconf: autoconf/configure.in
	@${AUTOCONF} autoconf/configure.in >configure 2>autoconf.log
	@${AUTOHEADER} -l autoconf autoconf/configure.in > include/setup.h.in 2> autoheader.log
	@${RM} -f config.cache

build:
	-@if [ ! -f include/setup.h ] ; then \
		echo "Hmm...doesn't look like you've run configure..."; \
		echo "Doing so now."; \
		sh configure; \
	fi
	@for i in $(SUBDIRS); do \
		echo "build ==> $$i";\
		cd $$i;\
		${MAKE} build || exit; cd ..;\
	done

clean:
	@${RM} -f *~ core rsa_respond.tar rsa_respond.tar.gz autoheader.log autoconf.log
	@for i in $(CLEANDIRS); do \
		echo "clean ==> $$i";\
		cd $$i;\
		${MAKE} clean; cd ..;\
	done
	-@if [ -f include/setup.h ] ; then \
	echo "To really restart installation, make distclean" ; \
	fi

distclean:
	@${RM} -f Makefile *~ *.rej *.orig core ircd.core
	@${RM} -f config.status config.cache config.log
	@cd include; ${RM} -f setup.h *~ *.rej *.orig ; cd ..
	@for i in $(CLEANDIRS); do \
		echo "distclean ==> $$i";\
		cd $$i;\
		${MAKE} distclean; cd ..;\
	done

depend:
	@for i in $(SUBDIRS); do \
		echo "depend ==> $$i";\
		cd $$i;\
		${MAKE} depend; cd ..;\
	done

lint:
	@for i in $(SUBDIRS); do \
		echo "lint ==> $$i";\
		cd $$i;\
		${MAKE} lint; cd ..;\
	done

install: all
	@for i in $(SUBDIRS); do \
		echo "install ==> $$i";\
		cd $$i;\
		${MAKE} install; \
		cd ..; \
	done

rsa_respond:
	@cd tools;\
	echo "Creating rsa_respond.tar.gz";\
	tar cf ../rsa_respond.tar $(RSA_FILES);\
	cd ..;\
	gzip rsa_respond.tar

release:
	@make distclean;\
	cd ..;\
	tar --exclude='CVS' --gzip --create --file='${TARBALL}' FreeWorld-ircd/;\
	tar --exclude='CVS' --bzip2 --create --file='${BZIP_TARBALL}' FreeWorld-ircd/;

