autoconfiscate

Add autoconf, libtool, automake and bootstrap tools. While this will be
used for the typical "build a shared-library" use-case, we still want to
support other build types that may use the libmctp code directly, and
not use autoconf.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 1084eec..0000000
--- a/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-
-CC = gcc
-AR = ar
-CFLAGS = -Wall -Wextra -Werror -ggdb
-CPPFLAGS = -DMCTP_LOG_STDERR -DMCTP_FILEIO -I$(LIBMCTP_DIR)
-
-LIBMCTP_DIR=./
-
-include Makefile.inc
-
-all: $(LIBMCTP)
-
-libmctp.a:
-	$(AR) rcsTPD $@ $^
-
-utils/%: utils/%.o libmctp.a
-	$(LINK.o) -o $@ $^
-
-test_util_objs = tests/test-utils.o
-
-tests = test_eid test_seq
-
-test_targets = $(tests:%=tests/%)
-
-$(test_targets): $(test_util_objs) libmctp.a
-
-$(test_targets): %: %.o
-	$(LINK.o) -o $@ $^
-
-check: $(test_targets)
-	for t in $(test_targets); do echo $$t; $$t || exit 1; done
-
-.PHONY: check
-
-clean:
-	rm -f $(LIBMCTP)
-	rm -f $(LIBMCTP_OBJS)
-	rm -f tests/*.o
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..1f3cd2a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,30 @@
+ACLOCAL_AMFLAGS = -I m4
+
+# standalone compilation uses stdio
+libmctp_la_CPPFLAGS = -DMCTP_LOG_STDERR -DMCTP_FILEIO
+
+lib_LTLIBRARIES = libmctp.la
+libmctp_la_SOURCES = core.c alloc.c \
+		     libmctp.h libmctp-alloc.h
+
+if LIBMCTP_BINDING_serial
+libmctp_la_SOURCES += serial.c libmctp-serial.h
+endif
+
+if LIBMCTP_BINDING_astlpc
+libmctp_la_SOURCES += astlpc.c libmctp-astlpc.h
+endif
+
+bin_PROGRAMS = utils/mctp-demux-daemon
+utils_mctp_demux_daemon_LDADD = libmctp.la
+
+TESTS = $(check_PROGRAMS)
+
+check_PROGRAMS = tests/test_eid tests/test_seq
+# We set a global LDADD here, as there's no way to specify it for all
+# tests. This means other targets' LDADDs need to be overridden.
+LDADD = tests/libtest-utils.a libmctp.la
+
+noinst_LIBRARIES = tests/libtest-utils.a
+
+tests_libtest_utils_a_SOURCES = tests/test-utils.c tests/test-utils.h
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..c508090
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec autoreconf -f -i
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..334b0a5
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,22 @@
+# Initialization
+AC_PREREQ([2.69])
+AC_INIT([libmctp], 0.9, [https://github.com/openbmc/libmctp/issues])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIRS([m4])
+AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+
+# libtool init
+LT_INIT
+
+AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
+AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT