#
# Makefile.in for ircd/modules
#
# $Id: Makefile.in 715 2006-07-14 21:01:55Z michael $
#
# @evo tc added m_evo.c to be included during compile
CC		= gcc
AR		= /usr/bin/ar
RM		= /bin/rm
SED		= /bin/sed
SEDOBJ		= s/\.o/.so/g
STDOUT		= > .depend
CFLAGS		=  -Wall -O2 -g
PICFLAGS	= -fPIC -DPIC -shared
MKDEP		= gcc -MM
INSTALL		= /usr/bin/install -c
INSTALL_DATA	= ${INSTALL} -m 644
MV		= /bin/mv
LD		= /usr/bin/ld

SSL_LIBS	=  -lssl -lcrypto
SSL_INCLUDES	= 
IRCDLIBS        = -ldl -lcrypt  $(SSL_LIBS)

prefix          = $(DESTDIR)/home/tom/ircd
datarootdir	= $(DESTDIR)${prefix}/share
# Change this later! -- adrian
moduledir       = ${prefix}/modules
automoduledir   = ${moduledir}/autoload

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

CORE_SRCS = \
  core/m_die.c \
  core/m_join.c \
  core/m_kick.c \
  core/m_kill.c \
  core/m_message.c \
  core/m_mode.c \
  core/m_nick.c \
  core/m_part.c \
  core/m_quit.c \
  core/m_server.c \
  core/m_sjoin.c \
  core/m_squit.c

SSL_SRCS = \
  m_challenge.c \
  m_cryptlink.c

SRCS =       \
  m_accept.c \
  m_admin.c \
  m_away.c \
  m_cap.c \
  m_capab.c \
  m_cburst.c \
  m_close.c \
  $(SSL_SRCS) \
  m_connect.c \
  m_drop.c \
  m_encap.c \
  m_eob.c \
  m_etrace.c \
  m_evo.c \
  m_hash.c \
  m_help.c \
  m_gline.c \
  m_info.c \
  m_invite.c \
  m_ison.c \
  m_kline.c \
  m_knock.c \
  m_links.c \
  m_list.c \
  m_lljoin.c \
  m_llnick.c \
  m_locops.c \
  m_lusers.c \
  m_map.c \
  m_motd.c \
  m_names.c \
  m_nburst.c \
  m_omotd.c \
  m_oper.c \
  m_operwall.c \
  m_pass.c \
  m_ping.c \
  m_pong.c \
  m_post.c \
  m_rehash.c \
  m_restart.c \
  m_resv.c \
  m_rkline.c \
  m_rxline.c \
  m_set.c \
  m_stats.c \
  m_svinfo.c \
  m_tburst.c \
  m_testmask.c \
  m_testline.c \
  m_time.c \
  m_topic.c \
  m_trace.c \
  m_user.c \
  m_userhost.c \
  m_users.c \
  m_version.c \
  m_wallops.c \
  m_who.c \
  m_whois.c \
  m_whowas.c \
  m_xline.c

ALL_SRCS = $(CORE_SRCS) $(SRCS) $(SSL_SRCS)

SH_OBJS = ${SRCS:.c=.so}
SH_CORE_OBJS = ${CORE_SRCS:.c=.so}

HPUX_OBJS = ${SH_OBJS:.so=.sl}
HPUX_CORE_OBJS = ${SH_CORE_OBJS:.so=.sl}

S_OBJS = ${ALL_SRCS:.c=.o}

default:	build
build: all
all: .depend shared_modules

shared_modules: $(SH_CORE_OBJS) $(SH_OBJS)

hpux_shared: $(SH_CORE_OBJS) $(SH_OBJS) $(HPUX_CORE_OBJS) $(HPUX_OBJS)

libmodules.a: $(S_OBJS)
	$(RM) -f $@
	$(AR) csrv $@ $(S_OBJS) 

install-mkdirs:
	mkdir -p $(prefix)

	-@if test -d $(moduledir)-old; then \
		echo "${RM} -rf $(moduledir)-old"; \
		${RM} -rf $(moduledir)-old; \
	fi
	-@if test -d $(moduledir); then \
		echo "${MV} $(moduledir) $(moduledir)-old"; \
		${MV} $(moduledir) $(moduledir)-old; \
	fi

	mkdir -p $(moduledir) $(automoduledir)
	
install: install_shared_modules

install_libmodules.a: libmodules.a
# Ye olde noop here.	

install_shared_modules: install-mkdirs
	@echo "Installing core modules into $(moduledir) .."
	@for file in $(SH_CORE_OBJS); do \
		$(INSTALL_DATA) $$file $(moduledir); \
	done
	@echo "Installing modules into $(automoduledir) .."
	@for file in $(SH_OBJS); do \
		$(INSTALL_DATA) $$file $(automoduledir); \
	done

install_hpux_shared: install-mkdirs
	@echo "Installing core modules into $(moduledir) .."
	@for file in $(HPUX_CORE_OBJS); do \
		$(INSTALL_DATA) $$file $(moduledir); \
	done
	@echo "Installing modules into $(automoduledir) .."
	@for file in $(HPUX_OBJS); do \
		$(INSTALL_DATA) $$file $(automoduledir); \
	done

.SUFFIXES: .sl .so .o

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

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

.so.sl:
	$(LD) -b $< -o $@

.depend:
	${MKDEP} ${CPPFLAGS} ${ALL_SRCS} ${STDOUT}
	${SED} -e '${SEDOBJ}' < .depend > .depend.tmp-1
	${SED} -e 's/^m_\(server\|squit\|die\|join\|kick\|kill\|message\|mode\|nick\|part\|quit\|sjoin\)/core\/m_\1/' .depend.tmp-1 > .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
	${RM} -f .depend.tmp-1

clean:
	${RM} -f *.so *.sl *~ *.o *.a so_locations
	${RM} -f core/*.so core/*.sl core/*~ core/*.o

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

.PHONY: clean distclean install install_hpux_shared hpux_shared install_shared_modules shared_modules install_libmodules.a install-mkdirs build
# Autogenerated - do not delete
include .depend
