From 2a8b9425516302889b8400fd9d3f636b66c59fc2 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 26 Jan 2021 12:10:02 +0100
Subject: [PATCH] BUILD: Update configure script to really checks for libs and
 display a more comprehensible config log

---
 configure                 | 101 +++++++++++++++++++++++---------------
 configure.ac              |  91 +++++++++++++++++++++++-----------
 inc/lektor/lktconfig.h.in |  15 ------
 3 files changed, 124 insertions(+), 83 deletions(-)

diff --git a/configure b/configure
index aba6d813..07c279c8 100755
--- a/configure
+++ b/configure
@@ -2469,11 +2469,6 @@ $as_echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
-as_fn_append ac_header_list " sqlite3.h"
-as_fn_append ac_header_list " curl/curl.h"
-as_fn_append ac_header_list " json-c/json.h"
-as_fn_append ac_header_list " SDL.h"
-as_fn_append ac_header_list " mpv/client.h"
 as_fn_append ac_header_list " stdnoreturn.h"
 as_fn_append ac_header_list " stddef.h"
 as_fn_append ac_header_list " inttypes.h"
@@ -4054,16 +4049,6 @@ done
 
 
 
-
-
-
-
-
-
-
-
-
-
 
 
 
@@ -18433,7 +18418,7 @@ _ACEOF
 
 
 
-LKT_BUILD_STRING="$(basename $CC) $(uname -r) $(uname -m)"
+LKT_BUILD_STRING="$(basename $CC)/$(basename $CXX) $(uname -s) $(uname -p) $(uname -r) $(uname -m)"
 
 cat >>confdefs.h <<_ACEOF
 #define LKT_BUILD_STRING "$LKT_BUILD_STRING"
@@ -18535,6 +18520,36 @@ fi
     done
 
 
+
+    # Update path
+    PATH="$PWD/depends_install/bin:$PATH"
+fi
+
+LKT_SDL2_VERSION="sdl2 `sdl2-config --version`"
+if test $? -ne 0 ; then
+    as_fn_error $? "Faield to get sdl2 version, is sdl2 installed?" "$LINENO" 5
+fi
+
+LKT_CURL_VERSION=`curl-config --version`
+if test $? -ne 0 ; then
+    as_fn_error $? "Faield to get libcurl version, is libcurl installed?" "$LINENO" 5
+fi
+
+pkg-config --exists mpv 2>/dev/null 1>&2
+if test $? -ne 0 ; then
+    as_fn_error $? "Faield to get libmpv with pkg-config, is libmpv installed?" "$LINENO" 5
+fi
+
+LKT_SQLITE_VERSION=`sqlite3 --version | cut -d' ' -f1`
+if ! test `echo "$LKT_SQLITE_VERSION" | cut -d. -f1` = "3" ; then
+    as_fn_error $? "You need sqlite 3 for lektor" "$LINENO" 5
+fi
+if ! test `echo "$LKT_SQLITE_VERSION" | cut -d. -f2` -gt 31 ; then
+    as_fn_error $? "You need at least sqlite 3.31.0 for lektor" "$LINENO" 5
+fi
+pkg-config --exists sqlite3
+if test $? -ne 0 ; then
+    as_fn_error $? "Faield to get sqlite3 with pkg-config, is dev lib for sqlite3 installed?" "$LINENO" 5
 fi
 
 ##########
@@ -21136,35 +21151,43 @@ cd $LKT_PATH_BUILD
 LKT_CONFIG_RESULT="
 ########## Lektor configuration ###########
 #
-# Configure run on..... $(date)
-# Compiler C........... $(basename $CC)
-# Version.............. mk7.$AFF_VERSION
-# Branch............... $AFF_BRANCH
-# Last tag............. $AFF_LASTTAG
+# Configure run on......... $(date)
+# Compiler C............... $(basename $CC) ($(which $CC))
+# Configure time Version... mk7.$AFF_VERSION
+# Configure time Branch.... $AFF_BRANCH
+# Configure time Last tag.. $AFF_LASTTAG
 #
 ### Build options
 #
-# Modules.............. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static)
-# C Flags.............. $CFLAGS
-# LD Flags............. $LDFLAGS
-# To link against...... -Wl,-rpath -Wl,$prefix/lib
-# Builtin depends...... $LKT_BUILD_DEPENDS
-# Builtin libraries.... $AFF_BUILTINS
-# LibLektor............ $LKT_STATIC_LIB
-# Build Klkt........... $LKT_KLKT
-# Qt libraries......... $QT_REQUIREMENTS
-# Qt LDFLAGS........... $QT_LDFLAGS
-# Qt CPPFLAGS.......... $QT_CPPFLAGS
-# Qt LIBS.............. $QT_LIBS
+# Modules.................. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static)
+# C Flags.................. $CFLAGS
+# LD Flags................. $LDFLAGS
+# To link against.......... -Wl,-rpath -Wl,$prefix/lib
+# Builtin depends.......... $LKT_BUILD_DEPENDS
+# Builtin libraries........ $AFF_BUILTINS
+# LibLektor................ $LKT_STATIC_LIB
+# Build Klkt............... $LKT_KLKT
+#
+### Qt options (needed only for klkt)
+#
+# Compiler C++............. $(basename $CXX) ($(which $CXX))
+# QMake.................... $(basename $QMAKE) ($QMAKE)
+# MOC...................... $(basename $MOC) ($MOC)
+# RCC...................... $(basename $RCC) ($RCC)
+# UIC...................... $(basename $UIC) ($UIC)
+# Qt libraries............. $QT_REQUIREMENTS
+# Qt LDFLAGS............... $QT_LDFLAGS
+# Qt CPPFLAGS.............. $QT_CPPFLAGS
+# Qt LIBS.................. $QT_LIBS
 #
 ### Other informations
 #
-# Build string......... $LKT_BUILD_STRING
-# Debug enabled........ $LKT_DEBUG_ENABLED
-# Prefix............... $prefix
-# Build folder......... $PWD
-# Source folder........ $LKT_PATH_SOURCE
-# Endiannes............ $(test $LKT_ENDIANES_LITTLE = 1 && echo little || echo big)
+# Build string............. $LKT_BUILD_STRING
+# Debug enabled............ $LKT_DEBUG_ENABLED
+# Prefix................... $prefix
+# Build folder............. $PWD
+# Source folder............ $LKT_PATH_SOURCE
+# Endiannes................ $(test $LKT_ENDIANES_LITTLE = 1 && echo little || echo big)
 #
 ###########################################
 "
diff --git a/configure.ac b/configure.ac
index f6c03489..61de0409 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,11 +20,6 @@ AC_SUBST([LKT_PATH_SOURCE])
 AC_SUBST([LKT_PATH_BUILD])
 
 AC_CHECK_HEADERS_ONCE([
-    sqlite3.h
-    curl/curl.h
-    json-c/json.h
-    SDL.h
-    mpv/client.h
     stdnoreturn.h
     stddef.h
     inttypes.h
@@ -200,7 +195,7 @@ AC_SUBST([LKT_MAN_BINARY])
 AC_DEFINE_UNQUOTED([LKT_COMPILER], ["$CC"], [Lektor compiled with])
 AC_SUBST([LKT_COMPILER])
 
-LKT_BUILD_STRING="$(basename $CC) $(uname -r) $(uname -m)"
+LKT_BUILD_STRING="$(basename $CC)/$(basename $CXX) $(uname -s) $(uname -p) $(uname -r) $(uname -m)"
 AC_DEFINE_UNQUOTED([LKT_BUILD_STRING], ["$LKT_BUILD_STRING"], [Build string])
 AC_SUBST([LKT_BUILD_STRING])
 
@@ -253,6 +248,36 @@ if test "x$LKT_BUILD_DEPENDS" = "xyes" ; then
     done
     AC_SUBST([LKT_LIB_LINK])
     AC_SUBST([LKT_LIB_DIR])
+
+    # Update path
+    PATH="$PWD/depends_install/bin:$PATH"
+fi
+
+LKT_SDL2_VERSION="sdl2 `sdl2-config --version`"
+if test $? -ne 0 ; then
+    AC_MSG_ERROR([Faield to get sdl2 version, is sdl2 installed?])
+fi
+
+LKT_CURL_VERSION=`curl-config --version`
+if test $? -ne 0 ; then
+    AC_MSG_ERROR([Faield to get libcurl version, is libcurl installed?])
+fi
+
+pkg-config --exists mpv 2>/dev/null 1>&2
+if test $? -ne 0 ; then
+    AC_MSG_ERROR([Faield to get libmpv with pkg-config, is libmpv installed?])
+fi
+
+LKT_SQLITE_VERSION=`sqlite3 --version | cut -d' ' -f1`
+if ! test `echo "$LKT_SQLITE_VERSION" | cut -d. -f1` = "3" ; then
+    AC_MSG_ERROR([You need sqlite 3 for lektor])
+fi
+if ! test `echo "$LKT_SQLITE_VERSION" | cut -d. -f2` -gt 31 ; then
+    AC_MSG_ERROR([You need at least sqlite 3.31.0 for lektor])
+fi
+pkg-config --exists sqlite3
+if test $? -ne 0 ; then
+    AC_MSG_ERROR([Faield to get sqlite3 with pkg-config, is dev lib for sqlite3 installed?])
 fi
 
 ##########
@@ -286,35 +311,43 @@ cd $LKT_PATH_BUILD
 LKT_CONFIG_RESULT="
 ########## Lektor configuration ###########
 #
-# Configure run on..... $(date)
-# Compiler C........... $(basename $CC)
-# Version.............. mk7.$AFF_VERSION
-# Branch............... $AFF_BRANCH
-# Last tag............. $AFF_LASTTAG
+# Configure run on......... $(date)
+# Compiler C............... $(basename $CC) ($(which $CC))
+# Configure time Version... mk7.$AFF_VERSION
+# Configure time Branch.... $AFF_BRANCH
+# Configure time Last tag.. $AFF_LASTTAG
 #
 ### Build options
 #
-# Modules.............. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static)
-# C Flags.............. $CFLAGS
-# LD Flags............. $LDFLAGS
-# To link against...... -Wl,-rpath -Wl,$prefix/lib
-# Builtin depends...... $LKT_BUILD_DEPENDS
-# Builtin libraries.... $AFF_BUILTINS
-# LibLektor............ $LKT_STATIC_LIB
-# Build Klkt........... $LKT_KLKT
-# Qt libraries......... $QT_REQUIREMENTS
-# Qt LDFLAGS........... $QT_LDFLAGS
-# Qt CPPFLAGS.......... $QT_CPPFLAGS
-# Qt LIBS.............. $QT_LIBS
+# Modules.................. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static)
+# C Flags.................. $CFLAGS
+# LD Flags................. $LDFLAGS
+# To link against.......... -Wl,-rpath -Wl,$prefix/lib
+# Builtin depends.......... $LKT_BUILD_DEPENDS
+# Builtin libraries........ $AFF_BUILTINS
+# LibLektor................ $LKT_STATIC_LIB
+# Build Klkt............... $LKT_KLKT
+#
+### Qt options (needed only for klkt)
+#
+# Compiler C++............. $(basename $CXX) ($(which $CXX))
+# QMake.................... $(basename $QMAKE) ($QMAKE)
+# MOC...................... $(basename $MOC) ($MOC)
+# RCC...................... $(basename $RCC) ($RCC)
+# UIC...................... $(basename $UIC) ($UIC)
+# Qt libraries............. $QT_REQUIREMENTS
+# Qt LDFLAGS............... $QT_LDFLAGS
+# Qt CPPFLAGS.............. $QT_CPPFLAGS
+# Qt LIBS.................. $QT_LIBS
 #
 ### Other informations
 #
-# Build string......... $LKT_BUILD_STRING
-# Debug enabled........ $LKT_DEBUG_ENABLED
-# Prefix............... $prefix
-# Build folder......... $PWD
-# Source folder........ $LKT_PATH_SOURCE
-# Endiannes............ $(test $LKT_ENDIANES_LITTLE = 1 && echo little || echo big)
+# Build string............. $LKT_BUILD_STRING
+# Debug enabled............ $LKT_DEBUG_ENABLED
+# Prefix................... $prefix
+# Build folder............. $PWD
+# Source folder............ $LKT_PATH_SOURCE
+# Endiannes................ $(test $LKT_ENDIANES_LITTLE = 1 && echo little || echo big)
 #
 ###########################################
 "
diff --git a/inc/lektor/lktconfig.h.in b/inc/lektor/lktconfig.h.in
index e0b16986..d4ed6f07 100644
--- a/inc/lektor/lktconfig.h.in
+++ b/inc/lektor/lktconfig.h.in
@@ -3,9 +3,6 @@
 /* Define to 1 if you have the <ctypes.h> header file. */
 #undef HAVE_CTYPES_H
 
-/* Define to 1 if you have the <curl/curl.h> header file. */
-#undef HAVE_CURL_CURL_H
-
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -15,27 +12,15 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the <json-c/json.h> header file. */
-#undef HAVE_JSON_C_JSON_H
-
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the <mpv/client.h> header file. */
-#undef HAVE_MPV_CLIENT_H
-
 /* Define to 1 if you have the <regex.h> header file. */
 #undef HAVE_REGEX_H
 
-/* Define to 1 if you have the <SDL.h> header file. */
-#undef HAVE_SDL_H
-
-/* Define to 1 if you have the <sqlite3.h> header file. */
-#undef HAVE_SQLITE3_H
-
 /* Define to 1 if you have the <stdargs.h> header file. */
 #undef HAVE_STDARGS_H
 
-- 
GitLab