-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
AC_PREREQ([2.68])
-AC_INIT([reapply_default_acl], [0.0.2], [michael@orlitzky.com])
-AM_INIT_AUTOMAKE
-AC_CONFIG_SRCDIR([src/reapply_default_acl.c])
+AC_INIT([apply-default-acl], [0.3.0], [michael@orlitzky.com])
+AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-xz])
AC_CONFIG_FILES([Makefile src/Makefile])
+AC_CONFIG_SRCDIR([src/apply-default-acl.c])
+AC_CONFIG_MACRO_DIRS([m4])
# Checks for programs.
AC_PROG_CC
+AM_PROG_AR
-# Checks for header files.
-AC_CHECK_HEADERS([limits.h stdlib.h string.h sys/acl.h unistd.h])
+# Predefined header checks.
+AC_HEADER_DIRENT # dirent.h
+AC_HEADER_STAT # sys/stat.h
+AC_HEADER_STDBOOL # stdbool.h
+AC_HEADER_STDC # stdlib.h string.h (implied: errno.h limits.h stdio.h)
-# Checks for typedefs, structures, and compiler characteristics.
-AC_HEADER_STDBOOL
-AC_TYPE_MODE_T
+# Check for header files not covered by the predefined macros above.
+AC_HEADER_REQUIRE(acl/libacl.h)
+AC_HEADER_REQUIRE(fcntl.h)
+AC_HEADER_REQUIRE(getopt.h)
+AC_HEADER_REQUIRE(libgen.h)
+AC_HEADER_REQUIRE(limits.h)
+AC_HEADER_REQUIRE(linux/xattr.h)
+AC_HEADER_REQUIRE(sys/acl.h)
+AC_HEADER_REQUIRE(unistd.h)
+# We need openat() with O_NOFOLLOW from POSIX-2008. Without them, we
+# can't operate securely; I would rather refuse to be built.
+AC_CHECK_FUNC(openat,
+ [],
+ AC_MSG_ERROR(missing required openat function))
+AC_CHECK_DECLS([O_DIRECTORY],
+ [],
+ [AC_MSG_ERROR(missing required O_DIRECTORY flag in fcntl.h)],
+ [[#include <fcntl.h>]])
+AC_CHECK_DECLS([O_NOFOLLOW],
+ [],
+ [AC_MSG_ERROR(missing required O_NOFOLLOW flag in fcntl.h)],
+ [[#include <fcntl.h>]])
+AC_CHECK_DECLS([O_PATH],
+ [],
+ [AC_MSG_ERROR(missing required O_PATH flag in fcntl.h)],
+ [[#define _GNU_SOURCE
+ #include <fcntl.h>]])
+LT_INIT
AC_OUTPUT