#
# Makefile.in for ircd/src
#
# $Id: Makefile.in 715 2006-07-14 21:01:55Z michael $
#


CC		= gcc
INSTALL		= /usr/bin/install -c
INSTALL_BIN	= ${INSTALL}
INSTALL_DATA	= ${INSTALL} -m 644
CFLAGS		=  -Wall -O2 -g
LDFLAGS   	=  -Wl,-export-dynamic
MKDEP		= gcc -MM
STDOUT		= > .depend
MV		= /bin/mv
RM		= /bin/rm
SED		= /bin/sed

prefix		= /home/tom/ircd
exec_prefix	= $(DESTDIR)${prefix}
bindir		= $(DESTDIR)${exec_prefix}/bin
sysconfdir	= $(DESTDIR)${prefix}/etc
localstatedir	= $(DESTDIR)${prefix}
datarootdir	= $(DESTDIR)${prefix}/share

# must not have whitespace here
CLOBBER=

NETIO_SRC	= s_bsd_epoll.c
INET_MISC	= 

# If you wish to change this, look in include/defaults.h also and change SPATH
PROGS		= ircd

SSL_LIBS	=  -lssl -lcrypto
SSL_INCLUDES	= 
IRCDLIBS	=  -ldl -lcrypt  ../lib/pcre/libpcre.a $(SSL_LIBS)
INCLUDES	= -I../include -I../lib/pcre $(SSL_INCLUDES)
CPPFLAGS	= ${INCLUDES} 
 
default:	all

y.tab.o:	y.tab.c ircd_parser.y
	${CC} ${CPPFLAGS} ${CFLAGS} -I. -c y.tab.c

lex.yy.o:	y.tab.c lex.yy.c ircd_lexer.l
	${CC} ${CPPFLAGS} ${CFLAGS} -I. -c lex.yy.c

SSL_SRCS = rsa.c

BASE_SRCS =	\
 balloc.c \
 channel.c \
 channel_mode.c \
 client.c \
  \
 csvlib.c \
 dbuf.c	\
 dynlink.c \
 event.c \
 fdlist.c \
 fileio.c \
 getopt.c \
 hash.c	\
 hook.c	\
 hostmask.c \
  \
 irc_getaddrinfo.c \
 irc_getnameinfo.c \
 irc_res.c \
 irc_reslib.c \
 irc_string.c \
 ircd.c \
 ircd_signal.c \
 lex.yy.c \
 list.c \
 listener.c \
 m_error.c \
 match.c \
 memory.c \
 modules.c \
 motd.c \
 numeric.c \
 packet.c \
 parse.c \
 restart.c \
 resv.c	\
 $(SSL_SRCS) \
 s_auth.c \
 s_bsd.c \
 s_conf.c \
 s_gline.c \
 s_log.c \
 s_misc.c \
 s_serv.c \
 s_stats.c \
 s_user.c \
 send.c \
  \
 sprintf_irc.c \
 tools.c \
 version.c \
 whowas.c \
 y.tab.c

SRCS = ${BASE_SRCS} $(NETIO_SRC)
OBJS = ${SRCS:.c=.o}

all: .depend ircd

build: all

ircd:  ../lib/libpcre.a $(OBJS)
	${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${IRCDLIBS}

../modules/libmodules.a:
	cd ../modules && ${MAKE} ${MFLAGS}
../lib/libpcre.a:
	cd ../lib/pcre && ${MAKE} ${MFLAGS}

install-mkdirs:
	mkdir -p $(DESTDIR)$(prefix) $(exec_prefix) $(bindir) $(sysconfdir) \
		$(localstatedir)/logs

install: install-mkdirs build
	@for i in $(PROGS); do \
		if test -f $(bindir)/$$i -a -z "$(CLOBBER)"; then \
			echo $(MV) $(bindir)/$$i $(bindir)/$$i.old; \
			$(MV) $(bindir)/$$i $(bindir)/$$i.old; \
		fi; \
		echo $(INSTALL_BIN) $$i $(bindir); \
		$(INSTALL_BIN) $$i $(bindir); \
	done

# this is really the default rule for c files
.c.o:
	${CC} ${CPPFLAGS} ${CFLAGS} -c $<

.depend:
	${MKDEP} ${CPPFLAGS} ${BASE_SRCS} ${NETIO_SRC} ${STDOUT}
	@${SED} -e '/^# Autogenerated - do not delete/,$$d' <Makefile >Makefile.depend
	@echo "# Autogenerated - do not delete" >> Makefile.depend
	@echo "include .depend" >> Makefile.depend
	@${MV} Makefile.depend Makefile

clean:
	${RM} -f *.o *.exe *~ *core ircd

distclean: clean
	${RM} -f Makefile .depend

.PHONY: clean distclean install install-mkdirs build
# Autogenerated - do not delete
include .depend
