Index: kitsh/buildsrc/kitsh-0.0/Makefile.in ================================================================== --- kitsh/buildsrc/kitsh-0.0/Makefile.in +++ kitsh/buildsrc/kitsh-0.0/Makefile.in @@ -1,9 +1,9 @@ CC = @CC@ RC = @RC@ -CFLAGS = @CFLAGS@ @DEFS@ -DSTDC_HEADERS=1 -DTK_LOCAL_APPINIT=TclKit_AppInit -CPPFLAGS = @CPPFLAGS@ @DEFS@ -DSTDC_HEADERS=1 -DTK_LOCAL_APPINIT=TclKit_AppInit +CFLAGS = @CFLAGS@ @DEFS@ -DTK_LOCAL_APPINIT=TclKit_AppInit +CPPFLAGS = @CPPFLAGS@ @DEFS@ -DTK_LOCAL_APPINIT=TclKit_AppInit LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ ARCHS = @ARCHS@ OBJS = kitInit.o main.o pwb.o rechan.o zlib.o winMain.o @EXTRA_OBJS@ Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -39,12 +39,16 @@ AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath) dnl Check for the ability to get the current system encoding 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) + dnl Check for optional system calls -AC_CHECK_FUNCS(readlink) +AC_CHECK_FUNCS(readlink 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 @@ -30,10 +30,21 @@ #ifndef MB_TASKMODAL # define MB_TASKMODAL 0 #endif /* MB_TASKMODAL */ #include "tclInt.h" + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_DLADDR +# ifdef HAVE_DLFCN_H +# include +# else +# undef HAVE_DLADDR +# endif +#endif #if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING) # define TCLKIT_CAN_SET_ENCODING 1 #endif #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 @@ -193,16 +204,22 @@ static void FindAndSetExecName(Tcl_Interp *interp) { int len = 0; Tcl_Obj *execNameObj; Tcl_Obj *lobjv[1]; -#if defined(HAVE_READLINK) +#ifdef HAVE_READLINK ssize_t readlink_ret; char procpath[4096]; char exe_buf[4096]; int snprintf_ret; +#endif /* HAVE_READLINK */ +#ifdef HAVE_DLADDR + Dl_info syminfo; + int dladdr_ret; +#endif /* HAVE_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)) { readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1); @@ -213,11 +230,20 @@ return; } } } -#endif +#endif /* HAVE_READLINK */ + +#ifdef HAVE_DLADDR + if (Tcl_GetNameOfExecutable() == NULL) { + dladdr_ret = dladdr(&SetExecName, &syminfo); + if (dladdr_ret != 0) { + SetExecName(interp, syminfo.dli_fname); + } + } +#endif /* HAVE_DLADDR */ if (Tcl_GetNameOfExecutable() == NULL) { lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv);