Index: kitsh/buildsrc/kitsh-0.0/aclocal.m4 ================================================================== --- kitsh/buildsrc/kitsh-0.0/aclocal.m4 +++ kitsh/buildsrc/kitsh-0.0/aclocal.m4 @@ -231,5 +231,32 @@ AC_MSG_RESULT([not needed]) fi AC_SUBST(LDFLAGS) ]) + +AC_DEFUN(DC_CHECK_FOR_ACCEPTABLE_DLADDR, [ + AC_CHECK_HEADERS(dlfcn.h) + AC_CHECK_FUNCS(dladdr) + + AC_MSG_CHECKING([for acceptable dladdr]) + + AC_LINK_IFELSE( + AC_LANG_PROGRAM([[ +#ifdef HAVE_DLFCN_H +#include +#endif + ]], [[ +char *x; +Dl_info syminfo; +dladdr((void *) 0, &syminfo); +x = syminfo.dli_fname; + ]] + ), + [ + AC_MSG_RESULT([found]) + AC_DEFINE(HAVE_ACCEPTABLE_DLADDR, [1], [Define to 1 if you have an acceptable dladdr implementation with dli_fname]) + ], [ + AC_MSG_RESULT([not found]) + ] + ) +]) Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -41,14 +41,17 @@ AC_CHECK_FUNCS(Tcl_GetEncodingNameFromEnvironment Tcl_SetSystemEncoding) LIBS="${SAVE_LIBS}" dnl Check for optional headers AC_HEADER_STDC -AC_CHECK_HEADERS(unistd.h dlfcn.h) +AC_CHECK_HEADERS(unistd.h) dnl Check for optional system calls -AC_CHECK_FUNCS(readlink dladdr) +AC_CHECK_FUNCS(readlink) + +dnl Check for acceptable dladdr so we can find ourselves on Solaris +DC_CHECK_FOR_ACCEPTABLE_DLADDR dnl Find zlib AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib], [directory containing zlib]), [ CPPFLAGS="${CPPFLAGS} -I${with_zlib}/include -I${with_zlib}" CFLAGS="${CFLAGS} -I${with_zlib}/include -I${with_zlib}" Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -34,16 +34,14 @@ #include "tclInt.h" #ifdef HAVE_UNISTD_H # include #endif -#ifdef HAVE_DLADDR -# ifdef HAVE_DLFCN_H -# include -# else -# undef HAVE_DLADDR -# endif + +/* For dladdr() and Dl_info */ +#ifdef HAVE_DLFCN_H +# include #endif #if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING) # define TCLKIT_CAN_SET_ENCODING 1 #endif @@ -210,14 +208,14 @@ ssize_t readlink_ret; char procpath[4096]; char exe_buf[4096]; int snprintf_ret; #endif /* HAVE_READLINK */ -#ifdef HAVE_DLADDR +#ifdef HAVE_ACCEPTABLE_DLADDR Dl_info syminfo; int dladdr_ret; -#endif /* HAVE_DLADDR */ +#endif /*aHAVE_ACCEPTABLE_DLADDR */ #ifdef HAVE_READLINK if (Tcl_GetNameOfExecutable() == NULL) { snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid()); if (snprintf_ret < sizeof(procpath)) { @@ -232,18 +230,18 @@ } } } #endif /* HAVE_READLINK */ -#ifdef HAVE_DLADDR +#ifdef HAVE_ACCEPTABLE_DLADDR if (Tcl_GetNameOfExecutable() == NULL) { dladdr_ret = dladdr(&SetExecName, &syminfo); if (dladdr_ret != 0) { SetExecName(interp, syminfo.dli_fname); } } -#endif /* HAVE_DLADDR */ +#endif /* HAVE_ACCEPTABLE_DLADDR */ if (Tcl_GetNameOfExecutable() == NULL) { lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv);