summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/main.cc19
2 files changed, 21 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 09da4c47..895a46d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,7 +53,8 @@ endif
common_CFLAGS = \
-Wall \
-DINCLUDEDIR='"$(includedir)"' \
- -DLIBDIR='"$(libdir)"'
+ -DLIBDIR='"$(libdir)"' \
+ -DABS_TOP_BUILDDIR='"$(abs_top_builddir)"'
libprog_a_SOURCES = \
buffer.h bytecode.h colm.h debug.h dotgen.h fsmcodegen.h fsmgraph.h \
diff --git a/src/main.cc b/src/main.cc
index 317f3bce..482fb4a4 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -683,11 +683,30 @@ bool readCheck( const char *fn )
return result;
}
+void defaultBuildDir()
+{
+ if ( buildDir != 0 )
+ return;
+
+ const char *ldlp = getenv("LD_LIBRARY_PATH");
+ if ( ldlp != 0 ) {
+ size_t len_atbd = strlen(ABS_TOP_BUILDDIR);
+
+ if ( strlen(ldlp) > len_atbd &&
+ memcmp( ldlp, ABS_TOP_BUILDDIR "/", len_atbd+1) == 0 )
+ {
+ buildDir = ABS_TOP_BUILDDIR;
+ }
+ }
+}
+
/* Main, process args and call yyparse to start scanning input. */
int main(int argc, const char **argv)
{
processArgs( argc, argv );
+ defaultBuildDir();
+
if ( verbose )
gblActiveRealm = 0xffffffff;