From 1a17581567684ca2b8a0d703b449b04f5195a6f3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 8 Jun 2010 14:35:11 +0200 Subject: [PATCH] STYLE: consistent handling of compile/link flags for fileMonitor and setSet --- .../mesh/manipulation/setSet/Allwmake | 21 +++++++++------ .../mesh/manipulation/setSet/Make/options | 8 +++--- .../mesh/manipulation/setSet/setSet.C | 27 +++---------------- src/OSspecific/POSIX/Allwmake | 11 +++++--- src/OSspecific/POSIX/Make/options | 2 +- 5 files changed, 28 insertions(+), 41 deletions(-) diff --git a/applications/utilities/mesh/manipulation/setSet/Allwmake b/applications/utilities/mesh/manipulation/setSet/Allwmake index ef0a573951..3be0afc595 100755 --- a/applications/utilities/mesh/manipulation/setSet/Allwmake +++ b/applications/utilities/mesh/manipulation/setSet/Allwmake @@ -1,15 +1,20 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory -if [ -f /usr/include/readline/readline.h ] +unset COMP_FLAGS LINK_FLAGS + +# +# use readline if available +# unless otherwise specified (with NO_READLINE) +# +# eg, ./Allwmake NO_READLINE +# + +if [ -f /usr/include/readline/readline.h -a "${1%NO_READLINE}" = "$1" ] then - echo "Found readline/readline.h -- enabling readline support." - export READLINE=1 - export READLINELINK="-lreadline -lncurses" -else - # no readline/readline.h -- disabling readline support - export READLINE=0 - unset READLINELINK + echo "Found -- enabling readline support." + export COMP_FLAGS="-DHAS_READLINE" + export LINK_FLAGS="-lreadline -lncurses" fi wmake diff --git a/applications/utilities/mesh/manipulation/setSet/Make/options b/applications/utilities/mesh/manipulation/setSet/Make/options index d56c2b57f7..febadade7b 100644 --- a/applications/utilities/mesh/manipulation/setSet/Make/options +++ b/applications/utilities/mesh/manipulation/setSet/Make/options @@ -1,9 +1,7 @@ -/* NB: trailing zero after define improves robustness */ - EXE_INC = \ - -DREADLINE=$(READLINE)0 \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + $(COMP_FLAGS) EXE_LIBS = \ -lmeshTools \ - $(READLINELINK) + $(LINK_FLAGS) diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index 308319f2e6..7b204e984f 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -49,7 +49,7 @@ Description #include -#if READLINE != 0 +#ifdef HAS_READLINE # include # include #endif @@ -59,29 +59,10 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#if READLINE != 0 +#ifdef HAS_READLINE static const char* historyFile = ".setSet"; #endif -Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr) -{ - if (is0Ptr) - { - return *is0Ptr; - } - else if (is1Ptr) - { - return *is1Ptr; - } - else - { - FatalErrorIn("selectStream(Istream*, Istream*)") - << "No valid stream opened" << abort(FatalError); - - return *is0Ptr; - } -} - // Write set to VTK readable files void writeVTK @@ -867,7 +848,7 @@ int main(int argc, char *argv[]) printAllSets(mesh, Info); // Read history if interactive -# if READLINE != 0 +# ifdef HAS_READLINE if (!batch && !read_history(historyFile)) { Info<< "Successfully read history from " << historyFile << endl; @@ -949,7 +930,7 @@ int main(int argc, char *argv[]) } else { -# if READLINE != 0 +# ifdef HAS_READLINE { char* linePtr = readline("readline>"); diff --git a/src/OSspecific/POSIX/Allwmake b/src/OSspecific/POSIX/Allwmake index 7819ce885b..d3b21b47fc 100755 --- a/src/OSspecific/POSIX/Allwmake +++ b/src/OSspecific/POSIX/Allwmake @@ -1,17 +1,20 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +unset COMP_FLAGS LINK_FLAGS + # # use if available (Linux) -# unless otherwise specified (with FOAM_USE_STAT) +# unless otherwise specified (with USE_STAT) # -# eg, ./Allwmake FOAM_USE_STAT +# eg, ./Allwmake USE_STAT # if [ -f /usr/include/sys/inotify.h -a "${1%USE_STAT}" = "$1" ] then - unset FOAM_FILE_MONITOR + echo "Found -- using inotify for file monitoring." + unset COMP_FLAGS else - export FOAM_FILE_MONITOR="-DFOAM_USE_STAT" + export COMP_FLAGS="-DFOAM_USE_STAT" fi diff --git a/src/OSspecific/POSIX/Make/options b/src/OSspecific/POSIX/Make/options index be643469df..3f86d412a6 100644 --- a/src/OSspecific/POSIX/Make/options +++ b/src/OSspecific/POSIX/Make/options @@ -1 +1 @@ -EXE_INC = $(FOAM_FILE_MONITOR) +EXE_INC = $(COMP_FLAGS)