build: add autotools configuration
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 10:23:20 +0000 (11:23 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 10:29:13 +0000 (11:29 +0100)
This allows to build the library and programs using autotools.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]

diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..9408f4f
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# Copyright (C) 2017 Bartosz Golaszewski <bartekgola@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I m4
+LIBS =
+
+AM_CPPFLAGS = -I$(top_srcdir) -include $(top_srcdir)/config.h -Wextra
+AM_CPPFLAGS += -fvisibility=hidden
+
+lib_LTLIBRARIES = libgpiod.la
+
+libgpiod_la_SOURCES = core.c
+
+bin_PROGRAMS = gpiodetect gpioinfo gpioget gpioset
+
+gpiodetect_SOURCES = gpiodetect.c
+gpiodetect_LDFLAGS = -lgpiod
+
+gpioinfo_SOURCES = gpioinfo.c
+gpioinfo_LDFLAGS = -lgpiod
+
+gpioget_SOURCES = gpioget.c
+gpioget_LDFLAGS = -lgpiod
+
+gpioset_SOURCES = gpioset.c
+gpioset_LDFLAGS = -lgpiod
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..7f824e9
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+autoreconf --force --install --verbose
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..85424cb
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2017 Bartosz Golaszewski <bartekgola@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+
+AC_PREREQ(2.61)
+AC_INIT([libgpiod], 0.0)
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR([autostuff])
+AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects])
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+AC_CONFIG_HEADER([config.h])
+
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_PROG_INSTALL
+
+AC_HEADER_STDC
+
+AC_CHECK_FUNC([ioctl], [], [AC_MSG_ERROR([ioctl() unavailable])])
+AC_CHECK_FUNC([asprintf], [], [AC_MSG_ERROR([asprintf() unavailable])])
+AC_CHECK_FUNC([readdir], [], [AC_MSG_ERROR([readdir() unavailable])])
+
+AC_FUNC_MALLOC
+
+AC_CHECK_HEADERS([getopt.h], [], [AC_MSG_ERROR([getopt.h header not found])])
+AC_CHECK_HEADERS([stdint.h], [], [AC_MSG_ERROR([stdint.h header not found])])
+AC_CHECK_HEADERS([dirent.h], [], [AC_MSG_ERROR([dirent.h header not found])])
+AC_CHECK_HEADERS([linux/gpio.h], [],
+               [AC_MSG_ERROR([linux/gpio.h header not found])])
+
+AC_HEADER_STDC
+
+AC_CONFIG_FILES([Makefile])
+
+CFLAGS="$CFLAGS -Wall"
+
+AC_OUTPUT