STYLE: consistent handling of compile/link flags for fileMonitor and setSet

This commit is contained in:
Mark Olesen
2010-06-08 14:35:11 +02:00
parent aaf1674de2
commit 1a17581567
5 changed files with 28 additions and 41 deletions

View File

@ -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 <readline/readline.h> -- enabling readline support."
export COMP_FLAGS="-DHAS_READLINE"
export LINK_FLAGS="-lreadline -lncurses"
fi
wmake

View File

@ -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)

View File

@ -49,7 +49,7 @@ Description
#include <stdio.h>
#if READLINE != 0
#ifdef HAS_READLINE
# include <readline/readline.h>
# include <readline/history.h>
#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>");

View File

@ -1,17 +1,20 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
unset COMP_FLAGS LINK_FLAGS
#
# use <sys/inotify.h> 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 <sys/inotify.h> -- using inotify for file monitoring."
unset COMP_FLAGS
else
export FOAM_FILE_MONITOR="-DFOAM_USE_STAT"
export COMP_FLAGS="-DFOAM_USE_STAT"
fi

View File

@ -1 +1 @@
EXE_INC = $(FOAM_FILE_MONITOR)
EXE_INC = $(COMP_FLAGS)