Fix FTBFS on missing magic_getpath

(cherry picked from commit 03a61295af)
v3.5.13-sru
Slávek Banko 10 years ago
parent 6a26452382
commit 3138567410

@ -549,6 +549,26 @@ if( NOT HAVE_LIBDL )
endif( NOT HAVE_LIBDL )
##### check for magic ###########################
set( MAGIC_LIBRARIES magic )
check_library_exists( ${MAGIC_LIBRARIES} magic_load "" HAVE_LIBMAGIC )
if( HAVE_LIBMAGIC )
check_library_exists( ${MAGIC_LIBRARIES} magic_getpath "" HAVE_LIBMAGIC_GETPATH )
if( NOT HAVE_LIBMAGIC_GETPATH )
execute_process(
COMMAND file --version
OUTPUT_VARIABLE LIBMAGIC_VERSION
ERROR_VARIABLE LIBMAGIC_VERSION
)
string(REGEX REPLACE ".*magic file from ([^ \n]*).*" "\\1" LIBMAGIC_PATH ${LIBMAGIC_VERSION} )
message( STATUS "libmagick default path ${LIBMAGIC_PATH}" )
endif( NOT HAVE_LIBMAGIC_GETPATH )
else( HAVE_LIBMAGIC )
tde_message_fatal( "libmagic is required, but not found on your system" )
endif( HAVE_LIBMAGIC )
##### check for utempter ########################
if( WITH_UTEMPTER )

@ -902,6 +902,12 @@
/* Defined if compiling without arts */
#cmakedefine WITHOUT_ARTS 1
/* Defined if libmagic contain magic_getpath function */
#cmakedefine HAVE_LIBMAGIC_GETPATH 1
/* Define default path for libmagick files */
#cmakedefine LIBMAGIC_PATH "@LIBMAGIC_PATH@"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD

@ -115,5 +115,5 @@ endif( USE_POSIX_ACL )
tde_add_library( ${target} STATIC_PIC AUTOMOC
SOURCES ${${target}_SRCS}
LINK magic ${GAMIN_LIBRARIES}
LINK ${MAGIC_LIBRARIES} ${GAMIN_LIBRARIES}
)

@ -165,3 +165,25 @@ if test "x$kde_enable_inotify" = "xyes"; then
AC_MSG_RESULT(no)
fi
fi
dnl ------------------------------------------------------------------------
dnl Try to find if libmagic is installed and contains magic_getpath
dnl ------------------------------------------------------------------------
dnl
AC_MSG_CHECKING([for libmagic])
KDE_CHECK_LIB(magic, magic_load, kde_have_libmagic=yes, kde_have_libmagic=no)
if test $kde_have_libmagic = yes; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([for libmagic - magic_getpath])
KDE_CHECK_LIB(magic, magic_getpath, kde_have_libmagic_getpath=yes, kde_have_libmagic_getpath=no)
if test $kde_have_libmagic_getpath = yes; then
AC_DEFINE_UNQUOTED(HAVE_LIBMAGIC_GETPATH, 1, [Defined if libmagic contain magic_getpath function])
AC_MSG_RESULT(yes)
else
libmagic_path=`file --version 2>&1 | sed -n "s/^magic file from //p"`
AC_DEFINE_UNQUOTED(LIBMAGIC_PATH, $libmagic_path, [Define default path for libmagic files])
AC_MSG_RESULT(no)
fi
else
AC_MSG_RESULT(no)
fi

@ -20,6 +20,7 @@
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "kmimemagic.h"
#include <kdebug.h>
#include <kapplication.h>
@ -164,7 +165,11 @@ struct config_rec {
int KMimeMagic::apprentice( const TQString& magicfile ) {
TQString maindatabase = magicfile;
if (maindatabase == "") {
#ifdef HAVE_LIBMAGIC_GETPATH
maindatabase = magic_getpath(0, FILE_LOAD);
#else
maindatabase = TQString(LIBMAGIC_PATH);
#endif
}
conf->databases.clear();
conf->databases.append(maindatabase);

Loading…
Cancel
Save