#
#  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_TCL       writes a DEBUG.TCL file which grows really fast and
#                      logs EVERY command sent to Tcl
#   -DEBUG           logs random debugging comments to +d level (annoying
#                      and useless to most people)
CFLGS = 


# 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 #


# Modify these appropriately. I'm too lazy to make configure do it.
# These are the cp commands that make install uses.
CP1 = cp -f 
CP2 = cp -rf 
CP3 = cp -pf

# stuff for Tcl
XREQ = @TCL_REQS@ 
TCLLIB = @TCLLIB@ 
CFLAGS = -c @CFLAGS@ -I.. @DEFS@ ${CFLGS} @SET_MAKE@ 

all: eggdrop

help:
	@echo Makefile for Eggdrop.
	@echo "To make eggdrop (the bot):"
	@echo "   % make eggdrop"

clean:
	@rm -f eggdrop egg core *.o *.a
	@cd src ; rm -f eggdrop egg core *.o *.a

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

eggdrop: always
	@cd src ; ${GMAKE} eggdrop
	@mv src/@EGGEXEC@ .
	@echo ""
	@./eggdrop -v
	@echo ""
	@echo "To copy the help files and executables into your bot's"
	@echo "directory, type:"
	@echo "   make install DEST=<my-bots-directory>"
	@echo ""

egg: always
	@cd src ; ${GMAKE} egg
	@mv src/egg .

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

GMAKE = ${MAKE} 'CC=@CC@' 'OBJS=${OBJS}' 'TCLLIBFN=@TCLLIBFN@'\
	'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS=@TCL_LIBS@ @LIBS@'\
	'TCLLIB=${TCLLIB}' 'RANLIB=@RANLIB@' 'STRIP=@STRIP@'

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

OBJS = blowfish.o botcmd.o botnet.o chan.o chanprog.o chanset.o cmds.o\
	dcc.o dccutil.o filedb.o fileq.o files.o gotdcc.o hash.o main.o\
	match.o mem.o misc.o mode.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

install: 
	@if test X$(DEST) = X; then \
		echo "You must specify a destination directory with DEST="; \
		exit 1; \
	fi
	@if test ! -x eggdrop; then \
		echo "You haven't compiled eggdrop yet."; \
		exit 1; \
	fi
	@./eggdrop -v
	@echo
	@echo Installing in directory: $(DEST). 
	@echo
	@if test ! -d $(DEST); then \
		echo Creating directory: $(DEST).; \
		mkdir $(DEST); \
	fi
	@if test -r $(DEST)/eggdrop; then \
		rm -f $(DEST)/oeggdrop; \
	fi
	@$(CP1) README $(DEST)/
	@if test ! -r $(DEST)/motd; then \
		$(CP1) motd $(DEST)/; \
	fi
	@if test -r $(DEST)/eggdrop; then \
		echo Renamed the old \'eggdrop\' executable to \'oeggdrop\'.; \
		mv -f $(DEST)/eggdrop $(DEST)/oeggdrop; \
	fi
	@if test ! -d $(DEST)/doc; then \
		echo Creating \'doc\' subdirectory.; \
		mkdir $(DEST)/doc; \
	fi
	@$(CP2) doc/* $(DEST)/doc
	@if test ! -d $(DEST)/help; then \
		echo Creating \'help\' subdirectory.; \
		mkdir $(DEST)/help; \
	fi
	@$(CP2) help/* $(DEST)/help/
	@if test ! -d $(DEST)/filesys; then \
		echo Creating a skeletal \'filesys\' subdirectory.; \
		mkdir $(DEST)/filesys; \
		mkdir $(DEST)/filesys/incoming; \
	fi
	@if test ! -d $(DEST)/scripts; then \
		echo Creating a \'scripts\' subdirectory.; \
		mkdir $(DEST)/scripts; \
	fi
	@$(CP2) scripts/* $(DEST)/scripts
	@echo
	@echo Installation completed. 
	@echo You MUST ensure that you edit/verify your configuration file! 
	@echo \'eggdrop.conf.dist\' lists current options. You should copy
	@echo this file over to $(DEST) after editing it.

