From 69d6fcbf56ed823461189f2488e5c2b2f44dca02 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Mon, 22 Feb 2010 06:54:19 +0000 Subject: [PATCH] fix bug 33 (statically link the "cvc4" binary); also main driver cleanup --- Makefile.builds.in | 10 ++++------ configure.ac | 1 + src/main/Makefile.am | 4 ++++ src/main/main.cpp | 12 ++++++------ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Makefile.builds.in b/Makefile.builds.in index 650d7be6d..f26111c4f 100644 --- a/Makefile.builds.in +++ b/Makefile.builds.in @@ -57,9 +57,8 @@ ifeq ($(BUILDING_SHARED),1) progdir="$(abs_builddir)$(bindir)"; file=cvc4; \ eval `grep '^relink_command=' $(CURRENT_BUILD)/src/main/cvc4 | sed 's:-Wl,-rpath:-Wl,-rpath -Wl,\\\\$$thelibdir -Wl,-rpath:'`; \ eval "(cd $(CURRENT_BUILD)/src/main && $$relink_command)" -endif -ifeq ($(BUILDING_STATIC),1) -# if we're building static libs, just install them directly +else +# if we're building static libs only, just install the driver binary directly $(install_sh) \ $(CURRENT_BUILD)/src/main/cvc4 \ "$(abs_builddir)$(bindir)" @@ -78,9 +77,8 @@ ifeq ($(BUILDING_SHARED),1) thelibdir="`pwd`$(libdir)"; progdir="`pwd`$(bindir)"; file=cvc4; \ eval `grep '^relink_command=' $(CURRENT_BUILD)/src/main/cvc4 | sed 's:-Wl,-rpath:-Wl,-rpath -Wl,\\\\$$thelibdir -Wl,-rpath:'`; \ eval "(cd $(CURRENT_BUILD)/src/main && $$relink_command)" -endif -ifeq ($(BUILDING_STATIC),1) -# if we're building static libs, just install them directly +else +# if we're building static libs only, just install the driver binary directly $(install_sh) $(CURRENT_BUILD)/src/main/cvc4 "`pwd`$(bindir)" endif # set up builds/bin and builds/lib diff --git a/configure.ac b/configure.ac index c67da8ba2..36f6d6c16 100644 --- a/configure.ac +++ b/configure.ac @@ -407,6 +407,7 @@ if test "$enable_shared" = yes; then BUILDING_SHARED=1; fi if test "$enable_static" = yes; then BUILDING_STATIC=1; fi AC_SUBST(BUILDING_SHARED) AC_SUBST(BUILDING_STATIC) +AM_CONDITIONAL([STATIC_BINARY], [test "$enable_shared" != yes -a "$enable_static" = yes]) AC_SUBST(CVC4_LIBRARY_VERSION) AC_SUBST(CVC4_PARSER_LIBRARY_VERSION) diff --git a/src/main/Makefile.am b/src/main/Makefile.am index 04d717294..79eb8c74e 100644 --- a/src/main/Makefile.am +++ b/src/main/Makefile.am @@ -15,4 +15,8 @@ cvc4_LDADD = \ ../parser/libcvc4parser.la \ ../libcvc4.la +if STATIC_BINARY +cvc4_LINK = $(CXXLINK) -all-static +else cvc4_LINK = $(CXXLINK) +endif diff --git a/src/main/main.cpp b/src/main/main.cpp index e54bbb5f6..6ebe895a5 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -68,16 +68,16 @@ int main(int argc, char *argv[]) { SmtEngine smt(&exprMgr, &options); // If no file supplied we read from standard input - bool inputFromStdin = firstArgIndex >= argc; + bool inputFromStdin = firstArgIndex >= argc || !strcmp("-", argv[firstArgIndex]); // Auto-detect input language by filename extension if(!inputFromStdin && options.lang == Parser::LANG_AUTO) { - if(!strcmp(".smt", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - 4)) { + const char* filename = argv[firstArgIndex]; + unsigned len = strlen(filename); + if(len >= 4 && !strcmp(".smt", filename + len - 4)) { options.lang = Parser::LANG_SMTLIB; - } else if(!strcmp(".cvc", argv[firstArgIndex] - + strlen(argv[firstArgIndex]) - 4) - || !strcmp(".cvc4", argv[firstArgIndex] + strlen(argv[firstArgIndex]) - - 5)) { + } else if(( len >= 4 && !strcmp(".cvc", filename + len - 4) ) + || ( len >= 5 && !strcmp(".cvc4", filename + len - 5) )) { options.lang = Parser::LANG_CVC4; } } -- 2.30.2