#
#  This is the Makefile for EGGDROP (the irc bot)
#  You should never need to edit this.
#
# $Id: Makefile.in,v 1.29 2001/12/20 00:10:42 guppy Exp $

SHELL = @SHELL@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

@SET_MAKE@
prefix = @prefix@
DEST = @DEST@
EGGEXEC = @EGGEXEC@
EGGVERSION = @EGGVERSION@

# things you can put here:
#   -Wall            if you're using gcc and it supports it
#                    (configure usually detects this anyway now)
#
#   -DDEBUG_ASSERT   to enable assert debugging
#   -DDEBUG_MEM      to be able to debug memory allocation (.debug)
#                    These can both be set by using 'make debug'
#                    or 'make sdebug'
CFLGS =

# 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 off, do 'STRIP = touch' not 'STRIP ='

# defaults
CC = @CC@
LD = @CC@
STRIP = @STRIP@
RANLIB = @RANLIB@

# make eggmod
MOD_CC = @MOD_CC@
MOD_LD = @MOD_LD@
MOD_STRIP = @MOD_STRIP@

# make modules
SHLIB_CC = @SHLIB_CC@
SHLIB_LD = @SHLIB_LD@
SHLIB_STRIP = @SHLIB_STRIP@
MOD_EXT = @MOD_EXT@

# programs make install uses
LN_S = @LN_S@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@

# 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
XREQS = @TCL_REQS@
XLIBS = @TCL_LIBS@ @LIBS@
TCLLIB = @TCLLIB@
TCLLIBFN = @TCLLIBFN@

DEBCFLAGS = -DDEBUG_ASSERT -DDEBUG_MEM 

modconf = $(top_srcdir)/misc/modconfig --top_srcdir=$(top_srcdir)

egg_test_run =  EGG_LANGDIR=$(top_srcdir)/language ./$(EGGEXEC) -v

post_config  =  echo "" && \
		echo "You can now compile the bot, using \"make\"." && \
		echo ""

post_iconfig =  $(modconf) update-depends && \
		$(modconf) Makefile && \
		(cd src/mod && $(MAKE_CONFIG) config) && \
		$(modconf) Makefile

egg_install_msg =  echo "" && \
		   echo "Now run \"make install\" to install your bot." && \
		   echo ""

MAKE_MODEGG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(MOD_CC)' 'LD=$(MOD_LD)' \
'STRIP=$(MOD_STRIP)' 'RANLIB=$(RANLIB)' 'CFLGS=$(CFLGS)' \
'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \
'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=' 'MODOBJS='

MAKE_MODULES = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(SHLIB_CC)' 'LD=$(SHLIB_LD)' \
'STRIP=$(SHLIB_STRIP)' 'CFLGS=$(CFLGS)' 'XLIBS=$(XLIBS)' 'MOD_EXT=$(MOD_EXT)'

MAKE_STATIC = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
'STRIP=$(STRIP)' 'RANLIB=$(RANLIB)' 'CFLGS=$(CFLGS) -DSTATIC' \
'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \
'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(static version)' \
'MODOBJS=mod/*.o'

MAKE_DEBEGG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(MOD_CC)' 'LD=$(MOD_LD) -g' \
'STRIP=touch' 'RANLIB=$(RANLIB)' 'CFLGS=-g3 $(DEBCFLAGS) $(CFLGS)' \
'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \
'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(debug version)' 'MODOBJS='

MAKE_DEBMODULES = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(SHLIB_CC)' 'LD=$(SHLIB_LD)' \
'XLIBS=$(XLIBS)' 'STRIP=touch' 'CFLGS=-g3 $(DEBCFLAGS) $(CFLGS)' \
'MOD_EXT=$(MOD_EXT)'

MAKE_SDEBUG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD) -g' \
'STRIP=touch' 'RANLIB=$(RANLIB)' 'CFLGS=-g3 $(DEBCFLAGS) -DSTATIC $(CFLGS)' \
'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \
'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(static and debug version)' 'MODOBJS=mod/*.o'

MAKE_DEPEND = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
'STRIP=$(STRIP)' 'CFLGS=$(CFLGS)'

MAKE_CONFIG = $(MAKE) 'MAKE=$(MAKE)'

MAKE_INSTALL = $(MAKE) 'MAKE=$(MAKE)' 'DEST=$(DEST)'

all: @DEFAULT_MAKE@

eggclean:
	@rm -f $(EGGEXEC) *.$(MOD_EXT) *.stamp core DEBUG *~
	@cd doc && $(MAKE) clean
	@cd scripts && $(MAKE) clean
	@cd src && $(MAKE) clean
	@cd src/md5 && $(MAKE) clean
	@cd src/compat && $(MAKE) clean

clean: eggclean
	@cd src/mod && $(MAKE) clean

distclean: eggclean clean-modconfig
	@cd src/mod && $(MAKE) distclean
	@rm -f Makefile doc/Makefile scripts/Makefile src/Makefile src/md5/Makefile src/compat/Makefile src/mod/Makefile
	@rm -f config.cache config.log config.status config.h lush.h
	@rm -rf autom4te.cache

distrib: distclean
	@rm -f `find . \( -name '*~' -o -name '*#' -o -name '*.orig' \
		-o -name '*.rej' -o -name '*.bak' \) -print`
	@rm -rf `find . \( -name 'CVS' \) -print`
	@(echo "all:"; \
	echo "	@echo \"\""; \
	echo "	@echo \"Before you can compile your bot you have to configure it.\""; \
	echo "	@echo \"So please start the configure script now:\""; \
	echo "	@echo \"\""; \
	echo "	@echo \" % ./configure\""; \
	echo "	@echo \"\""; ) > Makefile

depend:
	@cat /dev/null > lush.h
	@cd src && $(MAKE_DEPEND) depend
	@cd src/md5 && $(MAKE_DEPEND) depend
	@cd src/mod && $(MAKE_DEPEND) depend
	@cd src/compat && $(MAKE_DEPEND) depend

eggautoconf:
	@$(modconf) eggautoconf

config:
	@$(modconf) modules-still-exist
	@$(modconf) detect-modules
	@$(modconf) update-depends
	@$(modconf) Makefile
	@cd src/mod && $(MAKE_CONFIG) config
	@$(modconf) Makefile
	@$(post_config)

new-iconfig:
	@$(modconf) modules-still-exist
	@$(modconf) update-depends
	@$(modconf) -n configure
	@$(post_iconfig)
	@$(post_config)

iconfig:
	@$(modconf) modules-still-exist
	@$(modconf) detect-modules
	@$(modconf) update-depends
	@$(modconf) configure
	@$(post_iconfig)
	@$(post_config)

clean-modconfig:
	@rm -f .modules .known_modules

conftest:
	@if test ! -f .modules; then \
		echo ""; \
		echo "You have NOT configured the modules yet. This has to be done"; \
		echo "before you can start compiling."; \
		echo ""; \
		echo "   Run \"make config\" or \"make iconfig\" now."; \
		echo ""; \
		exit 1; \
	fi

reconfig: clean-modconfig config

eggdrop: modegg modules

modegg: modtest
	@rm -f src/mod/mod.xlibs
	@cd src && $(MAKE_MODEGG) $(EGGEXEC)
	@echo ""
	@$(egg_test_run)
	@ls -l $(EGGEXEC)

modules: modtest
	@cd src/mod && $(MAKE_MODULES) modules
	@echo ""
	@echo "modules made:"
	@ls -l *.$(MOD_EXT)
	@$(egg_install_msg)

static: eggtest
	@echo ""
	@echo "Making module objects for static linking..."
	@echo ""
	@rm -f src/mod/mod.xlibs
	@cd src/mod && $(MAKE_STATIC) static
	@echo ""
	@echo "Making core eggdrop for static linking..."
	@echo ""
	@cd src && $(MAKE_STATIC) $(EGGEXEC)
	@echo ""
	@$(egg_test_run)
	@ls -l $(EGGEXEC)
	@$(egg_install_msg)

debug: debegg debmodules

debegg: modtest
	@cd src && $(MAKE_DEBEGG) $(EGGEXEC)
	@echo ""
	@$(egg_test_run)
	@ls -l $(EGGEXEC)

debmodules: modtest
	@cd src/mod && $(MAKE_DEBMODULES) modules
	@echo ""
	@echo "modules made:"
	@ls -l *.$(MOD_EXT)
	@$(egg_install_msg)

sdebug: eggtest
	@echo ""
	@echo "Making module objects for static linking..."
	@echo ""
	@rm -f src/mod/mod.xlibs
	@cd src/mod && $(MAKE_SDEBUG) static
	@echo ""
	@echo "Making core eggdrop for static linking..."
	@echo ""
	@cd src && $(MAKE_SDEBUG) $(EGGEXEC)
	@echo ""
	@$(egg_test_run)
	@ls -l $(EGGEXEC)
	@$(egg_install_msg)

eggtest: conftest
	@if test -f EGGMOD.stamp; then \
		echo "You're trying to do a STATIC build of eggdrop when you've";\
		echo "already run 'make' for a module build.";\
		echo "You must first type \"make clean\" before you can build";\
		echo "a static version.";\
		exit 1;\
	fi
	@echo "stamp" >EGGDROP.stamp

modtest: conftest
	@if [ -f EGGDROP.stamp ]; then \
		echo "You're trying to do a MODULE build of eggdrop when you've";\
		echo "already run 'make' for a static build.";\
		echo "You must first type \"make clean\" before you can build";\
		echo "a module version.";\
		exit 1;\
	fi
	@echo "stamp" >EGGMOD.stamp

install: ainstall

dinstall: eggdrop ainstall

sinstall: static ainstall

ainstall: install-start install-bin install-modules install-data \
install-help install-language install-filesys install-doc \
install-scripts install-end

install-start:
	@if test ! -f $(EGGEXEC); then \
		echo ""; \
		echo "You haven't compiled eggdrop yet."; \
		echo "To compile eggdrop use:"; \
		echo "  make <target>"; \
		echo ""; \
		echo "  valid targets: eggdrop static debug sdebug"; \
		echo ""; \
		exit 1; \
	fi
	@if test "x$(DEST)" = "x"; then \
		echo "You must specify a destination directory with DEST="; \
		exit 1; \
	fi
	@echo ""
	@$(egg_test_run)
	@echo
	@echo "Installing in directory: '$(DEST)'."
	@echo
	@if test ! -d $(DEST); then \
		echo "Creating directory: $(DEST)."; \
		$(top_srcdir)/misc/mkinstalldirs $(DEST); \
	fi

install-bin:
	@if test -f $(DEST)/o$(EGGEXEC); then \
		rm -f $(DEST)/o$(EGGEXEC); \
	fi
	@if test -h $(DEST)/$(EGGEXEC); then \
		echo "Removing symlink to archival eggdrop binary."; \
		rm -f $(DEST)/$(EGGEXEC); \
	fi
	@if test -f $(DEST)/$(EGGEXEC); then \
		echo "Renamed the old '$(EGGEXEC)' executable to 'o$(EGGEXEC)'."; \
		mv -f $(DEST)/$(EGGEXEC) $(DEST)/o$(EGGEXEC); \
	fi
	@echo "Copying new '$(EGGEXEC)' executable and creating symlink."
	@$(INSTALL_PROGRAM) $(EGGEXEC) $(DEST)/$(EGGEXEC)-$(EGGVERSION)
	@(cd $(DEST) && $(LN_S) $(EGGEXEC)-$(EGGVERSION) $(EGGEXEC))

install-modules:
	@if test -h $(DEST)/modules; then \
		echo "Removing symlink to archival modules directory."; \
		rm -f $(DEST)/modules; \
	fi
	@if test -d $(DEST)/modules; then \
		echo "Moving old modules into 'modules.old' directory."; \
		rm -rf $(DEST)/modules.old; \
		mv -f $(DEST)/modules $(DEST)/modules.old; \
	fi
	@if test ! "x`echo *.$(MOD_EXT)`" = "x*.$(MOD_EXT)"; then \
		if test ! -d $(DEST)/modules-$(EGGVERSION); then \
			echo "Creating modules-$(EGGVERSION) directory and symlink."; \
			$(top_srcdir)/misc/mkinstalldirs $(DEST)/modules-$(EGGVERSION); \
		fi; \
		(cd $(DEST) && $(LN_S) modules-$(EGGVERSION) modules); \
		echo "Copying new modules."; \
		for i in *.$(MOD_EXT); do \
			$(INSTALL_PROGRAM) $$i $(DEST)/modules-$(EGGVERSION)/; \
		done; \
	fi

install-data:
	@$(INSTALL_DATA) $(srcdir)/eggdrop.advanced.conf $(DEST)
	@$(INSTALL_DATA) $(srcdir)/eggdrop.complete.conf $(DEST)
	@$(INSTALL_DATA) $(srcdir)/eggdrop.simple.conf $(DEST)
	@if test ! -d $(DEST)/logs; then \
		echo "Creating 'logs' subdirectory."; \
		$(top_srcdir)/misc/mkinstalldirs $(DEST)/logs; \
		$(INSTALL_DATA) $(srcdir)/logs/CONTENTS $(DEST)/logs/; \
	fi;
	@if test ! -d $(DEST)/text; then \
		echo "Creating 'text' subdirectory."; \
		$(top_srcdir)/misc/mkinstalldirs $(DEST)/text; \
	fi;
	@if test ! -f $(DEST)/text/motd; then \
		$(INSTALL_DATA) $(srcdir)/text/motd $(DEST)/text/; \
	fi
	@if test ! -f $(DEST)/text/banner; then \
		$(INSTALL_DATA) $(srcdir)/text/banner $(DEST)/text/; \
	fi

install-help:
	@echo "Copying help files."
	@if test ! "x`echo $(srcdir)/help/*.help`" = "x$(srcdir)/help/*.help"; then \
		if test ! -d $(DEST)/help; then \
			echo "Creating 'help' subdirectory."; \
			$(top_srcdir)/misc/mkinstalldirs $(DEST)/help; \
		fi; \
		for i in $(srcdir)/help/*.help; do \
			$(INSTALL_DATA) $$i $(DEST)/help/; \
		done; \
	fi
	@if test ! "x`echo $(srcdir)/help/msg/*.help`" = "x$(srcdir)/help/msg/*.help"; then \
		if test ! -d $(DEST)/help/msg; then \
			echo "Creating 'help/msg' subdirectory."; \
			$(top_srcdir)/misc/mkinstalldirs $(DEST)/help/msg; \
		fi; \
		for i in $(srcdir)/help/msg/*.help; do \
			$(INSTALL_DATA) $$i $(DEST)/help/msg/; \
		done; \
	fi
	@if test ! "x`echo $(srcdir)/help/set/*.help`" = "x$(srcdir)/help/set/*.help"; then \
		if test ! -d $(DEST)/help/set; then \
			echo "Creating 'help/set' subdirectory."; \
			$(top_srcdir)/misc/mkinstalldirs $(DEST)/help/set; \
		fi; \
		for i in $(srcdir)/help/set/*.help; do \
			$(INSTALL_DATA) $$i $(DEST)/help/set/; \
		done; \
	fi
	@cd src/mod/ && $(MAKE_INSTALL) install-help

install-language:
	@echo "Copying language files."
	@if test ! "x`echo $(srcdir)/language/*.lang`" = "x$(srcdir)/language/*.lang"; then \
		if test ! -d $(DEST)/language; then \
			echo "Creating 'language' subdirectory."; \
			$(top_srcdir)/misc/mkinstalldirs $(DEST)/language; \
		fi; \
		for i in $(srcdir)/language/*.lang; do \
			$(INSTALL_DATA) $$i $(DEST)/language/; \
		done; \
	fi
	@cd src/mod && $(MAKE_INSTALL) install-language

install-filesys:
	@if test ! -d $(DEST)/filesys; then \
		echo "Creating a skeletal filesys subdirectory."; \
		$(top_srcdir)/misc/mkinstalldirs $(DEST)/filesys; \
		$(top_srcdir)/misc/mkinstalldirs $(DEST)/filesys/incoming; \
	fi

install-doc:
	@$(INSTALL_DATA) $(srcdir)/README $(DEST)
	@cd doc/ && $(MAKE_INSTALL) install

install-scripts:
	@cd scripts/ && $(MAKE_INSTALL) install

install-end:
	@echo
	@echo "Installation completed."
	@echo ""
	@echo "You MUST ensure that you edit/verify your configuration file."
	@echo "Use one of the three configuration files (eggdrop.simple.conf, eggdrop.advanced.conf and eggdrop.complete.conf) distributed with your bot."
	@echo ""
	@echo "Remember to change directory to $(DEST) before you proceed."
	@echo ""

#safety hash
