diff --git a/configure b/configure index 1bdac87b51..5d7a948491 100755 --- a/configure +++ b/configure @@ -11,3 +11,7 @@ cat /dev/null > config.log . qb/qb.comp.sh . qb/qb.libs.sh + +. qb/qb.moc.sh + +. qb/qb.make.sh diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 1746658018..64668df0be 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -277,7 +277,7 @@ check_val '' SDL2 -lSDL2 SDL2 check_enabled QT 'Qt companion' -if [ "$HAVE_QT" != 'no' ] && [ "$HAVE_MOC" = 'yes' ]; then +if [ "$HAVE_QT" != 'no' ] && [ "$HAVE_CXX" != "no" ]; then check_pkgconf QT5CORE Qt5Core 5.2 check_pkgconf QT5GUI Qt5Gui 5.2 check_pkgconf QT5WIDGETS Qt5Widgets 5.2 @@ -594,16 +594,3 @@ fi if [ "$HAVE_V4L2" != 'no' ] && [ "$HAVE_VIDEOPROCESSOR" != 'no' ]; then HAVE_VIDEO_PROCESSOR=yes fi - -# Creates config.mk and config.h. -add_define MAKEFILE GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" -set -- $(set | grep ^HAVE_) -while [ $# -gt 0 ]; do - tmpvar="${1%=*}" - shift 1 - var="${tmpvar#HAVE_}" - vars="${vars} $var" -done -VARS="$(printf %s "$vars" | tr ' ' '\n' | $SORT)" -create_config_make config.mk $(printf %s "$VARS") -create_config_header config.h $(printf %s "$VARS") diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index 8cf94e9a20..58740d4d80 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -2,8 +2,6 @@ TEMP_C=.tmp.c TEMP_CXX=.tmp.cxx -TEMP_MOC=.moc.h -TEMP_CPP=.moc.cpp TEMP_EXE=.tmp # Checking for working C compiler @@ -105,58 +103,3 @@ echo "Checking for pkg-config ... $PKG_CONF_PATH" if [ "$PKG_CONF_PATH" = "none" ]; then die : 'Warning: pkg-config not found, package checks will fail.' fi - -# Checking for working moc -cat << EOF > "$TEMP_MOC" -#include -class Test : public QObject -{ -public: - Q_OBJECT - QTimeZone tz; -}; -EOF - -HAVE_MOC=no -if [ "$HAVE_QT" != "no" ] && [ "$HAVE_CXX" != "no" ] && [ "$PKG_CONF_PATH" != "none" ]; then - moc_works=0 - if "$PKGCONF" --exists Qt5Core; then - if [ "$MOC" ]; then - "$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 && - "$CXX" -o "$TEMP_EXE" $("$PKGCONF" --cflags --libs Qt5Core) -fPIC \ - -c "$TEMP_CPP" >/dev/null 2>&1 && - moc_works=1 - else - for moc in moc-qt5 moc; do - MOC="$(exists "$moc")" || MOC="" - if [ "$MOC" ]; then - "$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 || - continue - "$CXX" -o "$TEMP_EXE" $("$PKGCONF" --cflags --libs Qt5Core) \ - -fPIC -c "$TEMP_CPP" >/dev/null 2>&1 && { - moc_works=1 - break - } - fi - done - fi - else - MOC="" - fi - - moc_status='does not work' - if [ "$moc_works" = '1' ]; then - moc_status='works' - HAVE_MOC='yes' - elif [ -z "$MOC" ]; then - moc_status='not found' - fi - - echo "Checking for moc ... $MOC $moc_status" - - if [ "$HAVE_MOC" != 'yes' ]; then - die : 'Warning: moc not found, Qt companion support will be disabled.' - fi -fi - -rm -f -- "$TEMP_CPP" "$TEMP_EXE" "$TEMP_MOC" diff --git a/qb/qb.make.sh b/qb/qb.make.sh new file mode 100644 index 0000000000..376f011c6f --- /dev/null +++ b/qb/qb.make.sh @@ -0,0 +1,12 @@ +# Creates config.mk and config.h. +add_define MAKEFILE GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" +set -- $(set | grep ^HAVE_) +while [ $# -gt 0 ]; do + tmpvar="${1%=*}" + shift 1 + var="${tmpvar#HAVE_}" + vars="${vars} $var" +done +VARS="$(printf %s "$vars" | tr ' ' '\n' | $SORT)" +create_config_make config.mk $(printf %s "$VARS") +create_config_header config.h $(printf %s "$VARS") diff --git a/qb/qb.moc.sh b/qb/qb.moc.sh new file mode 100644 index 0000000000..4a9780281b --- /dev/null +++ b/qb/qb.moc.sh @@ -0,0 +1,55 @@ +TEMP_MOC=.moc.h +TEMP_CPP=.moc.cpp + +# Checking for working moc +cat << EOF > "$TEMP_MOC" +#include +class Test : public QObject +{ +public: + Q_OBJECT + QTimeZone tz; +}; +EOF + +HAVE_MOC=no +if [ "$HAVE_QT" = "yes" ]; then + moc_works=0 + if [ "$MOC" ]; then + "$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 && + "$CXX" -o "$TEMP_EXE" $(printf %s "$QT5CORE_CFLAGS $QT5CORE_LIBS") \ + -fPIC -c "$TEMP_CPP" >/dev/null 2>&1 && + moc_works=1 + else + for moc in moc-qt5 moc; do + MOC="$(exists "$moc")" || MOC="" + if [ "$MOC" ]; then + "$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 || + continue + "$CXX" -o "$TEMP_EXE" \ + $(printf %s "$QT5CORE_CFLAGS $QT5CORE_LIBS") \ + -fPIC -c "$TEMP_CPP" >/dev/null 2>&1 && { + moc_works=1 + break + } + fi + done + fi + + moc_status='does not work' + if [ "$moc_works" = '1' ]; then + moc_status='works' + HAVE_MOC='yes' + elif [ -z "$MOC" ]; then + moc_status='not found' + fi + + printf %s\\n "Checking for moc ... $MOC $moc_status" + + if [ "$HAVE_MOC" != 'yes' ]; then + HAVE_QT='no' + die : 'Warning: moc not found, Qt companion support will be disabled.' + fi +fi + +rm -f -- "$TEMP_CPP" "$TEMP_EXE" "$TEMP_MOC"