#
#  This is the Makefile for EGGDROP (the irc bot)
#  You should never need to edit this.
#

# things you can put here:
#   -Wall            if you're using gcc and it supports it (configure
#                      usually detects this anyway now)
#   -DEBUG_MEM       to be able to debug memory allocation (.debug)
#   -DEBUG_OUTPUT    to send everything sent to the server to +d console people
#   -DEBUG           logs random debugging comments to +d level (annoying
#                      and useless to most people)
#   -DREDHATSUX      if you get dprintf already defined errors in redhat
#
# *note* -DEBUG_TCL made so little code addition, I moved it into tcl
#    try set debug-tcl 1
#
# ok, Im a linux weenie, these settings with work for linux
#
CFLGS = -g

# configure SHOULD set these...you may need to tweak them to get modules
# to compile .. if you do...let the devel-team know the working settings
# btw to turn STRIP of, do STRIP=touch not STRIP=

CC=@CC@
LD=@CC@

#making eggmod
MOD_CC = @BEL_MOD_CC@
MOD_LD = @BEL_MOD_LD@
MOD_STRIP = @BEL_MOD_STRIP@
DLFLAGS= @DLFLAGS@

#makind modules
SHLIB_CC = @SHLIB_CC@
SHLIB_LD  = @SHLIB_LD@
SHLIB_STRIP = @SHLIB_STRIP@

# STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP #
# - - - - - - - - do not edit anything below this line. - - - - - - - - #
# - - - - - - - - -  it's all done by configure now.  - - - - - - - - - #
# STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP #


# stuff for Tcl
XREQ = @TCL_REQS@
TCLLIB = @TCLLIB@

CFLAGS = -c @CFLAGS@ -I.. @DEFS@ ${CFLGS}
@SET_MAKE@

all:    @DEFAULT_MAKE@

help:
	@echo "To make eggdrop :"
	@echo "   % make "

clean: cleanmods
	@rm -f eggdrop egg core *.o *.a *.so *~ *.stamp
	@cd src ; rm -f eggdrop egg core *.o *.a *~
	
cleanmods:
	@cd src/mod ; make clean

dist: clean
	@rm -f Makefile config.cache config.log config.status config.h lush.h
	@rm -f doc/*~
	@echo "all:" >Makefile
	@echo "	@./configure; make" >>Makefile

eggdrop: always modegg modules

debug: always debugmod moddebug

always: 

# Justin Slootsky says some systems need this (?)
src/libtcle.a: ${TCLLIB}/lib@TCLLIBFN@
	@echo "[ Fixing lib@TCLLIBFN@ -> libtcle.a ]"
	cp ${TCLLIB}/lib@TCLLIBFN@ src/libtcle.a
	chmod u+rw src/libtcle.a
	ar d src/libtcle.a tclMain.o
	@RANLIB@ src/libtcle.a

eggdrop.h:
	@echo You do not have the eggdrop source!
	@exit 1

OBJS = botcmd.o botnet.o chan.o chanprog.o chanset.o cmds.o cmdsirc.o \
	dcc.o dccutil.o gotdcc.o main.o mem.o misc.o mode.o modules.o \
	msgcmds.o msgnotice.o net.o notes.o \
	tcl.o tclchan.o tcldcc.o tclhash.o tclmisc.o tcluser.o userrec.o\
	users.o

GMAKE_STATIC = ${MAKE} 'CC=${CC}' 'LD=${LD}' 'OBJS=${OBJS}'\
'STRIP=${MOD_STRIP}' 'CFLAGS=${CFLAGS} -DSTATIC' 'XLIBS=@TCL_LIBS@ @LIBS@'

GMAKE_SHLIB = ${MAKE} 'CC=${SHLIB_CC}' 'LD=${SHLIB_LD}' 'OBJS=${OBJS}'\
'STRIP=${SHLIB_STRIP}' 'CFLAGS=${CFLAGS}' 'XLIBS=@TCL_LIBS@ @LIBS@'

GMAKE_MOD = ${MAKE} 'CC=${MOD_CC}' 'LD=${MOD_LD}' 'OBJS=${OBJS}'\
'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' \
'TCLLIB=${TCLLIB}' 'STRIP=${MOD_STRIP}' 'RANLIB=@RANLIB@' \
'XLIBS=@TCL_LIBS@ @LIBS@'

DMAKE_SHLIB = ${MAKE} 'CC=${SHLIB_CC}' 'LD=${SHLIB_LD}' 'OBJS=${OBJS}'\
'STRIP=touch' 'CFLAGS=${CFLAGS}' 'XLIBS=@TCL_LIBS@ @LIBS@'

DMAKE_MOD = ${MAKE} 'CC=${MOD_CC}' 'LD=${MOD_LD} -g' 'OBJS=${OBJS}'\
'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' \
'TCLLIB=${TCLLIB}' 'STRIP=touch' 'RANLIB=@RANLIB@' \
'XLIBS=@TCL_LIBS@ @LIBS@'

static:
	@echo ""
	@echo "Making module objects for static linking..."
	@echo ""
	@cd src/mod;${GMAKE_STATIC} static
	@echo ""
	@echo "Making core eggdrop for static linking..."
	@echo ""
	@cd src;${GMAKE_STATIC} static

modegg:
	@cd src;${GMAKE_MOD} eggdrop
	@echo
	@./eggdrop -v
	@ls -la eggdrop
	
modules:
	@cd src/mod;${GMAKE_SHLIB} modules
	@echo
	@echo "modules made:"
	@ls -la *.so
  
debugmod:
	@cd src;${DMAKE_MOD} eggdrop
	@echo
	@./eggdrop -v
	@ls -la eggdrop
  	
moddebug:
	@cd src/mod;${DMAKE_SHLIB} modules
	@echo
	@echo "modules made:"
	@ls -la *.so
	
#safety hash
