#
# Makefile.in for ircd/contrib
#
# $Id: Makefile.in 715 2006-07-14 21:01:55Z michael $
#
CC		= @CC@
RM		= @RM@
SED		= @SED@
SEDOBJ		= @SEDOBJ@
STDOUT		= @STDOUT@
MV		= @MV@
CFLAGS		= @IRC_CFLAGS@
LD		= @LD@
LN		= @LN@
PICFLAGS	= @PICFLAGS@
MKDEP		= @MKDEP@
INSTALL		= @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@

prefix		= $(DESTDIR)@prefix@
datarootdir	= $(DESTDIR)@datarootdir@

AUTOMODULEDIR	= ${prefix}/modules

SSL_LIBS	= @SSL_LIBS@
SSL_INCLUDES	= @SSL_INCLUDES@

IRCDLIBS	= @LIBS@ $(SSL_LIBS)

INCLUDES	= -I../include -I../lib/pcre $(SSL_INCLUDES)
CPPFLAGS	= ${INCLUDES} @CPPFLAGS@

SRCS = \
  ip_cloaking.c \
  m_capture.c   \
  m_change.c    \
  m_clearchan.c \
  m_classlist.c \
  m_ctrace.c \
  m_flags.c     \
  m_force.c     \
  m_jupe.c      \
  m_killhost.c  \
  m_ltrace.c \
  m_mkpasswd.c  \
  m_ojoin.c     \
  m_operspy.c   \
  m_opme.c      \
  m_services.c  \
  m_spoof.c

SHARED_ONLY_SRCS = \
  spy_admin_notice.c    \
  spy_info_notice.c     \
  spy_links_notice.c    \
  spy_motd_notice.c     \
  spy_stats_notice.c    \
  spy_stats_p_notice.c  \
  spy_trace_notice.c    \
  spy_whois_notice.c

OBJS = ${SRCS:.c=.so} ${SHARED_ONLY_SRCS:.c=.so}
SOBJS = ${SRCS:.c=.o}
SLOBJS = ${OBJS:.so=.sl}

default:	build
build: all
all: .depend @MOD_TARGET@

libmodules.a: ../modules/libmodules.a $(SOBJS)
	@echo "WARNING WARNING WARNING"
	@echo "These modules are unsupported by the hybrid team, but due to the"
	@echo "limits of your OS we link them all in by default. If you do NOT"
	@echo "want this to happen, take out references to the modules you don't"
	@echo "want in include/modules.h, src/modules.c, and this Makefile (SRCS.)"
	@echo "YOU HAVE BEEN WARNED!"
	
	$(AR) csrv ../modules/libmodules.a $(SOBJS)
	
	cd ../src && \
	$(CC) $(CPPFLAGS) $(CFLAGS) -DBUILD_CONTRIB -c modules.c || exit; \
	${MAKE} ircd
	
	@echo "New statically linked ircd binary has been generated; suggest $(MAKE) install."

shared_modules: $(OBJS)

hpux_shared: $(OBJS) $(SLOBJS)

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

install: all install_@MOD_TARGET@ install_help

install_shared_modules: $(OBJS)
	mkdir -p $(AUTOMODULEDIR)
	@echo "Installing modules into $(AUTOMODULEDIR) .."
	@for file in $(OBJS); do \
		$(INSTALL_DATA) $$file $(AUTOMODULEDIR); \
	done

install_hpux_shared: $(SLOBJS)
	mkdir -p $(AUTOMODULEDIR)
	@echo "Installing modules into $(AUTOMODULEDIR) .."
	@for file in $(SLOBJS); do \
		$(INSTALL_DATA) $$file $(AUTOMODULEDIR); \
	done

install_help:
	cd help && ${MAKE} install || exit; cd ..; 

install_libmodules.a:
# Ye olde noop.

.SUFFIXES: .so .sl .o

.c.so:
	${CC} ${PICFLAGS} ${CPPFLAGS} ${CFLAGS} $< -o $@

.c.o:
	${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@

.so.sl:
	${LD} -b $< -o $@
	
.depend:
	${MKDEP} ${CPPFLAGS} ${SRCS} ${STDOUT}
	${SED} -e '${SEDOBJ}' < .depend > .depend.tmp
	@${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
	${MV} -f .depend.tmp .depend

clean:
	${RM} -f *.so *.o *.sl *~ 
	cd help && ${MAKE} clean || exit; cd ..;

distclean: clean
	${RM} -f Makefile .depend
	cd help && ${MAKE} distclean || exit; cd ..;

.PHONY: depend clean distclean install_hpux_shared install_libmodules.a install_help shared_modules install hpux_shared build
