#************************************************************************
#*   IRC - Internet Relay Chat, src/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$
#*/

CC = "==== DO NOT RUN MAKE FROM THIS DIRECTORY ===="

OBJS=dns.o auth.o channel.o crule.o dbuf.o \
	fdlist.o hash.o ircd.o ircsprintf.o list.o \
	match.o modules.o parse.o mempool.o operclass.o \
	conf_preprocessor.o conf.o debug.o dispatch.o numeric.o \
	misc.o serv.o aliases.o socket.o \
	tls.o user.o scache.o send.o support.o \
	version.o whowas.o random.o api-usermode.o api-channelmode.o \
	api-moddata.o api-extban.o api-isupport.o api-command.o \
	api-clicap.o api-messagetag.o api-history-backend.o api-efunctions.o \
	api-event.o \
	crypt_blowfish.o unrealdb.o updconf.o crashreport.o modulemanager.o \
	utf8.o log.o \
	openssl_hostname_validation.o $(URL)

SRC=$(OBJS:%.o=%.c)

# Flags specific for the ircd binary (and it's object files)...
# .. but NOT for modules.
BINCFLAGS=@HARDEN_BINCFLAGS@
BINLDFLAGS=@DYNAMIC_LDFLAGS@ @HARDEN_BINLDFLAGS@

INCLUDES = ../include/channel.h \
	../include/common.h ../include/config.h ../include/dbuf.h \
	../include/dynconf.h ../include/fdlist.h ../include/h.h \
	../include/ircsprintf.h \
	../include/license.h \
	../include/modules.h ../include/modversion.h ../include/msg.h \
	../include/numeric.h ../include/proto.h \
	../include/resource.h ../include/setup.h \
	../include/struct.h ../include/sys.h \
	../include/types.h \
	../include/version.h ../include/whowas.h \
	../include/openssl_hostname_validation.h

.SUFFIXES:
.SUFFIXES: .c .h .o

all: build

build:
	# Force build of 'ircd', before we start building any modules:
	$(MAKE) ircd
	$(MAKE) mods

custommodule:
	+cd modules/third; $(MAKE) MODULEFILE=$(MODULEFILE) 'EXLIBS=$(EXLIBS)' custommodule

ircd: $(OBJS)
	$(CC) $(CFLAGS) $(BINCFLAGS) $(CRYPTOLIB) -o ircd $(OBJS) $(LDFLAGS) $(BINLDFLAGS) $(IRCDLIBS) $(CRYPTOLIB)

mods:
	@if [ ! -r include ] ; then \
		ln -s ../include include; \
	fi
	@if [ ! -r modules ] ; then \
		echo "You havent done cvs update -P -d"; \
	fi
	+cd modules; $(MAKE) all

version.c: version.c.SH
	$(SHELL) version.c.SH

%.o:	%.c $(INCLUDES)
	$(CC) $(CFLAGS) $(BINCFLAGS) -c $<

clean:
	$(RM) -f *.o *.so *~ core ircd version.c; \
	cd modules; ${MAKE} clean

cleandir: clean

depend:
	makedepend -I${INCLUDEDIR} ${SRC}

# DO NOT DELETE THIS LINE -- make depend depends on it.
