--- MEGAsync_ori/src/MEGASync/mega/configure.ac	Wed Mar  9 01:46:53 2022
+++ MEGAsync_patched/src/MEGASync/mega/configure.ac	Mon Feb 28 22:19:04 2022
@@ -47,7 +47,7 @@
 AC_INIT([libmega], m4_esyscmd([ grep define < include/mega/version.h | awk '{print $3}' | awk 'BEGIN { RS = "" ; FS = "\n" } {printf $1"."$2"."$3}']), [https://github.com/meganz/sdk])
 
 #override default /usr/local prefix
-AC_PREFIX_DEFAULT([/])
+AC_PREFIX_DEFAULT([/usr])
 
 # Define _GNU_SOURCE
 # AC_GNU_SOURCE
@@ -448,8 +448,8 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_cryptopp/lib"; then
-        LDFLAGS="-L$with_cryptopp/lib $LDFLAGS"
+    if test -d "$with_cryptopp/lib/amd64"; then
+        LDFLAGS="-L$with_cryptopp/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_cryptopp/include $CXXFLAGS"
         CPPFLAGS="-I$with_cryptopp/include $CPPFLAGS"
 
@@ -456,7 +456,7 @@
         AC_CHECK_HEADERS(cryptopp/cryptlib.h,
          CRYPTO_CXXFLAGS="-I$with_cryptopp/include"
          CRYPTO_CPPFLAGS="-I$with_cryptopp/include"
-         CRYPTO_LDFLAGS="-L$with_cryptopp/lib",
+         CRYPTO_LDFLAGS="-L$with_cryptopp/lib/amd64",
          AC_MSG_ERROR([cryptopp/cryptlib.h header not found or not usable])
          )
     # assume we are using crypto source directory
@@ -522,8 +522,8 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_sodium/lib"; then
-        LDFLAGS="-L$with_sodium/lib $LDFLAGS"
+    if test -d "$with_sodium/lib/amd64"; then
+        LDFLAGS="-L$with_sodium/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_sodium/include $CXXFLAGS"
         CPPFLAGS="-I$with_sodium/include $CPPFLAGS"
 
@@ -530,7 +530,7 @@
         AC_CHECK_HEADERS(sodium.h,
          SODIUM_CXXFLAGS="-I$with_sodium/include"
          SODIUM_CPPFLAGS="-I$with_sodium/include"
-         SODIUM_LDFLAGS="-L$with_sodium/lib",
+         SODIUM_LDFLAGS="-L$with_sodium/lib/amd64",
          AC_MSG_ERROR([sodium/sodium.h header not found or not usable])
          )
     # assume we are using sodium source directory
@@ -612,26 +612,26 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_pcre/lib64"; then
-        LDFLAGS="-L$with_pcre/lib64 $LDFLAGS"
-        CXXFLAGS="-I$with_pcre/include $CXXFLAGS"
-        CPPFLAGS="-I$with_pcre/include $CPPFLAGS"
+    if test -d "$with_pcre/lib/amd64"; then
+        LDFLAGS="-L$with_pcre/lib/amd64 $LDFLAGS"
+        CXXFLAGS="-I$with_pcre/include/pcre $CXXFLAGS"
+        CPPFLAGS="-I$with_pcre/include/pcre $CPPFLAGS"
 
         AC_CHECK_HEADERS(pcrecpp.h,
-         PCRE_CXXFLAGS="-I$with_pcre/include"
-         PCRE_CPPFLAGS="-I$with_pcre/include"
-         PCRE_LDFLAGS="-L$with_pcre/lib64",
+         PCRE_CXXFLAGS="-I$with_pcre/include/pcre"
+         PCRE_CPPFLAGS="-I$with_pcre/include/pcre"
+         PCRE_LDFLAGS="-L$with_pcre/lib/amd64",
          AC_MSG_ERROR([pcrecpp.h header not found or not usable])
          )
     else
-        LDFLAGS="-L$with_pcre/lib32 $LDFLAGS"
-        CXXFLAGS="-I$with_pcre/include $CXXFLAGS"
-        CPPFLAGS="-I$with_pcre/include $CPPFLAGS"
+        LDFLAGS="-L$with_pcre/lib $LDFLAGS"
+        CXXFLAGS="-I$with_pcre/include/pcre $CXXFLAGS"
+        CPPFLAGS="-I$with_pcre/include/pcre $CPPFLAGS"
 
         AC_CHECK_HEADERS(pcrecpp.h,
-         PCRE_CXXFLAGS="-I$with_pcre/include"
-         PCRE_CPPFLAGS="-I$with_pcre/include"
-         PCRE_LDFLAGS="-L$with_pcre/lib32",
+         PCRE_CXXFLAGS="-I$with_pcre/include/pcre"
+         PCRE_CPPFLAGS="-I$with_pcre/include/pcre"
+         PCRE_LDFLAGS="-L$with_pcre/lib",
          AC_MSG_ERROR([pcrecpp.h header not found or not usable])
          )
     fi
@@ -691,8 +691,8 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_libraw/lib"; then
-        LDFLAGS="-L$with_libraw/lib $LDFLAGS"
+    if test -d "$with_libraw/lib/amd64"; then
+        LDFLAGS="-L$with_libraw/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_libraw/include $CXXFLAGS"
         CPPFLAGS="-I$with_libraw/include $CPPFLAGS"
 
@@ -699,7 +699,7 @@
         AC_CHECK_HEADERS(libraw/libraw.h,
          LIBRAW_CXXFLAGS="-I$with_libraw/include"
          LIBRAW_CPPFLAGS="-I$with_libraw/include"
-         LIBRAW_LDFLAGS="-L$with_libraw/lib",
+         LIBRAW_LDFLAGS="-L$with_libraw/lib/amd64",
          AC_MSG_ERROR([libraw/libraw.h header not found or not usable])
          )
     fi
@@ -771,21 +771,21 @@
      ;;
    *)
 
-    if test -f  "$with_libuv/lib/pkgconfig/libuv.pc"; then
-        UV_LIBS=`cat $with_libuv/lib/pkgconfig/libuv.pc | grep "Libs:" | awk '{$1=""; $2=""; print $0}'`
+    if test -f  "$with_libuv/lib/amd64/pkgconfig/libuv.pc"; then
+        UV_LIBS=`cat $with_libuv/lib/amd64/pkgconfig/libuv.pc | grep "Libs:" | awk '{$1=""; $2=""; print $0}'`
     fi
 
     SAVE_LIBS=$LIBS
     # determine if library is installed
-    if test -d "$with_libuv/lib"; then
-        LIBS="-L$with_libuv/lib $UV_LIBS $LIBS" #TODO: These are actually lost: let's assume these library dependencies are included somewhere else
-        LDFLAGS="-L$with_libuv/lib $UV_LDFLAGS $LDFLAGS"
+    if test -d "$with_libuv/lib/amd64"; then
+        LIBS="-L$with_libuv/lib/amd64 $UV_LIBS $LIBS" #TODO: These are actually lost: let's assume these library dependencies are included somewhere else
+        LDFLAGS="-L$with_libuv/lib/amd64 $UV_LDFLAGS $LDFLAGS"
         CXXFLAGS="-I$with_libuv/include $UV_CXXFLAGS $CXXFLAGS"
         CPPFLAGS="-I$with_libuv/include $UV_CPPFLAGS $CPPFLAGS"
         AC_CHECK_HEADERS(uv.h,
          LIBUV_CXXFLAGS="-I$with_libuv/include"
          LIBUV_CPPFLAGS="-I$with_libuv/include"
-         LIBUV_LDFLAGS="-L$with_libuv/lib",
+         LIBUV_LDFLAGS="-L$with_libuv/lib/amd64",
          AC_MSG_ERROR([uv.h header not found or not usable])
          )
     # assume we are using libuv source directory
@@ -883,8 +883,8 @@
      ;;
    *)
 
-    if test -d "$with_zlib/lib"; then
-        LDFLAGS="-L$with_zlib/lib $LDFLAGS"
+    if test -d "$with_zlib/lib/amd64"; then
+        LDFLAGS="-L$with_zlib/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_zlib/include $CXXFLAGS"
         CPPFLAGS="-I$with_zlib/include $CPPFLAGS"
 
@@ -891,7 +891,7 @@
         AC_CHECK_HEADERS(zlib.h,
          ZLIB_CXXFLAGS="-I$with_zlib/include"
          ZLIB_CPPFLAGS="-I$with_zlib/include"
-         ZLIB_LDFLAGS="-L$with_zlib/lib",
+         ZLIB_LDFLAGS="-L$with_zlib/lib/amd64",
          AC_MSG_ERROR([zlib.h header not found or not usable])
          )
 
@@ -965,12 +965,12 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_sqlite/lib"; then
-        LDFLAGS="-L$with_sqlite/lib $LDFLAGS"
+    if test -d "$with_sqlite/lib/amd64"; then
+        LDFLAGS="-L$with_sqlite/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_sqlite/include $CXXFLAGS"
 
         AC_CHECK_HEADERS(sqlite3.h,[
-         DB_LDFLAGS="-L$with_sqlite/lib"
+         DB_LDFLAGS="-L$with_sqlite/lib/amd64"
          DB_CXXFLAGS="-I$with_sqlite/include"
          DB_CPPFLAGS="-I$with_sqlite/include"],
          AC_MSG_ERROR([sqlite3.h header not found or not usable])
@@ -1046,7 +1046,7 @@
    yes)
     #ffmpeg-mega
     AC_CHECK_HEADERS([ffmpeg-mega/libavutil/macros.h],
-       # LDFLAGS="-L$with_ffmpeg/lib $LDFLAGS"
+       # LDFLAGS="-L$with_ffmpeg/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I/usr/include/ffmpeg-mega $CXXFLAGS"
         CPPFLAGS="-I/usr/include/ffmpeg-mega $CPPFLAGS"
 
@@ -1079,7 +1079,7 @@
   [AC_MSG_RESULT([--with-ffmpeg not specified])
 
     AC_CHECK_HEADERS([ffmpeg-mega/libavutil/macros.h],
-       # LDFLAGS="-L$with_ffmpeg/lib $LDFLAGS"
+       # LDFLAGS="-L$with_ffmpeg/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I/usr/include/ffmpeg-mega $CXXFLAGS"
         CPPFLAGS="-I/usr/include/ffmpeg-mega $CPPFLAGS"
 
@@ -1139,8 +1139,8 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_libzen/lib"; then
-        LDFLAGS="-L$with_libzen/lib $LDFLAGS"
+    if test -d "$with_libzen/lib/amd64"; then
+        LDFLAGS="-L$with_libzen/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_libzen/include $CXXFLAGS"
         CPPFLAGS="-I$with_libzen/include $CPPFLAGS"
 
@@ -1147,7 +1147,7 @@
         AC_CHECK_HEADERS(ZenLib/Ztring.h,
          LIBZEN_CXXFLAGS="-I$with_libzen/include"
          LIBZEN_CPPFLAGS="-I$with_libzen/include"
-         LIBZEN_LDFLAGS="-L$with_libzen/lib",
+         LIBZEN_LDFLAGS="-L$with_libzen/lib/amd64",
          AC_MSG_ERROR([ZenLib/Ztring.h header not found or not usable])
          )
     # assume we are using libzen source directory
@@ -1233,8 +1233,8 @@
        *)
 
         # determine if library is installed
-        if test -d "$with_libmediainfo/lib"; then
-            LDFLAGS="$LIBZEN_LDFLAGS $ZLIB_LDFLAGS -L$with_libmediainfo/lib $LDFLAGS"
+        if test -d "$with_libmediainfo/lib/amd64"; then
+            LDFLAGS="$LIBZEN_LDFLAGS $ZLIB_LDFLAGS -L$with_libmediainfo/lib/amd64 $LDFLAGS"
             CXXFLAGS="$LIBZEN_CXXFLAGS $ZLIB_CXXFLAGS -I$with_libmediainfo/include $CXXFLAGS"
             CPPFLAGS="$LIBZEN_CPPFLAGS $ZLIB_CPPFLAGS  -I$with_libmediainfo/include $CPPFLAGS"
 
@@ -1241,7 +1241,7 @@
             AC_CHECK_HEADERS(MediaInfo/MediaInfo.h,
              LIBMEDIAINFO_CXXFLAGS="$LIBZEN_CXXFLAGS -I$with_libmediainfo/include"
              LIBMEDIAINFO_CPPFLAGS="$LIBZEN_CPPFLAGS -I$with_libmediainfo/include"
-             LIBMEDIAINFO_LDFLAGS="$LIBZEN_LDFLAGS -L$with_libmediainfo/lib",
+             LIBMEDIAINFO_LDFLAGS="$LIBZEN_LDFLAGS -L$with_libmediainfo/lib/amd64",
              AC_MSG_ERROR([MediaInfo/MediaInfo.h header not found or not usable])
              )
         # assume we are using libmediainfo source directory
@@ -1299,32 +1299,7 @@
      LDFLAGS="$LIBMEDIAINFO_LDFLAGS"
      CXXFLAGS="$LIBMEDIAINFO_CXXFLAGS"
      CPPFLAGS="$LIBMEDIAINFO_CPPFLAGS"
-     lmediainfo_prog='#include <iostream> 
-    #include "ZenLib/Ztring.h"
-    #include "MediaInfo/MediaInfo.h"
-    int main () { std::cout << ZenLib::Ztring(MediaInfoLib::MediaInfo::Option_Static(__T("Info_Version")).c_str()).To_Local().c_str() << std::endl; }
-    '
 
-      AC_LINK_IFELSE(
-        [AC_LANG_SOURCE($lmediainfo_prog)],
-         AC_MSG_RESULT([libmediainfo worked]),
-         #Try again with -DUNICODE
-         LIBMEDIAINFO_LDFLAGS="$LIBMEDIAINFO_LDFLAGS -DUNICODE"
-         LDFLAGS="$LIBMEDIAINFO_LDFLAGS"
-         AC_LINK_IFELSE(
-        [AC_LANG_SOURCE($lmediainfo_prog)],
-         AC_MSG_RESULT([libmediainfo worked worked with -DUNICODE])
-         AC_DEFINE(UNICODE, [1], [Define to use UNICODE (for MediaInfo)])
-         ,
-         AC_MSG_RESULT([libmediainfo failed to compile. Discarded])
-         libmediainfo=false
-         unset LIBMEDIAINFO_CXXFLAGS
-         unset LIBMEDIAINFO_CPPFLAGS
-         unset LIBMEDIAINFO_LDFLAGS
-         unset LIBMEDIAINFO_LIBS
-         )
-       )
-
       #restore
       LDFLAGS=$SAVE_LDFLAGS
       CXXFLAGS=$SAVE_CXXFLAGS
@@ -1394,10 +1369,10 @@
          ;;
        *)
         # determine if library is installed
-        LDFLAGS="-L$with_openssl/lib $LDFLAGS"
+        LDFLAGS="-L$with_openssl/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_openssl/include $CXXFLAGS"
 
-        LIBSSL_LDFLAGS="-L$with_openssl/lib"
+        LIBSSL_LDFLAGS="-L$with_openssl/lib/amd64"
         LIBSSL_FLAGS="-I$with_openssl/include"
         SAVE_LIBS=$LIBS
         LIBS="-lcrypto $LIBS"
@@ -1460,10 +1435,10 @@
          ;;
        *)
         # determine if library is installed
-        LDFLAGS="-L$with_cares/lib $LDFLAGS"
+        LDFLAGS="-L$with_cares/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_cares/include $CXXFLAGS"
 
-        CARES_LDFLAGS="-L$with_cares/lib"
+        CARES_LDFLAGS="-L$with_cares/lib/amd64"
         CARES_FLAGS="-I$with_cares/include"
 
         AC_CHECK_HEADERS([ares.h], [],
@@ -1631,7 +1606,7 @@
 
 
 # FreeImage
-freeimage=false
+freeimage=true
 AC_MSG_CHECKING(for FreeImage)
 AC_ARG_WITH(freeimage,
   AS_HELP_STRING(--with-freeimage=PATH, base of FreeImage installation),
@@ -1644,8 +1619,8 @@
     AC_CHECK_HEADERS([FreeImage.h],, [
         AC_MSG_ERROR([FreeImage.h header not found or not usable])
     ])
-    AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
-        AC_MSG_ERROR([FreeImage library is not found!])])
+    #AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
+    #    AC_MSG_ERROR([FreeImage library is not found!])])
 
      freeimage=true
      ;;
@@ -1652,13 +1627,13 @@
    *)
 
     # determine if library is installed
-    if test -d "$with_freeimage/lib"; then
-        LDFLAGS="-L$with_freeimage/lib $LDFLAGS"
+    if test -d "$with_freeimage/lib/amd64"; then
+        LDFLAGS="-L$with_freeimage/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_freeimage/include $CXXFLAGS"
         CPPFLAGS="-I$with_freeimage/include $CPPFLAGS"
 
         AC_CHECK_HEADERS([FreeImage.h],[
-         FI_LDFLAGS="-L$with_freeimage/lib"
+         FI_LDFLAGS="-L$with_freeimage/lib/amd64"
          FI_CXXFLAGS="-I$with_freeimage/include"
          FI_CPPFLAGS="-I$with_freeimage/include"],
          AC_MSG_ERROR([FreeImage.h header not found or not usable])
@@ -1677,8 +1652,8 @@
     fi
 
     # check and set FI library
-    AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
-        AC_MSG_ERROR([FreeImage library is not found!])])
+    #AC_CHECK_LIB([freeimage], [main], [FI_LIBS="-lfreeimage"], [
+    #    AC_MSG_ERROR([FreeImage library is not found!])])
 
     #restore
     LDFLAGS=$SAVE_LDFLAGS
@@ -1698,6 +1673,8 @@
      freeimage=true
   ]
   )
+FI_LDFLAGS=-L/usr/lib/amd64
+FI_LIBS=-lfreeimage
 AC_SUBST(FI_LDFLAGS)
 AC_SUBST(FI_LIBS)
 if test x$enable_static = xyes; then
@@ -1734,13 +1711,13 @@
     ;;
     *)
     # determine if library is installed
-    if test -d "$with_pdfium/lib"; then
-        LDFLAGS="-L$with_pdfium/lib $LDFLAGS"
+    if test -d "$with_pdfium/lib/amd64"; then
+        LDFLAGS="-L$with_pdfium/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_pdfium/include $CXXFLAGS"
         CPPFLAGS="-I$with_pdfium/include $CPPFLAGS"
 
         AC_CHECK_HEADERS([fpdfview.h],[
-         PDF_LDFLAGS="-L$with_pdfium/lib"
+         PDF_LDFLAGS="-L$with_pdfium/lib/amd64"
          PDF_CXXFLAGS="-I$with_pdfium/include"
          PDF_CPPFLAGS="-I$with_pdfium/include"],
          AC_MSG_ERROR([fpdfview.h header not found or not usable])
@@ -1804,13 +1781,13 @@
        *)
 
         # determine if library is installed
-        if test -d "$with_termcap/lib"; then
-            LDFLAGS="-L$with_termcap/lib $LDFLAGS"
+        if test -d "$with_termcap/lib/amd64"; then
+            LDFLAGS="-L$with_termcap/lib/amd64 $LDFLAGS"
             CXXFLAGS="-I$with_termcap/include $CXXFLAGS"
             CPPFLAGS="-I$with_termcap/include $CPPFLAGS"
 
             AC_CHECK_HEADERS([termcap.h],[
-                TERMCAP_LDFLAGS="-L$with_termcap/lib"
+                TERMCAP_LDFLAGS="-L$with_termcap/lib/amd64"
                 TERMCAP_CXXFLAGS="-I$with_termcap/include"
                 TERMCAP_CPPFLAGS="-I$with_termcap/include"],
                 AC_MSG_NOTICE([termcap.h header not found or not usable])
@@ -1873,8 +1850,8 @@
        *)
 
         # determine if library is installed
-        if test -d "$with_readline/lib"; then
-            LDFLAGS="-L$with_readline/lib $LDFLAGS"
+        if test -d "$with_readline/lib/amd64"; then
+            LDFLAGS="-L$with_readline/lib/amd64 $LDFLAGS"
             CXXFLAGS="-I$with_readline/include $CXXFLAGS"
             CPPFLAGS="-I$with_readline/include $CPPFLAGS"
             AC_CHECK_HEADERS([readline/readline.h], [
@@ -1948,7 +1925,7 @@
          ;;
        *)
 
-        LDFLAGS="-L$with_fuse/lib $LDFLAGS"
+        LDFLAGS="-L$with_fuse/lib/amd64 $LDFLAGS"
         CXXFLAGS="-I$with_fuse/include $CXXFLAGS -D_FILE_OFFSET_BITS=64"
         CPPFLAGS="-I$with_fuse/include $CPPFLAGS -D_FILE_OFFSET_BITS=64"