$Id: COMPILE-GUIDE,v 1.16 2011/10/02 20:51:31 pseudo Exp $

Eggdrop Compile Guide and FAQ
Last revised: October 02, 2011
    _____________________________________________________________________

                        Eggdrop Compile Guide and FAQ


  This guide may help you successfully compile Eggdrop. Suggestions are by
  various contributors. If you think something should be added, please send
  an e-mail to bugs@eggheads.org. Note that in this document, text between
  a '<' and a '>' should be replaced (without the '<' and '>').

  NOTE: This is not a 'quick install' guide. See the INSTALL file for basic
  setup information. This is intended to help you compile the bot on uncommon
  operating systems, or work past problems encountered during compile.


  Contents:
    Compile Guide:
      A. Standard compile process (Linux, FreeBSD, NetBSD, OpenBSD, etc)
      B. HP-UX B.11.*
      C. Ultrix
      D. Mac OS X
      E. AIX
      F. IRIX
      G. Solaris / SunOS
      H. Cygwin / Windows
      I. Tcl Detection and Installation

    Frequently Asked Questions:
      1. I get a lot of warnings.
      2. I get a 'strip terminated with signal 6' error during compile/install,
         or another error related to 'strip'.
      3. 'DIR' undeclared (and a whole bunch of others) (AIX 4)
      4. 'fd_set' undeclared (and a whole bunch of others) (AIX 4)
      5. Unresolved or undefined symbols: ldclose, ldopen, ldnshread (AIX 3)
      6. Unsatisfied symbols 'shl_findsym' and 'shl_load' (HP-UX 9)
      7. Compile stops at the last minute with "ld fatal signal 11"! (Linux)
      8. Undefined references in net.o (Sun OS)
      9. I experience problems starting the configure script (AIX/various)
     10. I get a 'make: Permission denied' error when I type 'make config'
         or 'make' (FreeBSD / *BSD)


  Compile Guide
    This will tell you how to compile Eggdrop on various operating systems.
    If you have gotten Eggdrop to compile on an operating system not listed
    here, please let the development team know how, at eggdev@eggheads.org.
    Please tell us what, if any, special steps were required to compile the
    bot. Also, any compiler warnings/etc, and the 'config.log' and 'config.h'
    files would be helpful. The development team does not have access to the
    resources needed to test portability on uncommon operating systems, so
    your help is greatly appreciated.

    A. Standard compile process (32-bit Linux, FreeBSD, NetBSD, OpenBSD, etc.)
    B. HP-UX B.11.*
    C. Ultrix
    D. Mac OS X
    E. AIX
    F. IRIX
    G. Solaris / SunOS
    H. Cygwin / Windows
    I. Tcl Detection and Installation

    A. Standard compile process (32-bit Linux, FreeBSD, NetBSD, OpenBSD, etc.)
      1. Type './configure' from the Eggdrop directory. Some of the options
         that can be given to ./configure are explained below.

           --enable-strip
             If you want to create a smaller binary, you can use this option.
             HOWEVER, this will remove debugging symbols and make bug reports
             almost completely useless, and is not recommended. If disk space
             is very limited, however, it might help to enable this.

           --with-tcllib
           --with-tclinc
             See 'I. Tcl Detection and Installation' below (at the end of this
             compile guide).

      2. Type either 'make config', or 'make iconfig' to determine which
         modules will be compiled.

      3. Type 'make' from the Eggdrop directory, or to force a statically
         linked module bot, type 'make static'. Otherwise, the Makefile will
         use whatever type of compile the configure script determined your
         system will support. Dynamic is always the better way to go if
         possible. You can force a dynamic build with 'make eggdrop'. There
         are also the 'debug' and 'sdebug' (static-debug) options, which will
         give more detailed output on a crash. This will help the development
         team track down the crash and fix the bug. Debug and sdebug will take
         a little longer to compile and will enlarge the binary a bit, but
         it's worth it if you want to support Eggdrop development.

      4. Eggdrop must be installed in a directory somewhere. This is
         accomplished by typing 'make install'.

         This will install the Eggdrop in your home directory in a directory
         called 'eggdrop' (i.e. /home/user/eggdrop).

         If you want to install to a different directory, use:

           make install DEST=<directory>

         For example:

           make install DEST=/home/user/otherdir

    B. HP-UX B.11.*
      Follow the standard compile process in Section A. To compile dynamically
      (with module support), use 'make eggdrop' instead of 'make'.

      During a linking in a dynamic build, you may experience an error such as:

        gcc -pipe -fPIC -shared -o ../eggdrop bg.o botcmd.o botmsg.o botnet.o
        chanprog.o cmds.o dcc.o dccutil.o dns.o flags.o language.o match.o
        main.o mem.o misc.o misc_file.o modules.o net.o rfc1459.o tcl.o
        tcldcc.o tclhash.o tclmisc.o tcluser.o userent.o userrec.o users.o
        -L/usr/local/lib -ltcl8.4 -lm -ldld -lnsl md5/md5c.o compat/*.o `cat
        mod/mod.xlibs`
        /usr/ccs/bin/ld: DP relative code in file bg.o - shared library must be
        position independent. Use +z or +Z to recompile.
        collect2: ld returned 1 exit status
        *** Error exit code 1

      If you know the cause of this error, please contact the Eggheads
      Development Team at eggdev@eggheads.org.

      Note that on HP-UX, the SHLIB_PATH environment variable should be used
      instead of LD_LIBRARY_PATH.


    C. Ultrix
      There are some known problems with 'make' and Eggdrop on Ultrix systems.
      We recommend using 'gmake' (GNU make) for this reason, as in the steps
      below.

      If your system does not have 'gmake', you can download it from:

        http://ftp.gnu.org/pub/gnu/make/

      It can be installed in your home directory, as with Tcl, but that is
      beyond the scope of this document. Read the INSTALL file that comes with
      gmake.

      Following these steps should work:

        1. Depending on what shell your using:

            bash/ksh:
              export LD_LIBRARY_PATH=<path to DIRECTORY containing Tcl library>:${LD_LIBRARY_PATH}

            csh/tcsh/tclsh:
              setenv LD_LIBRARY_PATH <path to DIRECTORY containing Tcl library>:${LD_LIBRARY_PATH}

          2. Run the following command from your Eggdrop compilation directory
             (this is all one command):

            sh5 ./configure --with-tclinc='<full path to tcl.h>'
            --with-tcllib='<full path to Tcl library>'

          3. Type 'gmake config' or 'gmake iconfig' to configure modules.

          4. Type 'gmake'. If you experience problems during linking, or while
             building modules, try using 'gmake static', for a static build,
             instead.

          5. To install Eggdrop, type 'gmake install'.

             This will install the Eggdrop in your home directory in a
             directory called 'eggdrop' (i.e. /home/user/eggdrop).

             If you want to install to a different directory, use:

               gmake install DEST=<directory>

             For example:

               gmake install DEST=/home/user/otherdir


    D. Mac OS X
      Follow the standard compile process in Section A. To compile dynamically
      (with module support), use 'make eggdrop' instead of 'make'.

      To get third-party modules to compile, you may need to edit the module's
      Makefile and add "$(XLIBS) $(MODULE_XLIBS)" to the end of the
      ../../../MODULE.$(MOD_EXT) target's $(LD) line.

      For example:

        ../../../mymodule.$(MOD_EXT): ../mymodule.o
        $(LD) -o ../../../mymodule.$(MOD_EXT) ../mymodule.o
        $(STRIP) ../../../mymodule.$(MOD_EXT)

      Would become:

        ../../../mymodule.$(MOD_EXT): ../mymodule.o
        $(LD) -o ../../../mymodule.$(MOD_EXT) ../mymodule.o $(XLIBS) $(MODULE_XLIBS)
        $(STRIP) ../../../mymodule.$(MOD_EXT)

      If you notice a module that requires these changes, it would probably be
      a good idea to let the module's developer know, so it can be fixed.


      Note that on Mac OS X, the DYLD_LIBRARY_PATH environment variable should
      be used instead of LD_LIBRARY_PATH.


    E. AIX
      Follow the standard compile process in Section A. To compile dynamically
      (with module support), use 'make eggdrop' instead of 'make'.

      Note that on AIX, the LIBPATH environment variable should be used instead
      of LD_LIBRARY_PATH.


    F. IRIX
      Follow the standard compile process in Section A. To compile dynamically
      (with module support), use 'make eggdrop' instead of 'make'.

      Note that on IRIX, the LD_LIBRARYN32_PATH and LD_LIBRARY64_PATH environment
      variables should be used instead of LD_LIBRARY_PATH.


    G. Solaris / SunOS
      Follow the standard compile process in Section A. To compile dynamically
      (with module support), use 'make eggdrop' instead of 'make'.

      Note that on Solaris / SunOS, the LD_LIBRARY_PATH_32 and LD_LIBRARY_PATH_64
      environment variables may need to be set instead of (or in addition to, to
      be safe) LD_LIBRARY_PATH.


    H. Cygwin / Windows
      To compile and install Eggdrop on windows, perform the steps listed
      below.

        1. Download and install Cygwin (www.cygwin.com). Make sure to install
           things like GCC, zlib, autoconf, and automake. DO NOT install the Tcl
           provided by Cygwin's installer. After installing, open the Cygwin
           bash prompt.

        2. Download and install TCL 8.5.9 or later. You can get Tcl for Cygwin
           at http://prdownloads.sourceforge.net/windrop/tcl-8.5.9.tar.gz.
           Extract this to the Cygwin root directory:

             cd /
             tar -zxf tcl-8.5.9.tar.gz

        3. Download Eggdrop from geteggdrop.com to your home directory.
           This is usually something like 'C:\cygwin\home\<username>\'. After
           downloading, extract the Eggdrop tarball:

             tar -zxf eggdrop1.6.21.tar.gz

        4. Run './configure --enable-strip'. Debugging information under
           Windows is basically useless to the development team, and this will
           reduce the size of your Eggdrop binary.

        5. Type either 'make config', or 'make iconfig' to determine which
           modules will be compiled.

        6. Compile the bot using 'make eggdrop'.

        7. Install the bot by typing 'make install DEST=<install path>'.
           For example:

             make install DEST='C:/eggdrop/'

           Make sure to enclose the destination directory/folder in single
           quotes (''), especially if it contains spaces.

        8. Perform the following commands:

             cd 'C:/<install path>/' (example: cd 'C:/eggdrop')
             rm modules
             rm eggdrop.exe
             mv eggdrop.exe-1.6.21 eggdrop.exe
             mv modules-1.6.21 modules

        9. Create a 'lib' directory and copy needed libraries using the
           following commands. This assumes that you installed your Eggdrop in
           'C:\eggdrop'. If you chose a different installation path, replace
           'C:/eggdrop' in the following steps with your installation
           directory, replacing all '\'s with '/'s.

             cp /bin/cygwin1.dll 'C:/eggdrop'
             cp /usr/local/bin/libtcl8.5.dll 'C:/eggdrop'

             mkdir C:/eggdrop/lib
             cp -r /usr/local/lib/tcl 'C:/eggdrop/lib'
             cp -r /usr/local/lib/tcl8.5 'C:/eggdrop/lib'

             cp /bin/cygz.dll 'C:/eggdrop' (if you selected compress.mod)


    I. Tcl Detection and Installation
        If ./configure does not correctly detect the location of your Tcl
        library and header file, or if you experience errors related to Tcl
        during linking, perform these steps:

          1. Depending on what shell your using:

            bash/ksh:
              export LD_LIBRARY_PATH=<path to DIRECTORY containing Tcl library>:${LD_LIBRARY_PATH}

            csh/tcsh/tclsh:
              setenv LD_LIBRARY_PATH <path to DIRECTORY containing Tcl library>:${LD_LIBRARY_PATH}

            Note that some OS's use a different environment variable to tell
            ld where to look for a library. See the notes for your specific OS
            above (if applicable).

          2. Run the following command from your Eggdrop compilation directory
             (this is all one command):

            ./configure --with-tclinc='<full path to tcl.h>'
            --with-tcllib='<full path to Tcl library>'

          3. Continue compiling the bot as outlined in Section A., starting
             with 'make config'.

        If you do not have Tcl installed on your system, you can compile it in
        your /home directory. Download Tcl from Tcl's SourceForge project page
        at http://www.sourceforge.net/projects/tcl/, or from ActiveState at
        ftp://tcl.activestate.com/pub/tcl/. Read Tcl's README file for help
        with compiling and installing it. After you compile Tcl, follow the
        steps above to allow Eggdrop to detect Tcl.


  Frequently Asked Questions
    1. I get a lot of warnings.

      Warnings do not necessarily mean anything bad. As long as the compile
      completes, there is really nothing to worry about. Generally, we try to
      avoid warnings. We try to fix the warnings we are aware of. If you
      experience warnings, you can let us know by e-mailing bugs@eggheads.org.
      If you feel like fixing them yourself, please do so and send us a patch
      (as described in doc/PATCH_HOWTO). Thanks.


    2. I get a 'strip terminated with signal 6' error during compile/install,
       or another error related to 'strip'.

      collect2: strip terminated with signal 6 [IOT/Abort trap]
      *** Exit 1
      Stop.
      *** Exit 1
      Stop.

      Don't use the --enable-strip ./configure option.


    3. 'DIR' undeclared (and a whole bunch of others) (AIX 4)

      gcc -c -O2 -fno-strength-reduce -I.. -DHAVE_CONFIG_H  filedb.c
      filedb.c: In function `filedb_update':
      filedb.c:209: `DIR' undeclared (first use this function)
      filedb.c:209: (Each undeclared identifier is reported only once
      filedb.c:209: for each function it appears in.)
      filedb.c:209: `dir' undeclared (first use this function)
      filedb.c:209: parse error before `*'
      filedb.c:217: warning: assignment makes pointer from integer without a cast
      filedb.c:218: `name' undeclared (first use this function)
      filedb.c:218: dereferencing pointer to incomplete type
      filedb.c:220: dereferencing pointer to incomplete type
      filedb.c:220: dereferencing pointer to incomplete type
      filedb.c:224: dereferencing pointer to incomplete type
      filedb.c:224: dereferencing pointer to incomplete type
      filedb.c:225: dereferencing pointer to incomplete type
      filedb.c:230: `s' undeclared (first use this function)
      filedb.c:231: `st' undeclared (first use this function)
      filedb.c:232: `fdb' undeclared (first use this function)
      filedb.c:232: `where' undeclared (first use this function)
      filedb.c:237: `fdb1' undeclared (first use this function)
      filedb.c:253: warning: assignment makes pointer from integer without a cast
      make: The error code from the last command is 1.

      The configure script didn't detect that this particular system had dirent.h
      and sys/dir.h. The solution is to add -DHAVE_DIRENT_H -DHAVE_SYS_DIR_H to
      the Makefile's CFLGS line:

        CFLGS = -DHAVE_DIRENT_H -DHAVE_SYS_DIR_H


    4. 'fd_set' undeclared (and a whole bunch of others) (AIX 4)

      gcc -c -O2 -fno-strength-reduce -I.. -DHAVE_CONFIG_H -DHAVE_DIRENT_H -DHAVE_SYS_DIR_H net.c
      net.c: In function `sockread':
      net.c:390: `fd_set' undeclared (first use this function)
      net.c:390: (Each undeclared identifier is reported only once
      net.c:390: for each function it appears in.)
      net.c:390: parse error before `fd'
      net.c:396: `fd' undeclared (first use this function)
      make: The error code from the last command is 1.

      Again, this seems that one of configure's components (sed, awk,
      or something along those lines) is broken, and configure failed to
      detect that this system needed sys/select.h. The solution is to add
      -DHAVE_SYS_SELECT_H to the Makefile's CFLGS line:

        CFLGS = -DHAVE_DIRENT_H -DHAVE_SYS_DIR_H -DHAVE_SYS_SELECT_H


    5. Unresolved or undefined symbols: ldclose, ldopen, ldnshread (AIX 3)

      cc -s -o eggdrop 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 tandcmd.o tandem.o tcl.o tclhash.o
      userrec.o users.o -L/home2/f/foster/lib -ltcl7.5 -lm
         0706-317 ERROR: Unresolved or undefined symbols detected:
                         Symbols in error (followed by references) are dumped to the load map.
                         The -bloadmap:<filename> option will create a load map.
         .ldclose
         .ldopen
         .ldnshread
         make: 1254-004 The error code from the last command is 8.

      Apparently, what is happening is a library called ld is required. Either
      configure doesn't know it is needed, it simply can't find it, or maybe
      this is a unique case. The solution is to have ld linked in with the final
      binary.

      Edit your Makefile and find the line that looks something like this:

        GMAKE = ${MAKE} 'CC=cc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl7.5.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS= -L/home2/f/foster/lib -ltcl7.5 -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=ranlib' 'STRIP=-s'

      Add in -lld into the XLIBS assignment, like this:

        GMAKE = ${MAKE} 'CC=cc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl7.5.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS=-lld -L/home2/f/foster/lib -ltcl7.5 -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=ranlib' 'STRIP=-s'


    6. Unsatisfied symbols 'shl_findsym' and 'shl_load' (HP-UX 9)

      gcc -s -o eggdrop 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 tandcmd.o tandem.o
      tcl.o tclhash.o userrec.o users.o -L/home/hltran/tcl/lib -ltcl7.5 -lm
         /bin/ld: Unsatisfied symbols:
            shl_findsym (code)
            shl_load (code)
         collect2: ld returned 1 exit status
         *** Error code 1
         Stop.

      Upgrade to a later version of Tcl. The following should also work.

      Edit your Makefile and find the line that looks something like this:

        GMAKE = ${MAKE} 'CC=gcc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl7.5.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS= -L/usr/local/lib -ltcl7.5 -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=:' 'STRIP='

      Add in -ldl into the XLIBS assignment, like this:

        GMAKE = ${MAKE} 'CC=gcc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl7.5.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS=-ldl -L/usr/local/lib -ltcl7.5 -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=:' 'STRIP='


    7. Compile stops at the last minute with "ld fatal signal 11"! (Linux)

      This seems to be caused by a non-ELF Tcl library binary, and the compiler
      doesn't seem to like it. Download and install Tcl in your home directory
      using the steps in 'E. Tcl Detection and Installation' in the Compile
      Guide above.


    8. Undefined references in net.o (SunOS)

                     First
      Undefined    Referenced
       Symbol       In file

      socket          net.o
      gethostbyname   net.o
      accept          net.o
      bind            net.o
      setsockopt      net.o
      gethostbyaddr   net.o
      getsockname     net.o
      gethostname     net.o
      listen          net.o
      connect         net.o
      ld: fatal: Symbol referencing errors. No output written to eggdrop

      This seems to be caused by a few libraries not being detected by the
      auto-configure script; it is relatively easy to fix. Edit your Makefile.
      Note that yours may be slightly different than this one when it comes to
      the Tcl library, but here is the way it probably is:

        GMAKE = ${MAKE} 'CC=gcc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS= -L/usr/local/lib -ltcl -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=:' 'STRIP='

      Here is what you need to change it to:

        GMAKE = ${MAKE} 'CC=gcc' 'AWK=awk' 'OBJS=${OBJS}' 'TCLLIBFN=tcl.a'\
                'CFLAGS=${CFLAGS}' 'XREQ=${XREQ}' 'XLIBS=-lsocket -ldl -lnsl -L/usr/local/lib -ltcl -lm'\
                'TCLLIB=${TCLLIB}' 'RANLIB=:' 'STRIP='

      You are adding three libraries to be linked in: socket, dl, and nsl. This
      will resolve the net.o errors.


    9. I experience problems starting the configure script (AIX/various)

      If you receive file descriptor or bad interpreter errors when attempting
      to run the configure script, try running 'sh configure' or 'bash configure'
      instead of './configure'. This problem seems to show up on many AIX
      machines.


    10. I get a 'make: Permission denied' error when I type 'make config' or
        'make' (FreeBSD / *BSD)

      This is caused by a bug in FreeBSD (and possibly other BSDs as well).
      A simple 'cd .', or changing to a different directory and then changing
      back, usually fixes this.
    _____________________________________________________________________

   Copyright (C) 1997 Robey Pointer
   Copyright (C) 1999 - 2011 Eggheads Development Team
