2015-01-27 19:31:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e # abort on error
|
2018-12-19 22:18:24 +01:00
|
|
|
#set -x # be verbose
|
2015-01-27 19:31:41 +01:00
|
|
|
|
2022-05-10 13:03:58 +02:00
|
|
|
function exit_if_strict {
|
|
|
|
if [ -n "${STRICT}" ] && [ "${STRICT}" -eq 1 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "Checking for pkg-config..."
|
|
|
|
if pkg-config --version; then
|
|
|
|
HAS_PKG_CONFIG=1
|
|
|
|
echo "pkg-config found."
|
|
|
|
else
|
|
|
|
HAS_PKG_CONFIG=0
|
|
|
|
echo "pkg-config is not available, skipping all syntax checks."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2015-01-27 19:31:41 +01:00
|
|
|
fi
|
|
|
|
|
2022-04-20 17:27:12 +02:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/
|
|
|
|
CPPCHECK="$DIR"../../cppcheck
|
2022-05-10 13:03:58 +02:00
|
|
|
CFG="$DIR"../../cfg/
|
2022-04-20 17:27:12 +02:00
|
|
|
|
2015-08-10 23:44:36 +02:00
|
|
|
# Cppcheck options
|
2023-01-26 22:28:04 +01:00
|
|
|
CPPCHECK_OPT='--check-library --platform=unix64 --enable=style --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
|
2015-08-10 23:44:36 +02:00
|
|
|
|
2015-08-10 22:58:46 +02:00
|
|
|
# Compiler settings
|
|
|
|
CXX=g++
|
2023-02-05 18:10:08 +01:00
|
|
|
CXX_OPT='-fsyntax-only -std=c++2a -Wno-format -Wno-format-security -Wno-deprecated-declarations'
|
2015-08-10 22:58:46 +02:00
|
|
|
CC=gcc
|
2022-06-04 19:33:56 +02:00
|
|
|
CC_OPT='-Wno-format -Wno-stringop-overread -Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -Wno-nonnull -fsyntax-only'
|
2015-08-10 22:58:46 +02:00
|
|
|
|
2022-04-20 17:27:12 +02:00
|
|
|
function get_pkg_config_cflags {
|
|
|
|
set +e
|
2023-01-07 23:29:47 +01:00
|
|
|
PKGCONFIG=$(pkg-config --cflags "$@")
|
2022-04-20 17:27:12 +02:00
|
|
|
PKGCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
PKGCONFIG=
|
|
|
|
else
|
|
|
|
# make sure the config is not empty when no flags were found - happens with e.g. libssl and sqlite3
|
|
|
|
if [ -z "$PKGCONFIG" ]; then
|
|
|
|
PKGCONFIG=" "
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "$PKGCONFIG"
|
|
|
|
}
|
|
|
|
|
2015-01-30 06:43:40 +01:00
|
|
|
# posix.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function posix_fn {
|
|
|
|
${CC} ${CC_OPT} ${DIR}posix.c
|
|
|
|
}
|
2015-02-16 22:19:51 +01:00
|
|
|
|
|
|
|
# gnu.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function gnu_fn {
|
|
|
|
${CC} ${CC_OPT} -D_GNU_SOURCE ${DIR}gnu.c
|
|
|
|
}
|
2015-08-10 23:44:36 +02:00
|
|
|
|
2017-04-18 18:04:27 +02:00
|
|
|
# qt.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function qt_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
2023-01-07 23:29:47 +01:00
|
|
|
QTCONFIG=$(get_pkg_config_cflags Qt5Core Qt5Test)
|
2022-04-20 17:27:12 +02:00
|
|
|
if [ -n "$QTCONFIG" ]; then
|
2023-01-07 23:29:47 +01:00
|
|
|
QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test)
|
2022-04-20 17:27:12 +02:00
|
|
|
[[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC"
|
|
|
|
set +e
|
|
|
|
echo -e "#include <QString>" | ${CXX} ${CXX_OPT} ${QTCONFIG} -x c++ -
|
|
|
|
QTCHECK_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $QTCHECK_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "Qt not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "Qt found and working, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} ${QTCONFIG} ${DIR}qt.cpp
|
|
|
|
fi
|
2019-01-07 14:40:21 +01:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "Qt not present, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-01-07 14:40:21 +01:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2017-04-18 18:04:27 +02:00
|
|
|
|
2018-05-30 16:47:00 +02:00
|
|
|
# bsd.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function bsd_fn {
|
|
|
|
true
|
|
|
|
}
|
2018-05-30 16:47:00 +02:00
|
|
|
|
2015-08-10 23:44:36 +02:00
|
|
|
# std.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function std_c_fn {
|
|
|
|
${CC} ${CC_OPT} ${DIR}std.c
|
|
|
|
}
|
|
|
|
|
|
|
|
# std.cpp
|
|
|
|
function std_cpp_fn {
|
|
|
|
${CXX} ${CXX_OPT} ${DIR}std.cpp
|
|
|
|
}
|
2015-01-30 06:43:40 +01:00
|
|
|
|
2018-01-24 20:05:16 +01:00
|
|
|
# windows.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function windows_fn {
|
|
|
|
# TODO: Syntax check via g++ does not work because it can not find a valid windows.h
|
|
|
|
#${CXX} ${CXX_OPT} ${DIR}windows.cpp
|
|
|
|
true
|
|
|
|
}
|
2018-02-06 15:33:45 +01:00
|
|
|
|
|
|
|
# wxwidgets.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function wxwidgets_fn {
|
2018-02-09 20:34:15 +01:00
|
|
|
set +e
|
2022-04-20 17:27:12 +02:00
|
|
|
WXCONFIG=$(wx-config --cxxflags)
|
|
|
|
WXCONFIG_RETURNCODE=$?
|
2018-02-09 20:34:15 +01:00
|
|
|
set -e
|
2022-04-20 17:27:12 +02:00
|
|
|
if [ $WXCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "wx-config does not work, skipping syntax check for wxWidgets tests."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2018-02-09 20:34:15 +01:00
|
|
|
else
|
2018-03-10 11:22:10 +01:00
|
|
|
set +e
|
2022-04-20 17:27:12 +02:00
|
|
|
echo -e "#include <wx/filefn.h>\n#include <wx/app.h>\n#include <wx/artprov.h>\n#include <wx/version.h>\n#if wxVERSION_NUMBER<2950\n#error \"Old version\"\n#endif" | ${CXX} ${CXX_OPT} ${WXCONFIG} -x c++ -
|
|
|
|
WXCHECK_RETURNCODE=$?
|
2018-03-10 11:22:10 +01:00
|
|
|
set -e
|
2022-04-20 17:27:12 +02:00
|
|
|
if [ $WXCHECK_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "wxWidgets not completely present (with GUI classes) or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "wxWidgets found, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} ${WXCONFIG} -Wno-deprecated-declarations ${DIR}wxwidgets.cpp
|
|
|
|
fi
|
2018-03-10 11:22:10 +01:00
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# gtk.c
|
|
|
|
function gtk_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
GTKCONFIG=$(get_pkg_config_cflags gtk+-3.0)
|
|
|
|
if [ -z "$GTKCONFIG" ]; then
|
|
|
|
GTKCONFIG=$(get_pkg_config_cflags gtk+-2.0)
|
|
|
|
fi
|
|
|
|
if [ -n "$GTKCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <gtk/gtk.h>" | ${CC} ${CC_OPT} ${GTKCONFIG} -x c -
|
|
|
|
GTKCHECK_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $GTKCHECK_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "GTK+ not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "GTK+ found and working, checking syntax with ${CXX} now."
|
|
|
|
${CC} ${CC_OPT} ${GTKCONFIG} ${DIR}gtk.c
|
|
|
|
fi
|
2018-03-10 11:22:10 +01:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "GTK+ not present, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2018-03-10 11:22:10 +01:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2018-07-12 08:40:26 +02:00
|
|
|
|
2019-01-08 20:30:21 +01:00
|
|
|
# boost.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function boost_fn {
|
2019-03-13 13:57:40 +01:00
|
|
|
set +e
|
2022-04-20 17:27:12 +02:00
|
|
|
echo -e "#include <boost/config.hpp>" | ${CXX} ${CXX_OPT} -x c++ -
|
|
|
|
BOOSTCHECK_RETURNCODE=$?
|
2019-03-13 13:57:40 +01:00
|
|
|
set -e
|
2022-04-20 17:27:12 +02:00
|
|
|
if [ ${BOOSTCHECK_RETURNCODE} -ne 0 ]; then
|
|
|
|
echo "Boost not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "Boost found and working, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} ${DIR}boost.cpp
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# sqlite3.c
|
|
|
|
function sqlite3_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
SQLITE3CONFIG=$(get_pkg_config_cflags sqlite3)
|
|
|
|
if [ -n "$SQLITE3CONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <sqlite3.h>" | ${CC} ${CC_OPT} ${SQLITE3CONFIG} -x c -
|
|
|
|
SQLITE3CHECK_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $SQLITE3CHECK_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "SQLite3 not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "SQLite3 found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${SQLITE3CONFIG} ${DIR}sqlite3.c
|
|
|
|
fi
|
2019-03-13 13:57:40 +01:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "SQLite3 not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-03-13 13:57:40 +01:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-03-13 13:57:40 +01:00
|
|
|
|
2019-07-05 03:00:52 +02:00
|
|
|
# openmp.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function openmp_fn {
|
|
|
|
${CC} ${CC_OPT} -fopenmp ${DIR}openmp.c
|
|
|
|
}
|
2019-07-05 03:00:52 +02:00
|
|
|
|
2019-08-24 10:17:23 +02:00
|
|
|
# python.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function python_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
PYTHON3CONFIG=$(get_pkg_config_cflags python3)
|
|
|
|
if [ -n "$PYTHON3CONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <Python.h>" | ${CC} ${CC_OPT} ${PYTHON3CONFIG} -x c -
|
|
|
|
PYTHON3CONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $PYTHON3CONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "Python 3 not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "Python 3 found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${PYTHON3CONFIG} ${DIR}python.c
|
|
|
|
fi
|
2019-08-24 10:17:23 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "Python 3 not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-08-24 10:17:23 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-08-24 10:17:23 +02:00
|
|
|
|
2019-08-29 11:38:21 +02:00
|
|
|
# lua.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function lua_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
|
|
|
|
if [ -n "$LUACONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <lua.h>" | ${CC} ${CC_OPT} ${LUACONFIG} -x c -
|
|
|
|
LUACONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $LUACONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "Lua not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "Lua found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${LUACONFIG} ${DIR}lua.c
|
|
|
|
fi
|
2019-08-29 11:38:21 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "Lua not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-08-29 11:38:21 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-08-29 11:38:21 +02:00
|
|
|
|
2019-08-29 15:11:59 +02:00
|
|
|
# libcurl.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function libcurl_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
LIBCURLCONFIG=$(get_pkg_config_cflags libcurl)
|
|
|
|
if [ -n "$LIBCURLCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <curl/curl.h>" | ${CC} ${CC_OPT} ${LIBCURLCONFIG} -x c -
|
|
|
|
LIBCURLCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $LIBCURLCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "libcurl not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "libcurl found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${LIBCURLCONFIG} ${DIR}libcurl.c
|
|
|
|
fi
|
2019-08-29 15:11:59 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "libcurl not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-08-29 15:11:59 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-08-29 15:11:59 +02:00
|
|
|
|
2019-09-19 08:48:04 +02:00
|
|
|
# cairo.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function cairo_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
CAIROCONFIG=$(get_pkg_config_cflags cairo)
|
|
|
|
if [ -n "$CAIROCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <cairo.h>" | ${CC} ${CC_OPT} ${CAIROCONFIG} -x c -
|
|
|
|
CAIROCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $CAIROCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "cairo not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "cairo found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${CAIROCONFIG} ${DIR}cairo.c
|
|
|
|
fi
|
2019-09-19 08:48:04 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "cairo not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-09-19 08:48:04 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-09-19 08:48:04 +02:00
|
|
|
|
2022-04-20 17:27:12 +02:00
|
|
|
# googletest.cpp
|
|
|
|
function googletest_fn {
|
|
|
|
true
|
|
|
|
}
|
2019-10-09 19:53:58 +02:00
|
|
|
|
2019-10-17 21:29:32 +02:00
|
|
|
# kde.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function kde_fn {
|
2019-10-17 21:29:32 +02:00
|
|
|
set +e
|
2022-04-20 17:27:12 +02:00
|
|
|
KDECONFIG=$(kde4-config --path include)
|
|
|
|
KDECONFIG_RETURNCODE=$?
|
2019-10-17 21:29:32 +02:00
|
|
|
set -e
|
2022-04-20 17:27:12 +02:00
|
|
|
if [ $KDECONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "kde4-config does not work, skipping syntax check."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-10-17 21:29:32 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
KDEQTCONFIG=$(get_pkg_config_cflags QtCore)
|
|
|
|
if [ -n "$KDEQTCONFIG" ]; then
|
|
|
|
echo "Suitable Qt not present, Qt is necessary for KDE. Skipping syntax check."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-10-17 21:29:32 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
set +e
|
|
|
|
echo -e "#include <KDE/KGlobal>\n" | ${CXX} ${CXX_OPT} -I${KDECONFIG} ${KDEQTCONFIG} -x c++ -
|
|
|
|
KDECHECK_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $KDECHECK_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "KDE headers not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "KDE found, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} -I${KDECONFIG} ${KDEQTCONFIG} ${DIR}kde.cpp
|
|
|
|
fi
|
2019-10-17 21:29:32 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-10-17 21:29:32 +02:00
|
|
|
|
2019-10-26 17:37:14 +02:00
|
|
|
# libsigc++.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function libsigcpp_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
LIBSIGCPPCONFIG=$(get_pkg_config_cflags sigc++-2.0)
|
|
|
|
if [ -n "$LIBSIGCPPCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <sigc++/sigc++.h>\n" | ${CXX} ${CXX_OPT} ${LIBSIGCPPCONFIG} -x c++ -
|
|
|
|
LIBSIGCPPCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $LIBSIGCPPCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "libsigc++ not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "libsigc++ found and working, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} ${LIBSIGCPPCONFIG} ${DIR}libsigc++.cpp
|
|
|
|
fi
|
2019-10-26 17:37:14 +02:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "libsigc++ not present, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-10-26 17:37:14 +02:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-10-26 17:37:14 +02:00
|
|
|
|
2019-10-31 09:21:08 +01:00
|
|
|
# openssl.c
|
2022-04-20 17:27:12 +02:00
|
|
|
function openssl_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
OPENSSLCONFIG=$(get_pkg_config_cflags libssl)
|
|
|
|
if [ -n "$OPENSSLCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <openssl/ssl.h>" | ${CC} ${CC_OPT} ${OPENSSLCONFIG} -x c -
|
|
|
|
OPENSSLCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $OPENSSLCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "OpenSSL not completely present or not working, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "OpenSSL found and working, checking syntax with ${CC} now."
|
|
|
|
${CC} ${CC_OPT} ${OPENSSLCONFIG} ${DIR}openssl.c
|
|
|
|
fi
|
2019-10-31 09:21:08 +01:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "OpenSSL not present, skipping syntax check with ${CC}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-10-31 09:21:08 +01:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-10-31 09:21:08 +01:00
|
|
|
|
2019-12-10 19:34:30 +01:00
|
|
|
# opencv2.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function opencv2_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
OPENCVCONFIG=$(get_pkg_config_cflags opencv)
|
|
|
|
if [ -n "$OPENCVCONFIG" ]; then
|
|
|
|
set +e
|
|
|
|
echo -e "#include <opencv2/opencv.hpp>\n" | ${CXX} ${CXX_OPT} ${OPENCVCONFIG} -x c++ -
|
|
|
|
OPENCVCONFIG_RETURNCODE=$?
|
|
|
|
set -e
|
|
|
|
if [ $OPENCVCONFIG_RETURNCODE -ne 0 ]; then
|
|
|
|
echo "OpenCV not completely present or not working, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "OpenCV found and working, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} ${OPENCVCONFIG} ${DIR}opencv2.cpp
|
|
|
|
fi
|
2019-12-10 19:34:30 +01:00
|
|
|
else
|
2022-04-20 17:27:12 +02:00
|
|
|
echo "OpenCV not present, skipping syntax check with ${CXX}."
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2019-12-10 19:34:30 +01:00
|
|
|
fi
|
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
2019-12-10 19:34:30 +01:00
|
|
|
|
2020-11-04 07:48:53 +01:00
|
|
|
# cppunit.cpp
|
2022-04-20 17:27:12 +02:00
|
|
|
function cppunit_fn {
|
|
|
|
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
|
|
|
if ! pkg-config cppunit; then
|
|
|
|
echo "cppunit not found, skipping syntax check for cppunit"
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
else
|
|
|
|
echo "cppunit found, checking syntax with ${CXX} now."
|
|
|
|
${CXX} ${CXX_OPT} -Wno-deprecated-declarations ${DIR}cppunit.cpp
|
|
|
|
fi
|
2020-11-04 07:48:53 +01:00
|
|
|
fi
|
2022-04-20 17:27:12 +02:00
|
|
|
}
|
|
|
|
|
2022-12-03 15:41:11 +01:00
|
|
|
function check_file {
|
|
|
|
f=$(basename $1)
|
2022-04-20 17:27:12 +02:00
|
|
|
case $f in
|
|
|
|
boost.cpp)
|
|
|
|
boost_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=boost ${DIR}boost.cpp
|
|
|
|
;;
|
|
|
|
bsd.c)
|
|
|
|
bsd_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=bsd ${DIR}bsd.c
|
|
|
|
;;
|
|
|
|
cairo.c)
|
|
|
|
cairo_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=cairo ${DIR}cairo.c
|
|
|
|
;;
|
|
|
|
cppunit.cpp)
|
|
|
|
cppunit_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=cppunit -f ${DIR}cppunit.cpp
|
|
|
|
;;
|
|
|
|
gnu.c)
|
|
|
|
gnu_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=posix,gnu ${DIR}gnu.c
|
|
|
|
;;
|
|
|
|
googletest.cpp)
|
|
|
|
googletest_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=googletest ${DIR}googletest.cpp
|
|
|
|
;;
|
|
|
|
gtk.c)
|
|
|
|
gtk_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=gtk -f ${DIR}gtk.c
|
|
|
|
;;
|
|
|
|
kde.cpp)
|
2022-05-10 13:03:58 +02:00
|
|
|
# TODO: "kde-4config" is no longer commonly available in recent distros
|
|
|
|
#kde_fn
|
2022-04-20 17:27:12 +02:00
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=kde ${DIR}kde.cpp
|
|
|
|
;;
|
|
|
|
libcurl.c)
|
|
|
|
libcurl_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=libcurl ${DIR}libcurl.c
|
|
|
|
;;
|
|
|
|
libsigc++.cpp)
|
|
|
|
libsigcpp_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=libsigc++ ${DIR}libsigc++.cpp
|
|
|
|
;;
|
|
|
|
lua.c)
|
|
|
|
lua_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=lua ${DIR}lua.c
|
|
|
|
;;
|
|
|
|
opencv2.cpp)
|
2022-05-10 13:03:58 +02:00
|
|
|
# TODO: "opencv.pc" is not commonly available in distros
|
|
|
|
#opencv2_fn
|
2022-04-20 17:27:12 +02:00
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=opencv2 ${DIR}opencv2.cpp
|
|
|
|
;;
|
|
|
|
openmp.c)
|
|
|
|
openmp_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=openmp ${DIR}openmp.c
|
|
|
|
;;
|
|
|
|
openssl.c)
|
|
|
|
openssl_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=openssl ${DIR}openssl.c
|
|
|
|
;;
|
|
|
|
posix.c)
|
|
|
|
posix_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=posix ${DIR}posix.c
|
|
|
|
;;
|
|
|
|
python.c)
|
|
|
|
python_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --library=python ${DIR}python.c
|
|
|
|
;;
|
|
|
|
qt.cpp)
|
|
|
|
qt_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=qt ${DIR}qt.cpp
|
|
|
|
;;
|
|
|
|
sqlite3.c)
|
|
|
|
sqlite3_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=sqlite3 ${DIR}sqlite3.c
|
|
|
|
;;
|
|
|
|
std.c)
|
|
|
|
std_c_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive ${DIR}std.c
|
|
|
|
;;
|
|
|
|
std.cpp)
|
|
|
|
std_cpp_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive ${DIR}std.cpp
|
|
|
|
;;
|
|
|
|
windows.cpp)
|
|
|
|
windows_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32A --library=windows ${DIR}windows.cpp
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32W --library=windows ${DIR}windows.cpp
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win64 --library=windows ${DIR}windows.cpp
|
|
|
|
;;
|
|
|
|
wxwidgets.cpp)
|
|
|
|
wxwidgets_fn
|
|
|
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets,windows -f ${DIR}wxwidgets.cpp
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unhandled file $f"
|
2022-05-10 13:03:58 +02:00
|
|
|
exit_if_strict
|
2022-04-20 17:27:12 +02:00
|
|
|
esac
|
2022-12-03 15:41:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_files
|
|
|
|
{
|
|
|
|
for f in "$@"
|
|
|
|
do
|
|
|
|
check_file $f
|
2022-04-20 17:27:12 +02:00
|
|
|
done
|
2022-12-03 15:41:11 +01:00
|
|
|
}
|
2020-11-04 07:48:53 +01:00
|
|
|
|
2018-07-12 08:40:26 +02:00
|
|
|
# Check the syntax of the defines in the configuration files
|
2022-12-03 15:41:11 +01:00
|
|
|
function check_defines_syntax
|
|
|
|
{
|
|
|
|
if ! xmlstarlet --version; then
|
|
|
|
echo "xmlstarlet needed to extract defines, skipping defines check."
|
|
|
|
exit_if_strict
|
|
|
|
else
|
|
|
|
for configfile in ${CFG}*.cfg; do
|
|
|
|
echo "Checking defines in $configfile"
|
|
|
|
# Disable debugging output temporarily since there could be many defines
|
|
|
|
set +x
|
|
|
|
# XMLStarlet returns 1 if no elements were found which is no problem here
|
|
|
|
EXTRACTED_DEFINES=$(xmlstarlet sel -t -m '//define' -c . -n <$configfile || true)
|
|
|
|
EXTRACTED_DEFINES=$(echo "$EXTRACTED_DEFINES" | sed 's/<define name="/#define /g' | sed 's/" value="/ /g' | sed 's/"\/>//g')
|
|
|
|
echo "$EXTRACTED_DEFINES" | gcc -fsyntax-only -xc -Werror -
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
check_files "${DIR}"*.{c,cpp}
|
|
|
|
check_defines_syntax
|
2019-01-23 09:40:43 +01:00
|
|
|
else
|
2022-12-03 15:41:11 +01:00
|
|
|
check_files "$@"
|
2019-01-23 09:40:43 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo SUCCESS
|