I figured it out. All I had to do was look up conditionals in the automake manual. I edited my file to look like this.
configure.ac
Code:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT([libfileinfo], [0.1])
AC_CONFIG_SRCDIR([libfileinfo/fileinfo.h]) #Can I combine these into one line?
AC_CONFIG_SRCDIR([libfileinfo/fileinfo.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_DIRENT
AC_CHECK_HEADERS([unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_STAT
AC_CHECK_FUNCS([getcwd])
AC_PROG_LIBTOOL
AC_CONFIG_FILES([
Makefile
libfileinfo/Makefile
test/Makefile
])
AC_ARG_WITH([libfileinfo],
AC_HELP_STRING([--with-libfileinfo], [compile library]),
[case "${withval}" in
yes) makelib=true ;;
no) makelib=false ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-libfileinfo]) ;;
esac], [makelib=true])
AM_CONDITIONAL([MAKELIB], [test x$makelib = xtrue])
AC_ARG_WITH([test],
AC_HELP_STRING([--with-test], [compile test program]),
[case "${withval}" in
yes) maketest=true ;;
no) maketest=false ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-test]) ;;
esac], [maketest=false])
AM_CONDITIONAL([MAKETEST], [test x$maketest = xtrue])
AC_OUTPUT
Makefile.am
Code:
# not a GNU package. You can remove this line, if
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign 1.4
if MAKELIB
LIB = libfileinfo
else
LIB =
endif
if MAKETEST
SAMPLE = test
else
SAMPLE =
endif
SUBDIRS = $(LIB) $(SAMPLE)
Now, I can move forward with the more important things in life. Can someone please tell me what the x is for in test x$maketest = xtrue?