# $Id: Makefile.in,v 1.56 2005/07/08 01:44:53 musirc Exp $

@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@
CRYPT_LIB	= @CRYPT_LIB@

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

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

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

IRCDLIBS	= @MODULES_LIBS@ @LIBS@
INCLUDES	= -I../include
CPPFLAGS	= ${INCLUDES} @CPPFLAGS@
 
default:	all

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

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

BASE_SRCS =	\
 auth.c \
 balloc.c \
 bsd.c \
 channel.c \
 channel_mode.c \
 client.c \
 config.c \
 @CRYPT_C@ \
 csvlib.c \
 dbuf.c	\
 @DYNLINK_C@ \
 event.c \
 fdlist.c \
 fileio.c \
 getaddrinfo.c \
 getnameinfo.c \
 getopt.c \
 hash.c	\
 hostmask.c \
 @INET_MISC@ \
 ircd.c \
 jupe.c	\
 lex.yy.c \
 list.c \
 listener.c \
 log.c \
 match.c \
 memory.c \
 misc.c \
 modules.c \
 motd.c \
 numeric.c \
 packet.c \
 parse.c \
 res.c \
 reslib.c \
 restart.c \
 send.c \
 server.c \
 signal.c \
 @SNPRINTF_C@ \
 sprintf.c \
 string.c \
 tools.c \
 user.c \
 whowas.c \
 y.tab.c

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

all: .depend ircd mkpasswd

build: all

ircd: @MODULES_LIBS@ $(OBJS) version.o
	${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} version.o ${IRCDLIBS}
	${MV} -f version.c version.c.last

mkpasswd: ../include/setup.h mkpasswd.c
	${CC} ${CFLAGS} ${LDFLAGS} mkpasswd.c -o mkpasswd ${CRYPT_LIB}

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

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

install: install-mkdirs build
	@for i in $(PROGS); do \
		$(INSTALL_BIN) $$i $(bindir); \
	done

version.c: version.c.SH
	/bin/sh ./version.c.SH

# 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 version.c version.c.last .depend

.PHONY: clean distclean install install-mkdirs build
