Re: Need help with autoconf configure script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 13, 2005 at 11:02:48AM +0200, Andreas Schwab wrote:
> Bob Rossi <bob@xxxxxxxxxx> writes:
> 
> > On Wed, Jul 13, 2005 at 12:04:27AM +0200, Andreas Schwab wrote:
> >> Bob Rossi <bob@xxxxxxxxxx> writes:
> >> 
> >> > If I run ./configure then by default opt_with_readline_prefix is "no".
> >> > During ../cgdb/configure I get,
> >> >    checking pty.h usability... yes
> >> >    checking pty.h presence... no
> >> >    configure: WARNING: pty.h: accepted by the compiler, rejected by the preprocessor!
> >> >    configure: WARNING: pty.h: proceeding with the compiler's result
> >> >    checking for pty.h... yes
> >> > so I get error's when VL_LIB_READLINE is *not* run.
> >> 
> >> Please check config.log for the actual preprocessor error you get.
> >> Without that it is impossible to guess what's going on.
> >
> > Thanks for the response Andreas. The attached is the diff between when
> > the config.log that works and doesn't work.
> 
> That's the old AC_REQUIRE problem.  VL_LIB_READLINE is probably the first
> macro requiring the AC_PROG_CPP framework, but since all of this is
> skipped when $vl_cv_lib_readline is no, the expansion from that macro is
> never executed, and many of the internal autoconf variables remain unset.
> Workaround: Put AC_PROG_CPP somewhere before this block.
> 
Hi Andreas,

It really sounds like you have something here! At least, the reasoning
could explain why things don't work, just because the macro is in the
configure.in, but it's not ever executed.

VL_LIB_READLINE does not depend on AC_PROG_CPP, in fact, CGDB is entirly
written in C. However, you suggestion made me think, and I did find out
yesterday that AC_CHECK_HEADERS was the macro that was causing
VL_LIB_READLINE to cause the problem. 

Because of your suggestion, I moved everything  (3 lines)
   dnl Checking for log10 function in math - I would like to remove this
   AC_CHECK_LIB(m, log10)

   dnl Checks for header files.
   AC_HEADER_STDC
   AC_HEADER_SYS_WAIT
in my configure.in that was after the 'if ... VL_LIB_READLINE', and
before all of my checks to AC_CHECK_HEADERS, above the VL_LIB_READLINE
macro. Now things seem to work!

Is this a bug in autoconf? I would really like to get to the root of
this problem, so that others do not have to deal with it, ever. It took
me a very long time to even get close to solving the problem, and it
wouldn't of happened without you guys!

Please see the attached files.
  attachment 1, the good configure.in
  attachment 2, the diff between the good and bad configure.in.
    This shows that moving those 3 lines is causing the problem.
  attachment 3, the readline.m4 macro

Thanks,
Bob Rossi
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.5)
AC_INIT(cgdb)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(cgdb, 0.5.2-cvs)
AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

AC_PROG_RANLIB
AM_PROG_LEX
AC_PROG_YACC

dnl determine if we are running in linux, cygwin, solaris, or freebsd
AC_CANONICAL_HOST

case $host in
 *-*-linux*)
   SYSTEM=LINUX
   AC_DEFINE(HAVE_LINUX, 1,  Linux environment)
   ;;
 *-*-cygwin*)
   SYSTEM=CYGWIN
   AC_DEFINE(HAVE_CYGWIN, 1,  Cygwin environment)
   ;;
 *-*-solaris*)
   SYSTEM=SOLARIS
   AC_DEFINE(HAVE_SOLARIS, 1,  Solaris environment)
   ;;
 *-*-freebsd*)
   SYSTEM=FREEBSD
   AC_DEFINE(HAVE_FREEBSD, 1,  Freebsd environment)
   ;;
 *-*-hp*)
   SYSTEM=HP
   AC_DEFINE(HAVE_HP, 1,  Hp environment)
   ;;
 *)
   SYSTEM=UNKNOWN
   ;;
esac

dnl Default variables
dnl If ncurses is yes after arguments, than use ncurses. Otherwise, use curses
use_ncurses_library=yes
opt_with_ncurses_prefix=no
opt_with_curses_prefix=no
opt_with_readline_prefix=no

dnl argument to configure
AC_ARG_WITH(ncurses, AC_HELP_STRING([--with-ncurses=PREFIX], [Use system installed ncurses library]), opt_with_ncurses_prefix=$withval)
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses=PREFIX], [Use system installed curses library]), opt_with_curses_prefix=$withval use_ncurses_library=no)
AC_ARG_WITH(readline, AC_HELP_STRING([--with-readline=PREFIX], [Use system installed readline library]), opt_with_readline_prefix=$withval)

#dnl Used for debugging to look at the config options
#dnl echo "OPT_WITH_NCURSES_PREFIX=$opt_with_ncurses_prefix"
#dnl echo "OPT_WITH_CURSES_PREFIX=$opt_with_curses_prefix"
#dnl echo "OPT_WITH_READLINE_PREFIX=$opt_with_readline_prefix"
#dnl echo "WITH_NCURSES=$use_ncurses_library"

dnl ncurses-prefix argument
if test "$opt_with_ncurses_prefix" != "no"; then
  # If set to "yes", it is on the compilers include path.
  if test "$opt_with_curses_prefix" != "yes"; then
    LDFLAGS="-L$opt_with_ncurses_prefix/lib $LDFLAGS" CFLAGS="-I$opt_with_ncurses_prefix/include -I$opt_with_ncurses_prefix/include/ncurses $CFLAGS" CPPFLAGS="-I$opt_with_ncurses_prefix/include -I$opt_with_ncurses_prefix/include/ncurses $CPPFLAGS"
  fi
fi

if test "$opt_with_curses_prefix" != "no"; then
  # If set to "yes", it is on the compilers include path.
  if test "$opt_with_curses_prefix" != "yes"; then
    LDFLAGS="-L$opt_with_curses_prefix/lib $LDFLAGS" CFLAGS="-I$opt_with_curses_prefix/include $CFLAGS" CPPFLAGS="-I$opt_with_curses_prefix/include $CPPFLAGS"
  fi
fi

if test "$opt_with_readline_prefix" != "no"; then
  # If set to "yes", it is on the compilers include path.
  if test "$opt_with_readline_prefix" != "yes"; then
    LDFLAGS="-L$opt_with_readline_prefix/lib $LDFLAGS" CFLAGS="-I$opt_with_readline_prefix/include -I$opt_with_readline_prefix/include/readline $CFLAGS" CPPFLAGS="-I$opt_with_readline_prefix/include -I$opt_with_readline_prefix/include/readline $CPPFLAGS"
  fi
fi

dnl If the user want ncurses, Try to find it and add it to the linking library.
if test "$use_ncurses_library" = "yes"; then
        AC_CHECK_LIB(ncurses, initscr,
            [AC_DEFINE(HAVE_NCURSES, 1, ncurses library)],
            AC_MSG_ERROR([cgdb needs ncurses/curses to build. ncurses is strongly recommended.
    If your system does not have ncurses get it!
    If that is not an option try 'configure --with-curses.'
    You can try --with-ncurses-prefix=/foo/ncurses to tell configure where ncurses is.]))
        LIBS="-lncurses  $LIBS"
fi

dnl If the user want curses, Warn them that cgdb does not run perfect against it.
if test "$use_ncurses_library" = "no"; then
        AC_MSG_WARN([ *****************************************************
                     cgdb may not run properly when linked against curses!
                     *****************************************************])
        AC_CHECK_LIB(curses, initscr,
            [AC_DEFINE(HAVE_CURSES, 1, curses library)],
            AC_MSG_ERROR([cgdb needs ncurses/curses to build. ncurses is strongly recommended.
    If your system does not have ncurses get it!
    You can try --with-curses-prefix=/foo/curses to tell configure where curses is.]))
        LIBS="-lcurses  $LIBS"
fi

dnl Checking for log10 function in math - I would like to remove this
AC_CHECK_LIB(m, log10)

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT

# If using system readline, then configure for it
if test "$opt_with_readline_prefix" = "no"; then
echo "READLINE_PREFIX=NO";
else
VL_LIB_READLINE
fi

dnl determine if terminal headers are available for tgdb
AC_CHECK_HEADERS(pty.h sys/stropts.h termios.h sys/select.h)

dnl headers for pseudo.c -> don't know what these are for, I didn't write lib.
AC_CHECK_HEADERS(util.h libutil.h)

dnl determine other headers for tgdb, Error if they do not exist
AC_CHECK_HEADERS(errno.h fcntl.h grp.h pwd.h signal.h \
stdarg.h stdio.h stdlib.h string.h sys/ioctl.h \
sys/stat.h sys/time.h sys/types.h unistd.h,,AC_MSG_ERROR)

dnl determine headers for cgdb
AC_CHECK_HEADERS(ctype.h curses.h limits.h math.h regex.h time.h)

dnl Check for getopt.h, If this is here then getopt_long can be used.
AC_CHECK_HEADER(getopt.h, AC_DEFINE(HAVE_GETOPT_H, 1, have getopt_long))

dnl determine if /dev/ptmx is available for pseudo terminals
AC_CHECK_FILE([/dev/ptmx], AC_DEFINE(HAVE_DEV_PTMX, 1, have /dev/ptmx))

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_SETPGRP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(mkdir putenv select strdup strerror)

AC_OUTPUT(Makefile \
various/Makefile \
various/util/Makefile various/util/src/Makefile \
various/adt/Makefile various/adt/src/Makefile \
various/rlctx/Makefile various/rlctx/src/Makefile \
tgdb/Makefile \
tgdb/annotate-two/Makefile tgdb/annotate-two/src/Makefile \
tgdb/gdbmi/Makefile tgdb/gdbmi/src/Makefile \
tgdb/tgdb-base/Makefile tgdb/tgdb-base/src/Makefile \
cgdb/Makefile cgdb/src/Makefile \
cgdb/lib/Makefile cgdb/lib/kui/Makefile cgdb/lib/kui/src/Makefile \
cgdb/lib/wm/Makefile cgdb/lib/wm/src/Makefile \
cgdb/tokenizer/Makefile cgdb/tokenizer/src/Makefile)
--- configure.in.works	2005-07-13 07:33:18.000000000 -0400
+++ configure.in.does_not_work	2005-07-13 07:32:37.000000000 -0400
@@ -107,13 +107,6 @@
         LIBS="-lcurses  $LIBS"
 fi
 
-dnl Checking for log10 function in math - I would like to remove this
-AC_CHECK_LIB(m, log10)
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_HEADER_SYS_WAIT
-
 # If using system readline, then configure for it
 if test "$opt_with_readline_prefix" = "no"; then
 echo "READLINE_PREFIX=NO";
@@ -121,6 +114,13 @@
 VL_LIB_READLINE
 fi
 
+dnl Checking for log10 function in math - I would like to remove this
+AC_CHECK_LIB(m, log10)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+
 dnl determine if terminal headers are available for tgdb
 AC_CHECK_HEADERS(pty.h sys/stropts.h termios.h sys/select.h)
 
AC_DEFUN([VL_LIB_READLINE], [
  AC_CACHE_CHECK([for a readline compatible library],
                 vl_cv_lib_readline, [
    ORIG_LIBS="$LIBS"
    for readline_lib in readline edit editline; do
      for termcap_lib in "" termcap curses ncurses; do
        if test -z "$termcap_lib"; then
          TRY_LIB="-l$readline_lib"
        else
          TRY_LIB="-l$readline_lib -l$termcap_lib"
        fi
        LIBS="$ORIG_LIBS $TRY_LIB"
        AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
        if test -n "$vl_cv_lib_readline"; then
          break
        fi
      done
      if test -n "$vl_cv_lib_readline"; then
        break
      fi
    done
    if test -z "$vl_cv_lib_readline"; then
      vl_cv_lib_readline="no"
      LIBS="$ORIG_LIBS"
    fi
  ])

  if test "$vl_cv_lib_readline" != "no"; then
    AC_DEFINE(HAVE_LIBREADLINE, 1,
              [Define if you have a readline compatible library])
    AC_CHECK_HEADERS(readline.h readline/readline.h)
    AC_CACHE_CHECK([whether readline supports history],
                   vl_cv_lib_readline_history, [
      vl_cv_lib_readline_history="no"
      AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes")
    ])
    if test "$vl_cv_lib_readline_history" = "yes"; then
      AC_DEFINE(HAVE_READLINE_HISTORY, 1,
                [Define if your readline library has \`add_history'])
      AC_CHECK_HEADERS(history.h readline/history.h)
    fi
  fi
])dnl
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux