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

CC		= @CC@
INSTALL		= @INSTALL@
INSTALL_BIN	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
CFLAGS		= @IRC_CFLAGS@
LDFLAGS   	= @LDFLAGS@
MKDEP		= @MKDEP@
STDOUT		= @STDOUT@
MV		= @MV@
RM		= @RM@
SED		= @SED@

prefix		= @prefix@
exec_prefix	= $(DESTDIR)@exec_prefix@
bindir		= $(DESTDIR)@bindir@
sysconfdir	= $(DESTDIR)@sysconfdir@
localstatedir	= $(DESTDIR)@localstatedir@
datarootdir	= $(DESTDIR)@datarootdir@

# must not have whitespace here
CLOBBER=@CLOBBER@

NETIO_SRC	= s_bsd_@SELECT_TYPE@.c
INET_MISC	= @INET_MISC@

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

SSL_LIBS	= @SSL_LIBS@
SSL_INCLUDES	= @SSL_INCLUDES@
IRCDLIBS	= @MODULES_LIBS@ @LIBS@ ../lib/pcre/libpcre.a $(SSL_LIBS)
INCLUDES	= -I../include -I../lib/pcre $(SSL_INCLUDES)
CPPFLAGS	= ${INCLUDES} @CPPFLAGS@
 
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 \
 @CRYPT_C@ \
 csvlib.c \
 dbuf.c	\
 @DYNLINK_C@ \
 event.c \
 fdlist.c \
 fileio.c \
 getopt.c \
 hash.c	\
 hook.c	\
 hostmask.c \
 @INET_MISC@ \
 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_ENABLE@ \
 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 \
 @SNPRINTF_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: @MODULES_LIBS@ ../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
