views:

36

answers:

2

I'm trying to set up autoconf for my project. I have everything working "properly" except that the ac_set_<...> functions are not being found in ./configure. They work fine in configure.status if I run it directly.

Specifically, I am having trouble with as_fn_set_status and as_fn_exit.

If I manually edit the config file and move the two functions to the top of the configure script, everything works fine.

To get to this point I:

  1. Wrote configure.ac
  2. ran autoreconf -i
  3. ran ./configure

The resulting lines are something like:

./configure: line 1366: as_fn_set_status: command not found

There are 3-4 lines on which the error occurs.

Any ideas on what might be producing this effect? Here is my configure.ac:

##########################################
#  Autoconf Configuration File for RPDB  #
##########################################

#   RPDB: An Object-Oriented Wrapper for Oracle's Berkeley Database (BDB/libdb),
#   which is available at: http://www.oracle.com/technology/software/products/berkeley-db/index.html

###########################
#  Init Autoconf >= 2.61  #
###########################

AC_CANONICAL_SYSTEM

AC_PREREQ(2.61)
AC_INIT([rpdb], [0.1.0], [[email protected]])

AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE

#################################
#  Check for Library Functions  #
#################################

AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_CHECK_FUNCS([strdup])

################################
#  Check for Working Compiler  #
################################

AC_PROG_CC
AC_PROG_RANLIB

#########################
#  Check for Libraries  #
#########################

AC_SEARCH_LIBS([db_create], [db], [have_libdb=yes])

#######################
#  "Root Sourcefile"  #
#######################

# "Root Sourcefile" is only used nominally to specify base path

AC_CONFIG_SRCDIR([src/RPDB_Base/RPDB.h])

#######################
#  Check for Headers  #
#######################

AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h])

# If we found libdb then check for db.h - we need to have both or we throw an error
if test "x${have_libdb}" = xyes; then
  AC_CHECK_HEADERS([db.h], [], [have_libdb=no])
fi
if test "x${have_libdb}" = xno; then
  echo "------------------------------------------"
  echo " Oracle's Berkeley Database (libdb)       "
  echo " library and header file is required to   "
  echo " build RPDB. Stopping...                  "
  echo " Check 'config.log' for more information. "
  echo "------------------------------------------"
  (exit 1); exit 1;
fi

#####################################################
#  Check For Type-Related Compiler Characteristics  #
#####################################################

AC_C_CONST
AC_HEADER_STDBOOL
AC_TYPE_INT32_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T

###############################
#  Generate Configure Script  #
###############################

AC_OUTPUT
A: 

Do you perhaps have different autoconf's installed. I think that function originates from the m4 macro: m4sugar/m4sh.m4. You could check that file to see if it has the function.

It should look something like:

[AS_REQUIRE_SHELL_FN([as_fn_set_status],
  [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
    [Set $? to STATUS, without forking.])], [  return $[]1])]dnl
DiggyF
I don't and the function is actually there - and shows up in the final output for configure. If I manually edit configure, it works.
Asher
The comments in `m4sh.m4` mention "We cannot simply use "exit N" because some shells....". Might it be that it has something to do with the line: `(exit 1); exit 1;`?
DiggyF
+1  A: 

You cannot invoke any macros that have a non-empty expansion prior to AC_INIT. If you move the invocation of AC_CANONICAL_SYSTEM to be after AC_INIT, your problem should go away.

William Pursell
I moved to CMake, so I can't easily verify this, but it makes sense, so I'm going to accept it. It lines up with the fact that I could move the macros (presumably created by AC_INIT?) upward and they would work.
Asher