#   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.28 2004/08/10 01:27:03 epiphani Exp $

RM=/bin/rm
MV=/bin/mv

ENGINE=socketengine_kqueue.c

SHELL=/bin/sh
SUBDIRS=md5 zlib src doc tools
INSTDIRS=src doc tools
CLEANSUBDIRS=src tools

CC=gcc
CFLAGS=-g -O2 -Wall
LIBS=-lcrypt  -L/usr/local/ssl/lib -lcrypto -Wl,-export-dynamic 

INSTALL_DIR=/usr/home/backupw/ircd

all:	$(EXTRA_UTILS) md5 build

md5/md5sum: 
	@cd md5; \
	if [ ! -f Makefile ] ; then \
		echo "Configuring MD5SUM..."; \
		sh configure; \
	fi; \
	echo "Building MD5SUM..."; \
	make build; \
	cd ..;

md5:    md5/md5sum

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 "Building $$i";\
		cd $$i;\
		${MAKE} build; cd ..;\
	done
	@echo "******************************************************************************"
	@echo "* For help with bahamut, please refer to http://bahamut.dal.net/             *"
	@echo "* If you encouter serious security related bugs, please mail coders@dal.net  *"
	@echo "* For other bug reports and inquiries, please mail dalnet-src@dal.net        *"
	@echo "* Thank you for choosing Bahamut!  - The DALnet coding team                  *"
	@echo "******************************************************************************"

profile:
	@for i in $(SUBDIRS); do \
		echo "Building $$i [profile]";\
		cd $$i;\
		${MAKE} profile; cd ..;\
	done

clean:
	${RM} -f *~ core
	@for i in $(CLEANSUBDIRS) md5; do \
		echo "Cleaning $$i";\
		cd $$i;\
		${MAKE} clean; cd ..;\
	done
	-@if [ -f include/setup.h ] ; then \
	echo "To really restart installation, make distclean" ; \
	fi

fullclean:
	${RM} -f *~ core
	@for i in $(SUBDIRS); do \
		echo "Cleaning $$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 *.tmp
	${RM} -f config.status config.cache config.log
	cd include; ${RM} -f setup.h *~ *.rej *.orig options.h; cd ..
	@for i in $(SUBDIRS); do \
		echo "Cleaning $$i";\
		cd $$i;\
		${MAKE} distclean; cd ..;\
	done

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

install: all
	@if test ! -d $(INSTALL_DIR); then \
		echo "Creating directory $(INSTALL_DIR)"; \
		mkdir $(INSTALL_DIR); \
	fi
	@for i in $(INSTDIRS); do \
		cd $$i; \
		$(MAKE) install; \
		cd ..; \
	done
	@echo ""
	@echo "Now edit $(INSTALL_DIR)/template.conf"
	@echo "and move it to ircd.conf - and you'll be all set."
	@echo "See the doc/ directory and the INSTALL file for more assistance"
	@echo "Thank you for choosing Bahamut!"
	@echo ""
