diff options
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/main.cc | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 895a46d6..b336fdfe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,8 @@ common_CFLAGS = \ -Wall \ -DINCLUDEDIR='"$(includedir)"' \ -DLIBDIR='"$(libdir)"' \ - -DABS_TOP_BUILDDIR='"$(abs_top_builddir)"' + -DABS_TOP_BUILDDIR='"$(abs_top_builddir)"' \ + -DABS_BUILDDIR='"$(abs_builddir)"' libprog_a_SOURCES = \ buffer.h bytecode.h colm.h debug.h dotgen.h fsmcodegen.h fsmgraph.h \ @@ -214,4 +215,3 @@ colm-wrap: colm-wrap.sh loadinit.cc: gen/if1.h loadboot2.cc: gen/if2.h loadcolm.cc: gen/if3.h - diff --git a/src/main.cc b/src/main.cc index 482fb4a4..a54a6dd8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -688,14 +688,23 @@ void defaultBuildDir() if ( buildDir != 0 ) return; - const char *ldlp = getenv("LD_LIBRARY_PATH"); - if ( ldlp != 0 ) { - size_t len_atbd = strlen(ABS_TOP_BUILDDIR); + struct stat self; + if ( stat( "/proc/self/exe", &self ) == 0 ) + { + struct stat colm; + + if ( stat ( ABS_BUILDDIR "/" LT_OBJDIR "colm", &colm ) == 0 && + self.st_dev == colm.st_dev && self.st_ino == colm.st_ino ) + { + buildDir = ABS_TOP_BUILDDIR; + return; + } - if ( strlen(ldlp) > len_atbd && - memcmp( ldlp, ABS_TOP_BUILDDIR "/", len_atbd+1) == 0 ) + if ( stat ( ABS_BUILDDIR "/colm", &colm ) == 0 && + self.st_dev == colm.st_dev && self.st_ino == colm.st_ino ) { buildDir = ABS_TOP_BUILDDIR; + return; } } } |