From owner-freebsd-questions Wed Jan 22 20:14:54 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 77EE437B401 for ; Wed, 22 Jan 2003 20:14:50 -0800 (PST) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id C8CDC43E4A for ; Wed, 22 Jan 2003 20:14:49 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.6/8.12.6) id h0N4EiXC071123; Wed, 22 Jan 2003 22:14:44 -0600 (CST) (envelope-from dan) Date: Wed, 22 Jan 2003 22:14:44 -0600 From: Dan Nelson To: edscott wilson garcia Cc: freebsd-questions@FreeBSD.ORG Subject: Re: checking for headers Message-ID: <20030123041444.GA53550@dan.emsphone.com> References: <1043292867.25022.9.camel@sagitario.eco.imp.mx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <1043292867.25022.9.camel@sagitario.eco.imp.mx> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.3i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In the last episode (Jan 22), edscott wilson garcia said: > I'm trying to get a "configure" program to check for dbh.h, but the > following line only checks in /usr/include: > > AC_CHECK_HEADERS(dbh.h, ac_cv_dbh_library=yes, ac_cv_dbh_library=no) > > The generated configure in Linux searches both /usr/include and > /usr/local/include, but not in FreeBSD. What do I have to add so that > it will search /usr/local/include in FreeBSD? You are usually better off simply telling your users to add required include and lib paths to CPPFLAGS and LDFLAGS. You can manually add paths by appending to CPPFLAGS at the top of your configure.in, but gcc will complain if you add a directory that's already in the system's path, and you risk not including common locations on other systems (lots of Solaris stuff installs in /opt, for example). There is no simple autoconf command for "add this include path if it exists and the compiler doesn't complain". I have attached the autoconf code that the Pike configure script uses; it will detect most common include and lib paths. It probably won't work on its own, but it's an example of how complicated it is when done right. -- Dan Nelson dnelson@allantgroup.com --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="configure.in" ############################################################################# ## Search for some popular places where libraries may be hidden. ############################################################################# if test x$"pike_cv_sys_os" != xWindows_NT ; then echo Searching for include-file directories... #Don't add include dirs if they give us warnings... OLD_ac_c_preproc_warn_flag="$ac_c_preproc_warn_flag" ac_c_preproc_warn_flag=yes if test $cppflags_is_set = no -a x${C_INCLUDE_PATH-} = x ; then real_include_dirs='' for d in `echo ${with_include_path} | sed 's/:/ /g'` \ `echo "${with_site_prefixes}/include"|sed -e 's/:/\/include /g'` \ `echo $prefix | sed "s@^NONE@$with_root$ac_default_prefix@g"`/include \ $with_root/usr/local/include $with_root/sw/local/include \ $with_root/usr/gnu/include $with_root/opt/gnu/include \ $with_root/sw/gnu/include $with_root/sw/include \ $with_root/usr/freeware/include $with_root/usr/pkg/include \ $with_root/opt/sfw/include \ `echo $with_root/opt/gnome*/include | sort -r` \ `echo $with_root/usr/X11*/include | sort -r` do AC_MSG_CHECKING($d) case x$d in x/usr/include | x/usr//include) ;; *) if test -d "$d/." ; then REALDIR="`cd $d/. ; /bin/pwd`" if test "x$REALDIR" = x ; then REALDIR=UNKNOWN else : fi case " $CPPFLAGS $real_include_dirs " in *\ -I$d\ * | *\ -I$REALDIR\ *) AC_MSG_RESULT(already added) ;; *) OLD_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} -I$d" AC_TRY_CPP([#include ], [ AC_MSG_RESULT(added) if test "x$REALDIR" != xUNKNOWN; then real_include_dirs="${real_include_dirs} -I$REALDIR" else : fi ], [ AC_MSG_RESULT(fails) CPPFLAGS="${OLD_CPPFLAGS}" ]) ;; esac else AC_MSG_RESULT(no) fi ;; esac done else : fi #Restore preprocessor warning sensitivity ac_c_preproc_warn_flag="$OLD_ac_c_preproc_warn_flag" #CPPFLAGS="${CPPFLAGS} -I$srcdir -I`pwd`" echo Searching for library directories... if test $ldflags_is_set = no ; then for dd in `echo ${with_lib_path} | sed 's/:/ /g'` \ `echo "${with_site_prefixes}/lib"|sed -e 's/:/\/lib /g'` \ `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$with_root$ac_default_prefix@g"` \ $with_root/usr/local/lib $with_root/sw/local/lib $with_root/sw/lib \ $with_root/usr/gnu/lib $with_root/opt/gnu/lib $with_root/sw/gnu/lib \ $with_root/usr/freeware/lib $with_root/usr/pkg/lib \ $with_root/opt/sfw/lib $with_root/opt/gnome-1.4/lib \ `echo $with_root/usr/X11*/lib | sort -r` do if test "$dd" = "/lib"; then continue; fi if test "$dd" = "/usr/lib"; then continue; fi for suff in '' 32 64 '/64'; do d="$dd$suff" AC_MSG_CHECKING($d) if test -d "$d/." ; then case " $LDFLAGS " in *\ -L$d\ -R$d\ * | *\ -R$d\ -L$d\ *) AC_MSG_RESULT(already added) ;; *) OLD_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS} -R$d -L$d -lm" AC_TRY_RUN([ #include #include int main(int argc, char **argv) { double (*foo)(double) = ceil; exit(0); } ],[ LDFLAGS="$OLD_LDFLAGS -R$d -L$d" AC_MSG_RESULT(yes) ],[ LDFLAGS="$OLD_LDFLAGS" AC_MSG_RESULT(no) ],[AC_TRY_LINK([ #include #include ],[ double (*foo)(double) = ceil; exit(0); ],[ LDFLAGS="$OLD_LDFLAGS -R$d -L$d" AC_MSG_RESULT(probably) ],[ LDFLAGS="$OLD_LDFLAGS" AC_MSG_RESULT(no)])]) ;; esac else AC_MSG_RESULT(no) fi done done else : fi --jRHKVT23PllUwdXP-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message