Appendix E. Using C in a Wigwam Project

Projects often consist of custom servers or tools which must be very fast or more lowlevel than perl or sh. In that case, you may try C or java. This section is about using C (or C++) within a Wigwam project.

Another possibility, by the way, is developing your program to be a Wigwam package. That will make it easier to reuse the code in another project. But sometimes the C code is worthless without the supporting project. In that case, embedding the code directly in $PLAYPEN_ROOT/src can be helpful.

Here is how we advise proceeding:

  1. Learn about automake and autoconf; these are the easiest way to build binaries from your source code.

  2. Copy a autogen.sh in src/:
            if test "x$PLAYPEN_ROOT" = "x"; then
              echo "You are NOT in a wigwam playpen." 1>&2
            else
              CPPFLAGS="-I$PLAYPEN_ROOT/include -I$PLAYPEN_ROOT/ext/include"
              LIBS="-L$PLAYPEN_ROOT/lib -L$PLAYPEN_ROOT/ext/lib"
              export CPPFLAGS
              export LIBS
              echo "You are in a wigwam playpen." 1>&2
            fi
    
            autoheader
            automake -a --foreign
            aclocal
            autoconf
            configure "$@"

  3. Write some C code.

  4. Write a configure.in and Makefile.am, as explained by the autoconf/automake documentation.

  5. Run
                   ./autogen.sh
                   make
    make it compile, then debug it.