Commit cfdc54f6 authored by Axel Auweter's avatar Axel Auweter
Browse files

And more fixes to Makefile and cxx11flags.sh...

parent 9145c93d
include ../config.mk include ../config.mk
CXXFLAGS = $(shell ./cxx11flags.sh $(CXX) -O0 -g -Wall -Wno-null-conversion -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/) CXXFLAGS = $(shell ./cxx11flags.sh $(CXX) -O0 -g -Wall -Wno-null-conversion -fmessage-length=0 -I$(DCDBDEPLOYPATH)/include/ | head -1)
OBJS = collectagent.o simplemqttserver.o simplemqttserverthread.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o OBJS = collectagent.o simplemqttserver.o simplemqttserverthread.o cassandra/Cassandra.o cassandra/cassandra_constants.o cassandra/cassandra_types.o
SRC = $(patsubst cassandra/%,,$(OBJS:.o=.cpp)) SRC = $(patsubst cassandra/%,,$(OBJS:.o=.cpp))
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread -lboost_system LIBS = $(shell ./cxx11flags.sh $(CXX) -L$(DCDBDEPLOYPATH)/lib/ -lthrift -lmosquitto -lssl -lcrypto -lpthread -lboost_system | tail -1)
TARGET = collectagent TARGET = collectagent
SUBTARGETS = cassandra/Cassandra.h SUBTARGETS = cassandra/Cassandra.h
......
#!/bin/bash #!/bin/bash
function test_flags { CFLAGSOK=0
LFLAGSOK=0
function test_cflags {
CXX=$1 CXX=$1
shift 1 shift 1
FLAGS+=$* FLAGS+=$*
cat << EOF | $CXX $FLAGS -x c++ - -o /dev/null &>/dev/null cat << EOF | $CXX $FLAGS -c -x c++ - -o $TMPFILE1 &>/dev/null
#include <system_error> #include <system_error>
int main() { int main() {
std::system_error e(0, std::system_category(), ""); std::system_error e(0, std::system_category(), "");
return 0; return 0;
} }
EOF EOF
}
function test_lflags {
CXX=$1
shift 1
FLAGS+=$*
$CXX $FLAGS -o $TMPFILE2 $TMPFILE1 &>/dev/null
} }
if [ "$#" -lt "1" ]; then if [ "$#" -lt "1" ]; then
...@@ -21,23 +31,59 @@ if [ "$#" -lt "1" ]; then ...@@ -21,23 +31,59 @@ if [ "$#" -lt "1" ]; then
exit 0 exit 0
fi fi
# Create a temporary file for the C++ compiler output.
tempdir=`basename $0`
TMPFILE1=`mktemp -t ${tempdir}` || exit 1
TMPFILE2=`mktemp -t ${tempdir}` || exit 1
# Test c++ 11 flags for g++... # Test c++ 11 flags for g++...
if [ "$CFLAGSOK" -eq "0" ]; then
FLAGS="--std=c++11 " FLAGS="--std=c++11 "
test_flags $@ test_cflags $@
if [ "$?" -eq "0" ]; then if [ "$?" -eq "0" ]; then
echo $FLAGS echo $FLAGS
exit 0 CFLAGSOK=1
goto
fi
fi fi
# Test c++ 11 flags for llvm clang # Test c++ 11 flags for llvm clang
FLAGS="-std=c++11 -stdlib=libc++ -lc++ " if [ "$CFLAGSOK" -eq "0" ]; then
test_flags $@ FLAGS="-std=c++11 -stdlib=libc++ "
test_cflags $@
if [ "$?" -eq "0" ]; then if [ "$?" -eq "0" ]; then
echo $FLAGS echo $FLAGS
exit 0 CFLAGSOK=1
fi
fi fi
# No idea how to get c++11 code compiled on this machine -> return error! # No idea how to get c++11 code compiled on this machine -> return error!
exit 1 if [ "$CFLAGSOK" -eq "0" ]; then
exit 1
fi
# Test c++ 11 linker flags for g++ (nothing required)
if [ "$LFLAGSOK" -eq "0" ]; then
FLAGS=" "
test_lflags $@
if [ "$?" -eq "0" ]; then
echo $FLAGS
LFLAGSOK=1
fi
fi
# Test c++ 11 linker flags for llvm clang
if [ "$LFLAGSOK" -eq "0" ]; then
FLAGS="-lc++ "
test_lflags $@
if [ "$?" -eq "0" ]; then
echo $FLAGS
LFLAGSOK=1
fi
fi
# No idea how to get c++11 code linked on this machine -> return error!
if [ "$LFLAGSOK" -eq "0" ]; then
exit 1
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment