Sat, 24 Oct 2020 17:36:00 +0200
fix toolchain detection in case gcc is not available
test/config.mk | file | annotate | diff | comparison | revisions | |
test/configure | file | annotate | diff | comparison | revisions | |
test/make/configure.vm | file | annotate | diff | comparison | revisions | |
test/make/project.xml | file | annotate | diff | comparison | revisions | |
test/make/toolchain.sh | file | annotate | diff | comparison | revisions |
--- a/test/config.mk Sun Jun 07 14:42:06 2020 +0200 +++ b/test/config.mk Sat Oct 24 17:36:00 2020 +0200 @@ -22,13 +22,14 @@ MANDIR=/export/home/olaf/Projekte/uwproj/test/work/man # toolchain -CC = gcc -CXX = g++ -LD = gcc -include $(BUILD_ROOT)/make/gcc.mk +CC = clang +CXX = clang++ +LD = clang + +include $(BUILD_ROOT)/make/clang.mk -CFLAGS += -I/usr/include/libxml2 -LDFLAGS += -lxml2 -lssl -lcrypto -lpq +CFLAGS += -I/usr/local/include/libxml2 +LDFLAGS += -L/usr/local/lib -lxml2 -lssl -lcrypto
--- a/test/configure Sun Jun 07 14:42:06 2020 +0200 +++ b/test/configure Sat Oct 24 17:36:00 2020 +0200 @@ -291,6 +291,17 @@ return 0 done + # dependency openssl platform="bsd" + while true + do + if isnotplatform "bsd"; then + break + fi + LDFLAGS="$LDFLAGS -lssl -lcrypto" + echo yes + return 0 + done + echo no return 1 } @@ -401,7 +412,7 @@ if [ $ERROR -ne 0 ]; then echo echo "Error: Unresolved dependencies" - echo $DEPENCIES_FAILED + echo $DEPENDENCIES_FAILED rm -Rf $TEMP_DIR exit 1 fi
--- a/test/make/configure.vm Sun Jun 07 14:42:06 2020 +0200 +++ b/test/make/configure.vm Sat Oct 24 17:36:00 2020 +0200 @@ -610,7 +610,7 @@ if [ $ERROR -ne 0 ]; then echo echo "Error: Unresolved dependencies" - echo $DEPENCIES_FAILED + echo $DEPENDENCIES_FAILED rm -Rf $TEMP_DIR exit 1 fi
--- a/test/make/project.xml Sun Jun 07 14:42:06 2020 +0200 +++ b/test/make/project.xml Sat Oct 24 17:36:00 2020 +0200 @@ -20,6 +20,10 @@ <pkgconfig>openssl</pkgconfig> </dependency> + <dependency name="openssl" platform="bsd"> + <ldflags>-lssl -lcrypto</ldflags> + </dependency> + <!-- optional dependencies --> <dependency name="libpq"> <pkgconfig>libpq</pkgconfig>
--- a/test/make/toolchain.sh Sun Jun 07 14:42:06 2020 +0200 +++ b/test/make/toolchain.sh Sat Oct 24 17:36:00 2020 +0200 @@ -11,161 +11,171 @@ check_c_compiler() { - cat > $TEMP_DIR/test.c << __EOF__ + cat > $TEMP_DIR/test.c << __EOF__ /* test file */ #include <stdio.h> int main(int argc, char **argv) { -#if defined(__GNUC__) - printf("gcc\n"); -#elif defined(__clang__) - printf("clang\n"); +#if defined(__clang__) + printf("clang\n"); +#elif defined(__GNUC__) + printf("gcc\n"); #elif defined(__sun) - printf("suncc\n"); + printf("suncc\n"); #else - printf("unknown\n"); + printf("unknown\n"); #endif - return 0; + return 0; } __EOF__ - rm -f $TEMP_DIR/checkcc - $1 -o $TEMP_DIR/checkcc $CFLAGS $LDFLAGS $TEMP_DIR/test.c 2> /dev/null - - if [ $? -ne 0 ]; then - return 1 - fi - return 0 + rm -f $TEMP_DIR/checkcc + $1 -o $TEMP_DIR/checkcc $CFLAGS $LDFLAGS $TEMP_DIR/test.c 2> /dev/null + + if [ $? -ne 0 ]; then + return 1 + fi + return 0 } check_cpp_compiler() { - cat > $TEMP_DIR/test.cpp << __EOF__ + cat > $TEMP_DIR/test.cpp << __EOF__ /* test file */ #include <iostream> int main(int argc, char **argv) { -#if defined(__GNUC__) - std::cout << "gcc" << std::endl; -#elif defined(__clang__) - std::cout << "clang" << std::endl; +#if defined(__clang__) + std::cout << "clang" << std::endl; +#elif defined(__GNUC__) + std::cout << "gcc" << std::endl; #elif defined(__sun) std::cout << "suncc" << std::endl; #else - std::cout << "unknown" << std::endl; + std::cout << "unknown" << std::endl; #endif - return 0; + return 0; } __EOF__ - rm -f $TEMP_DIR/checkcc - $1 -o $TEMP_DIR/checkcc $CXXFLAGS $LDFLAGS $TEMP_DIR/test.cpp 2> /dev/null - - if [ $? -ne 0 ]; then - return 1 - fi - return 0 + rm -f $TEMP_DIR/checkcc + $1 -o $TEMP_DIR/checkcc $CXXFLAGS $LDFLAGS $TEMP_DIR/test.cpp 2> /dev/null + + if [ $? -ne 0 ]; then + return 1 + fi + return 0 } printf "detect C compiler... " for COMP in $C_COMPILERS do - check_c_compiler $COMP - if [ $? -ne 0 ]; then - if [ ! -z "$CC" ]; then - if [ $COMP = $CC ]; then - echo "$CC is not a working C Compiler" - TOOLCHAIN_DETECTION_ERROR="error" - break - fi + check_c_compiler $COMP + if [ $? -ne 0 ]; then + if [ ! -z "$CC" ]; then + if [ $COMP = $CC ]; then + echo "$CC is not a working C Compiler" + TOOLCHAIN_DETECTION_ERROR="error" + break + fi fi - else - TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` + else + TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` + USE_TOOLCHAIN=$TOOLCHAIN_NAME if [ $COMP = "cc" ]; then - # we have found a working compiler, but in case - # the compiler is gcc or clang, we try to use - # these commands and not 'cc' - TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` - if [ $TOOLCHAIN_NAME = "gcc" ]; then - check_c_compiler "gcc" - if [ $? -eq 0 ]; then - COMP=gcc - fi - fi - if [ $TOOLCHAIN_NAME = "clang" ]; then - check_c_compiler "clang" - if [ $? -eq 0 ]; then - COMP=clang - fi - fi + # we have found a working compiler, but in case + # the compiler is gcc or clang, we try to use + # these commands and not 'cc' + TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` + if [ $TOOLCHAIN_NAME = "gcc" ]; then + check_c_compiler "gcc" + if [ $? -eq 0 ]; then + COMP=gcc + USE_TOOLCHAIN="gcc" + fi + fi + if [ $TOOLCHAIN_NAME = "clang" ]; then + check_c_compiler "clang" + if [ $? -eq 0 ]; then + COMP=clang + USE_TOOLCHAIN="clang" + fi + fi fi - TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` - TOOLCHAIN_CC=$COMP - echo $COMP - break - fi + TOOLCHAIN_NAME=$USE_TOOLCHAIN + TOOLCHAIN_CC=$COMP + echo $COMP + break + fi done if [ -z $TOOLCHAIN_CC ]; then - echo "not found" + echo "not found" fi printf "detect C++ compiler... " for COMP in $CPP_COMPILERS do - check_cpp_compiler $COMP - if [ $? -ne 0 ]; then + check_cpp_compiler $COMP + if [ $? -ne 0 ]; then if [ ! -z "$CXX" ]; then - if [ $COMP = $CXX ]; then - echo "$CC is not a working C++ Compiler" - TOOLCHAIN_DETECTION_ERROR="error" - break - fi + if [ $COMP = $CXX ]; then + echo "$CC is not a working C++ Compiler" + TOOLCHAIN_DETECTION_ERROR="error" + break + fi fi - else - if [ $COMP = "CC" ]; then - # we have found a working compiler, but in case - # the compiler is gcc or clang, we try to use - # these commands and not 'cc' - TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` - if [ $TOOLCHAIN_NAME = "gcc" ]; then - check_cpp_compiler "g++" - if [ $? -eq 0 ]; then - COMP=g++ - fi - fi - if [ $TOOLCHAIN_NAME = "clang" ]; then - check_cpp_compiler "clang++" - if [ $? -eq 0 ]; then - COMP=clang++ - fi - fi + else + if [ $COMP = "CC" ]; then + # we have found a working compiler, but in case + # the compiler is gcc or clang, we try to use + # these commands and not 'cc' + TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` + USE_TOOLCHAIN=$TOOLCHAIN_NAME + if [ $TOOLCHAIN_NAME = "gcc" ]; then + check_cpp_compiler "g++" + if [ $? -eq 0 ]; then + COMP=g++ + USE_TOOLCHAIN="gcc" + fi + fi + if [ $TOOLCHAIN_NAME = "clang" ]; then + check_cpp_compiler "clang++" + if [ $? -eq 0 ]; then + COMP=clang++ + USE_TOOLCHAIN="clang" + fi + fi fi - TOOLCHAIN_NAME=`$TEMP_DIR/checkcc` - TOOLCHAIN_CXX=$COMP - echo $COMP - break - fi + TOOLCHAIN_NAME=$USE_TOOLCHAIN + TOOLCHAIN_CXX=$COMP + echo $COMP + break + fi done if [ -z $TOOLCHAIN_CXX ]; then - echo "not found" + echo "not found" fi TOOLCHAIN_LD=$TOOLCHAIN_CC if [ -z "$TOOLCHAIN_NAME" ]; then - TOOLCHAIN_DETECTION_ERROR="error" + TOOLCHAIN_DETECTION_ERROR="error" else - cat >> $TEMP_DIR/config.mk << __EOF__ + cat >> $TEMP_DIR/config.mk << __EOF__ # toolchain __EOF__ echo "CC = ${TOOLCHAIN_CC}" >> $TEMP_DIR/config.mk if [ ! -z "$TOOLCHAIN_CXX" ]; then echo "CXX = ${TOOLCHAIN_CXX}" >> $TEMP_DIR/config.mk fi - echo "LD = ${TOOLCHAIN_LD}" >> $TEMP_DIR/config.mk - + echo "LD = ${TOOLCHAIN_LD}" >> $TEMP_DIR/config.mk + echo >> $TEMP_DIR/config.mk + cat "make/${TOOLCHAIN_NAME}.mk" > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "include \$(BUILD_ROOT)/make/${TOOLCHAIN_NAME}.mk" >> $TEMP_DIR/config.mk - fi + if [ $? -eq 0 ]; then + echo "include \$(BUILD_ROOT)/make/${TOOLCHAIN_NAME}.mk" >> $TEMP_DIR/config.mk + else + echo "SHLIB_CFLAGS = -fPIC" >> $TEMP_DIR/config.mk + echo "SHLIB_LDFLAGS = -shared" >> $TEMP_DIR/config.mk + fi fi