Index: .gitignore
===================================================================
--- .gitignore	(revision d5ef539f348e22f4dfe00fa09ae91cccbc0147e8)
+++ .gitignore	(revision 37f27bc0e54077fc0d554781c838adc50188236d)
@@ -4,6 +4,9 @@
 *~
 .#*
+.deps
 META.yml
 Makefile
+/Makefile.in
+/libfaim/Makefile.in
 Makefile.old
 TAGS
@@ -20,5 +23,8 @@
 configure
 core
+depcomp
+install-sh
 jabber.log
+missing
 owl_prototypes.h
 owl_prototypes.h.new
@@ -26,4 +32,5 @@
 perlwrap.c
 pm_to_blib
+stamp-h1
 tester
 varstubs.c
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 0b65bd726abafc33618b49204ae612d26c6582a0)
+++ Makefile.am	(revision 0b65bd726abafc33618b49204ae612d26c6582a0)
@@ -0,0 +1,69 @@
+bin_PROGRAMS = barnowl.bin
+check_PROGRAMS = tester
+
+barnowl_bin_SOURCES = $(BASE_SRCS) \
+     owl.h owl_perl.h config.h \
+     owl.c \
+     libzcrypt.a \
+     $(GEN_C) $(GEN_H)
+
+barnowl_bin_LDADD = libfaim/libfaim.a libzcrypt.a
+
+tester_SOURCES = $(BASE_SRCS) \
+     owl.h owl_perl.h config.h test.h \
+     libzcrypt.a \
+     $(GEN_C) $(GEN_H) \
+     tester.c
+
+noinst_LIBRARIES = libzcrypt.a
+
+libzcrypt_a_SOURCES = zcrypt.c
+libzcrypt_a_CFLAGS  = -w
+
+CPPFLAGS = -I$(top_srcdir)/ \
+           -I$(top_srcdir)/libfaim/
+
+BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
+     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
+     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
+     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
+     keypress.c keymap.c keybinding.c cmd.c context.c \
+     aim.c buddy.c buddylist.c style.c errqueue.c \
+     zbuddylist.c popexec.c obarray.c select.c wcwidth.c \
+     glib_compat.c
+
+GEN_C = varstubs.c perlglue.c
+GEN_H = owl_prototypes.h
+
+BUILT_SOURCES = $(GEN_C) $(GEN_H)
+
+proto: owl_prototypes.h
+
+perlglue.c: perlglue.xs
+	perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
+
+varstubs.c: variable.c stubgen.pl
+	perl stubgen.pl > varstubs.c
+
+# Only move owl_prototypes.h into place if the new one is different
+owl_prototypes.h: codelist.pl varstubs.c $(BASE_SRCS)
+	perl codelist.pl > owl_prototypes.h.new
+	@diff -U0 $@ owl_prototypes.h.new || { \
+	 test -f $@ && echo 'Interfaces changed!'; \
+	 echo mv -f owl_prototypes.h.new $@; \
+	      mv -f owl_prototypes.h.new $@; }
+
+# For emacs flymake-mode
+check-syntax: proto
+	$(CC) $(CFLAGS) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
+
+install-data-local:
+	$(mkinstalldirs) ${DESTDIR}${pkgdatadir}/lib
+	(cd perl/lib && tar -cf - . ) | (cd ${DESTDIR}${pkgdatadir}/lib && tar -xf - )
+
+do_transform = $(shell echo '$(1)' | sed '$(transform)')
+install-exec-hook:
+	mv -f $(DESTDIR)$(bindir)/$(call do_transform,barnowl.bin) \
+	      $(DESTDIR)$(bindir)/$(call do_transform,barnowl)
+
+SUBDIRS = libfaim/ perl/modules/
Index: kefile.in
===================================================================
--- Makefile.in	(revision ac40fdf0f0c8d27409111b26970341085b39848c)
+++ 	(revision )
@@ -1,147 +1,0 @@
-# $Id$
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-datarootdir = @datarootdir@
-datadir = @datadir@/barnowl
-bindir = @bindir@
-mandir = @mandir@
-transform = @program_transform_name@
-
-CC=@CC@
-LIBS=@LIBS@ -L./libfaim -lfaim
-CFLAGS=@CFLAGS@ -I./libfaim -DDATADIR=\"${datadir}\"
-LDFLAGS=@LDFLAGS@
-XSUBPPDIR=@XSUBPPDIR@
-XSUBPPFLAGS=@XSUBPPFLAGS@
-INSTALL=@INSTALL@
-INSTALL_PROGRAM=@INSTALL_PROGRAM@
-INSTALL_DATA=@INSTALL_DATA@
-ATHSTATIC=@ATHSTATIC@
-
-BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
-     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
-     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
-     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
-     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
-     aim.c buddy.c buddylist.c style.c errqueue.c \
-     zbuddylist.c popexec.c obarray.c select.c wcwidth.c \
-     glib_compat.c
-OWL_SRC = owl.c
-TESTER_SRC = tester.c
-
-EXE = barnowl.bin
-PERL_MODULES = Jabber IRC WordWrap
-MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%)
-
-BASE_OBJS = $(BASE_SRCS:.c=.o)
-
-GEN_C = varstubs.c perlglue.c
-GEN_H = owl_prototypes.h 
-GEN_O = $(GEN_C:.c=.o)
-
-OBJS = $(BASE_OBJS) $(GEN_O)
-
-AUTOGEN=$(GEN_C) $(GEN_H)
-#AUTOGEN=$(GEN_C)
-
-HEADERS=$(GEN_H) owl.h owl_perl.h config.h test.h
-
-all: $(EXE) $(MODULE_DIRS)
-
-$(EXE): $(AUTOGEN) $(OBJS) owl.o libfaim
-	$(ATHSTATIC) $(CC) -o $(EXE) owl.o $(OBJS) $(LDFLAGS) $(LIBS)
-
-tester: $(AUTOGEN) $(OBJS) tester.o libfaim
-	$(ATHSTATIC) $(CC) -o tester tester.o $(OBJS) $(LDFLAGS) $(LIBS)
-
-%.o: %.c $(HEADERS)
-	$(CC) -c $(CFLAGS) $< -o $@
-
-# zcrypt is old crufty DES code I don't want to touch
-# Disable all warnings when compiling it
-zcrypt.o: zcrypt.c $(HEADERS)
-	$(CC) -c $(CFLAGS) $< -w -o $@
-
-test: tester
-	./tester reg
-
-clean: libfaimclean modules_clean
-	$(RM) $(EXE) tester *.o $(AUTOGEN) owl_prototypes.h.new
-
-distclean: clean libfaimdistclean
-	$(RM) config.cache config.log config.status  Makefile config.h TAGS *~ core
-
-.PHONY: $(MODULE_DIRS) $(MODULE_DIRS:%=clean_%)
-
-modules: $(MODULE_DIRS)
-modules_clean: $(MODULE_DIRS:%=clean_%)
-
-$(MODULE_DIRS): %: %/Makefile
-	( cd $@ && $(MAKE) $(notdir $@).par )
-
-$(MODULE_DIRS:=/Makefile): %/Makefile: %/Makefile.PL
-	( cd $(dir $@) && perl -I../../lib Makefile.PL )
-
-$(MODULE_DIRS:%=clean_%): clean_%:
-	(cd $* && (test ! -f Makefile || $(MAKE) clean))
-
-proto: owl_prototypes.h
-
-perlglue.c: perlglue.xs Makefile 
-	perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
-
-varstubs.c: variable.c stubgen.pl
-	perl stubgen.pl > varstubs.c
-
-# Only move owl_prototypes.h into place if the new one is different
-owl_prototypes.h: codelist.pl varstubs.c $(BASE_SRCS)
-	perl codelist.pl > owl_prototypes.h.new
-	@diff -U0 $@ owl_prototypes.h.new || { \
-	 test -f $@ && echo 'Interfaces changed!'; \
-	 echo mv -f owl_prototypes.h.new $@; \
-	      mv -f owl_prototypes.h.new $@; }
-#owl_prototypes.h:
-
-.PHONY: tags clean distclean proto test check-syntax
-
-tags: TAGS
-
-TAGS: $(BASE_SRCS) $(OWL_SRC) $(TESTER_SRC) $(GEN_C) owl.h $(GEN_H)
-	etags $(BASE_SRCS) $(OWL_SRC) $(TESTER_SRC) $(GEN_C) owl.h $(GEN_H)
-
-$(BASE_OBJS) varstubs.h: owl.h config.h owl_prototypes.h
-
-libfaim: libfaim/libfaim.a
-
-libfaim/libfaim.a:
-	(cd libfaim && $(MAKE))
-
-libfaimclean:
-	(cd libfaim && $(MAKE) clean)
-
-libfaimdistclean:
-	(cd libfaim && $(MAKE) distclean)
-
-install: all installdirs $(PERL_MODULES:%=module_install_%)
-	${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/`echo barnowl|sed '$(transform)'`
-	${INSTALL_DATA} doc/barnowl.1 ${DESTDIR}${mandir}/man1/barnowl.1
-	(cd perl/lib && tar --exclude .svn -cf - . ) | (cd ${DESTDIR}${datadir}/lib && tar -xf - )
-
-installdirs: mkinstalldirs
-	${srcdir}/mkinstalldirs \
-	    ${DESTDIR}${bindir} \
-	    ${DESTDIR}${mandir}/man1 \
-	    ${DESTDIR}${datadir}/lib \
-	    ${DESTDIR}${datadir}/modules
-
-.PHONY: $(PERL_MODULES:%=module_install_%)
-
-$(PERL_MODULES:%=module_install_%): module_install_%: installdirs
-	${INSTALL_DATA} perl/modules/$*/$*.par ${DESTDIR}${datadir}/modules/$*.par
-
-# For emacs flymake-mode
-check-syntax: proto
-	$(CC) $(CFLAGS) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
Index: hstatic
===================================================================
--- athstatic	(revision 855dc8d060c78460217b895ed0ae73eee2c9c4dc)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#!/bin/sh
-# $Id$
-
-# Usage: athstatic progname options ...
-
-# Replaces -lfoo options with /usr/athena/lib/libfoo.a if it exists,
-# thus preferring static libraries to shared libraries for stuff in
-# /usr/athena/lib.
-
-progname=$1
-shift
-
-options=
-for arg do
-  case $arg in
-  -l*)
-    # Chop off the first two characters to get the library name.
-    lib=`expr "$arg" : '..\(.*\)$'`
-    if [ -f /usr/athena/lib/lib${lib}.a -a "$lib" != "perl" ]; then
-      options="$options /usr/athena/lib/lib${lib}.a"
-    else
-      options="$options $arg"
-    fi
-    ;;
-  *)
-    options="$options $arg"
-    ;;
-  esac
-done
-
-echo "$progname" $options
-exec "$progname" $options
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 130479bf970e1c63ccde4665e518d6bdd201a358)
+++ autogen.sh	(revision 37f27bc0e54077fc0d554781c838adc50188236d)
@@ -1,2 +1,3 @@
 #!/bin/sh
-autoreconf
+autoreconf -fvi
+
Index: configure.ac
===================================================================
--- configure.ac	(revision 40977238e21a877568df2968181b55aaee67f53a)
+++ configure.ac	(revision c08a72568ffb178aa943639541c5ce61a7fd77d6)
@@ -1,14 +1,10 @@
 dnl $Id$
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(owl.c)
+AC_INIT([BarnOwl],[1.3],[bug-barnowl@mit.edu])
+AM_INIT_AUTOMAKE([-Wall foreign])
 
-AC_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADER([config.h])
 
 AC_PROG_CC
-
-dnl If we're using GCC, enable all warnings
-if test "$GCC" = yes; then
-     CFLAGS="$CFLAGS -Wall -g";
-fi
 
 dnl Check for Athena
@@ -97,9 +93,4 @@
    ])])
 
-AC_ARG_ENABLE([athstatic], AS_HELP_STRING([--enable-athstatic],
-                                          [Statically link libraries in /usr/athena/lib]),
-                                          [ATHSTATIC=./athstatic],
-                                          [ATHSTATIC=])
-
 AC_CHECK_FUNCS(use_default_colors resizeterm des_string_to_key des_key_sched des_ecb_encrypt)
 AC_CHECK_FUNCS(				   DES_string_to_key  DES_ecb_encrypt DES_key_sched)
@@ -143,6 +134,6 @@
 dnl Add LDFLAGS for embedded perl
 FOO=`perl -MExtUtils::Embed -e ldopts`
-AC_MSG_NOTICE([Adding perl LDFLAGS ${FOO}])
-LDFLAGS=${LDFLAGS}\ ${FOO}
+AC_MSG_NOTICE([Adding perl LIBS ${FOO}])
+LIBS=${LIBS}\ ${FOO}
 
 dnl Add CFLAGS and LDFLAGS for glib-2.0
@@ -154,16 +145,19 @@
 LDFLAGS="${GLIB_LIBS} ${LDFLAGS}"
 
+if test "x${prefix}" = "xNONE"; then
+   prefix="${ac_default_prefix}"
+fi
+
+AC_DEFINE_UNQUOTED([DATADIR],["${prefix}/share/${PACKAGE}"],
+                   [Package data directory])
+
 dnl Checks for typedefs, structures, and compiler characteristics.
-
-dnl Support --program-{prefix,suffix,transform}
-AC_ARG_PROGRAM
 
 AC_SUBST(XSUBPPDIR)
 AC_SUBST(XSUBPPFLAGS)
-AC_SUBST(ATHSTATIC)
 
 AC_PROG_INSTALL
+AC_PROG_RANLIB
 
-AC_CONFIG_SUBDIRS(libfaim)
-
-AC_OUTPUT(Makefile)
+AC_CONFIG_FILES([Makefile libfaim/Makefile])
+AC_OUTPUT([perl/modules/Makefile])
Index: libfaim/Makefile.am
===================================================================
--- libfaim/Makefile.am	(revision ed6248222e25dffa6b616cbeb08cf3b6aaa19f9b)
+++ libfaim/Makefile.am	(revision ed6248222e25dffa6b616cbeb08cf3b6aaa19f9b)
@@ -0,0 +1,13 @@
+noinst_LIBRARIES = libfaim.a
+
+libfaim_a_SOURCES = admin.c \
+     adverts.c auth.c bos.c buddylist.c bstream.c \
+     chat.c chatnav.c conn.c email.c ft.c icq.c im.c \
+     invite.c md5.c misc.c msgcookie.c locate.c \
+     popups.c rxhandlers.c rxqueue.c search.c service.c \
+     snac.c ssi.c stats.c tlv.c translate.c txqueue.c \
+     util.c odir.c bart.c \
+     aim_cbtypes.h  aim.h  aim_internal.h  faimconfig.h md5.h
+
+libfaim_a_CPPFLAGS = -DAIM_BUILDDATE=\"x\" -DAIM_BUILDTIME=\"x\" \
+                     -I${top_srcdir}/libfaim
Index: bfaim/Makefile.in
===================================================================
--- libfaim/Makefile.in	(revision 89acc93b4eb479d4a1aa11a9f63edfc27cf6bf64)
+++ 	(revision )
@@ -1,21 +1,0 @@
-CC=@CC@
-LIBS=@LIBS@
-LDFLAGS=@LDFLAGS@
-RANLIB=@RANLIB@
-OBJS=admin.o adverts.o auth.o bos.o buddylist.o bstream.o \
-     chat.o chatnav.o conn.o email.o ft.o icq.o im.o \
-     invite.o md5.o misc.o msgcookie.o locate.o \
-     popups.o rxhandlers.o rxqueue.o search.o service.o \
-     snac.o ssi.o stats.o tlv.o translate.o txqueue.o \
-     util.o odir.o bart.o
-CFLAGS=@CFLAGS@ -I. -DAIM_BUILDDATE=\"x\" -DAIM_BUILDTIME=\"x\"
-
-libfaim: $(OBJS)
-	$(AR) -r libfaim.a $(OBJS)
-	$(RANLIB) libfaim.a
-
-clean:
-	$(RM) *.o libfaim.a
-
-distclean: clean
-	$(RM) config.cache config.log config.status Makefile config.h TAGS *~ core
Index: bfaim/configure.ac
===================================================================
--- libfaim/configure.ac	(revision 6cc1ff714e9c149b34f50c8c03d9f60eab64cb24)
+++ 	(revision )
@@ -1,13 +1,0 @@
-AC_INIT(bos.c)
-
-dnl AC_CONFIG_HEADER(config.h)
-
-AC_PROG_CC
-dnl we're using GCC, enable all warnings
-if test "$GCC" = yes; then
-   CFLAGS="$CFLAGS -Wall -g";
-fi
-AC_PROG_RANLIB
-
-
-AC_OUTPUT(Makefile)
Index: installdirs
===================================================================
--- mkinstalldirs	(revision 5471a9885a9bc1a848baf5fcc075a0eeea1d83eb)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-# $Id$
-
-errstatus=0
-
-for file
-do
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
-
-   pathcomp=
-   for d
-   do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-        echo "mkdir $pathcomp"
-
-        mkdir "$pathcomp" || lasterr=$?
-
-        if test ! -d "$pathcomp"; then
-  	  errstatus=$lasterr
-        fi
-     fi
-
-     pathcomp="$pathcomp/"
-   done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
Index: owl.h
===================================================================
--- owl.h	(revision a88f35a64d4d61e59e6dca10a9077b2cc9db4c84)
+++ owl.h	(revision 37f27bc0e54077fc0d554781c838adc50188236d)
@@ -48,10 +48,5 @@
 static const char owl_h_fileIdent[] = "$Id$";
 
-#define BARNOWL_STRINGIFY(x) _STRINGIFY(x)
-#define _STRINGIFY(x) #x
-
-#ifndef OWL_VERSION_STRING
-#define OWL_VERSION_STRING "1.3"
-#endif
+#define OWL_VERSION_STRING PACKAGE_VERSION
 
 /* Feature that is being tested to redirect stderr through a pipe. 
Index: perl/modules/Makefile.in
===================================================================
--- perl/modules/Makefile.in	(revision 37f27bc0e54077fc0d554781c838adc50188236d)
+++ perl/modules/Makefile.in	(revision 37f27bc0e54077fc0d554781c838adc50188236d)
@@ -0,0 +1,39 @@
+top_srcdir=@top_srcdir@
+srcdir=@srcdir@
+prefix=@prefix@
+datadir=@datadir@/barnowl
+datarootdir=@datarootdir@
+
+INSTALL=@INSTALL@
+INSTALL_PROGRAM=@INSTALL_PROGRAM@
+INSTALL_DATA=@INSTALL_DATA@
+install_sh = @install_sh@
+mkinstalldirs = $(install_sh) -d
+
+PERL_MODULES = Jabber IRC WordWrap
+MODULE_DIRS = $(PERL_MODULES)
+
+all: modules
+clean: modules_clean
+
+modules: $(MODULE_DIRS)
+modules_clean: $(MODULE_DIRS:%=clean_%)
+
+$(MODULE_DIRS): %: %/Makefile
+	( cd $@ && $(MAKE) $(notdir $@).par )
+
+$(MODULE_DIRS:=/Makefile): %/Makefile: %/Makefile.PL
+	( cd $(dir $@) && perl -I../../lib Makefile.PL )
+
+$(MODULE_DIRS:%=clean_%): clean_%:
+	(cd $* && (test ! -f Makefile || $(MAKE) clean))
+
+install: installdirs $(PERL_MODULES:%=module_install_%)
+
+installdirs:
+	$(mkinstalldirs) ${DESTDIR}${datadir}/modules/
+
+$(PERL_MODULES:%=module_install_%): module_install_%:
+	${INSTALL_DATA} $*/$*.par ${DESTDIR}${datadir}/modules/$*.par
+
+.PHONY: clean modules $(PERL_MODULES:%=module_install_%)
Index: scripts/do-release
===================================================================
--- scripts/do-release	(revision 11b901764e20a10cdc06a3fa4713c65960e772ae)
+++ scripts/do-release	(revision db98968bc3b30ba528ad63029aaba1addb187104)
@@ -6,5 +6,5 @@
 }
 
-VERS=$(perl -lne 'print $1 if m{^#define\s+OWL_VERSION_STRING\s+"([^"]+)"\s*$}' owl.h) \
+VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac) \
     || die "Unable to parse barnowl version"
 TAG=barnowl-$VERS
@@ -29,5 +29,5 @@
 CODIR=$(pwd)
 cd "$TMPDIR/$TGZ"
-autoreconf
+autoreconf -fvi
 cd "$TMPDIR"
 tar czvf "$TGZ.tgz" "$TGZ"
Index: scripts/locker-build
===================================================================
--- scripts/locker-build	(revision e477a53d3120b25a1de5eea73598e8bc5d679a89)
+++ scripts/locker-build	(revision db98968bc3b30ba528ad63029aaba1addb187104)
@@ -75,5 +75,5 @@
 (
     cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
-    VERS=$(perl -ne 'print $1 if m{^#define\s*OWL_VERSION_STRING\s*"([^"]+)"}' owl.h)
+    VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac)
     test -z "$VERS" && die "Unable to detect barnowl version."
 
