--- /dev/null
+Make sure the Makefile obeys $(DESTDIR)
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/src/Makefile.in
+===================================================================
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -120,48 +120,48 @@
+ install: ${INSTALL_TARGETS}
+
+ install-qlibc: qlibc
+- ${MKDIR_P} ${INST_INCDIR}/qlibc
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibc.h ${INST_INCDIR}/qlibc/qlibc.h
+- ${MKDIR_P} ${INST_LIBDIR}
+- ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_LIBNAME} ${INST_LIBDIR}/${QLIBC_LIBNAME}
+- ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_SLIBREALNAME} ${INST_LIBDIR}/${QLIBC_SLIBREALNAME}
+- ( cd ${INST_LIBDIR}; ${LN_S} -f ${QLIBC_SLIBREALNAME} ${QLIBC_SLIBNAME} )
++ ${MKDIR_P} ${DESTDIR}/${INST_INCDIR}/qlibc
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibc.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibc.h
++ ${MKDIR_P} ${DESTDIR}/${INST_LIBDIR}
++ ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_LIBNAME} ${DESTDIR}/${INST_LIBDIR}/${QLIBC_LIBNAME}
++ ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBC_SLIBREALNAME} ${DESTDIR}/${INST_LIBDIR}/${QLIBC_SLIBREALNAME}
++ ( cd ${DESTDIR}/${INST_LIBDIR}; ${LN_S} -f ${QLIBC_SLIBREALNAME} ${QLIBC_SLIBNAME} )
+
+ uninstall-qlibc:
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibc.h
+- ${RM} -f ${INST_LIBDIR}/${QLIBC_LIBNAME}
+- ${RM} -f ${INST_LIBDIR}/${QLIBC_SLIBREALNAME}
+- ${RM} -f ${INST_LIBDIR}/${QLIBC_SLIBNAME}
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibc.h
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBC_LIBNAME}
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBC_SLIBREALNAME}
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBC_SLIBNAME}
+
+ install-qlibcext: qlibcext
+- ${MKDIR_P} ${INST_INCDIR}/qlibc
+- ${MKDIR_P} ${INST_INCDIR}/qlibc/qlibcext/
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext.h ${INST_INCDIR}/qlibc/qlibcext.h
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qconfig.h ${INST_INCDIR}/qlibc/qlibcext/qconfig.h
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qaconf.h ${INST_INCDIR}/qlibc/qlibcext/qaconf.h
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qlog.h ${INST_INCDIR}/qlibc/qlibcext/qlog.h
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qhttpclient.h ${INST_INCDIR}/qlibc/qlibcext/qhttpclient.h
+- ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qdatabase.h ${INST_INCDIR}/qlibc/qlibcext/qdatabase.h
+- ${MKDIR_P} ${INST_LIBDIR}
+- ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_LIBNAME} ${INST_LIBDIR}/${QLIBCEXT_LIBNAME}
+- ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_SLIBREALNAME} ${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME}
+- ( cd ${INST_LIBDIR}; ${LN_S} -f ${QLIBCEXT_SLIBREALNAME} ${QLIBCEXT_SLIBNAME} )
++ ${MKDIR_P} ${DESTDIR}/${INST_INCDIR}/qlibc
++ ${MKDIR_P} ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext.h
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qconfig.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qconfig.h
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qaconf.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qaconf.h
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qlog.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qlog.h
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qhttpclient.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qhttpclient.h
++ ${INSTALL_DATA} ${QLIBC_INCDIR}/qlibcext/qdatabase.h ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qdatabase.h
++ ${MKDIR_P} ${DESTDIR}/${INST_LIBDIR}
++ ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_LIBNAME} ${DESTDIR}/${INST_LIBDIR}/${QLIBCEXT_LIBNAME}
++ ${INSTALL_DATA} ${QLIBC_LIBDIR}/${QLIBCEXT_SLIBREALNAME} ${DESTDIR}/${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME}
++ ( cd ${DESTDIR}/${INST_LIBDIR}; ${LN_S} -f ${QLIBCEXT_SLIBREALNAME} ${QLIBCEXT_SLIBNAME} )
+
+ uninstall-qlibcext:
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext.h
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext/qconfig.h
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext/qaconf.h
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext/qlog.h
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext/qhttpclient.h
+- ${RM} -f ${INST_INCDIR}/qlibc/qlibcext/qdatabase.h
+- ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_LIBNAME}
+- ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME}
+- ${RM} -f ${INST_LIBDIR}/${QLIBCEXT_SLIBNAME}
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext.h
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qconfig.h
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qaconf.h
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qlog.h
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qhttpclient.h
++ ${RM} -f ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext/qdatabase.h
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBCEXT_LIBNAME}
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBCEXT_SLIBREALNAME}
++ ${RM} -f ${DESTDIR}/${INST_LIBDIR}/${QLIBCEXT_SLIBNAME}
+
+ deinstall: uninstall
+ uninstall: uninstall-qlibc uninstall-qlibcext
+- ${RMDIR} ${INST_INCDIR}/qlibc/qlibcext
+- ${RMDIR} ${INST_INCDIR}/qlibc
++ ${RMDIR} ${DESTDIR}/${INST_INCDIR}/qlibc/qlibcext
++ ${RMDIR} ${DESTDIR}/${INST_INCDIR}/qlibc
+
+ clean:
+ ${RM} -f ${QLIBC_OBJS}
--- /dev/null
+Allow to explicitly disable openssl and mysql
+
+AC_ARG_WITH() is being incorrectly used: the third argument indicates
+the action that needs to be taken when a value was passed, when not
+the option is enabled. Therefore, the result of the existing code was
+that when you passed --without-mysql or --without-openssl, the
+$withval variable would get the value 'yes', which is obviously wrong.
+
+Instead, we simply empty this third argument, because $withval is
+already properly filled with 'yes' or 'no' by the AC_ARG_WITH()
+function.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -170,7 +170,7 @@
+ ## --with section
+ ##
+
+-AC_ARG_WITH([openssl],[AS_HELP_STRING([--with-openssl], [This will enable HTTPS support in qhttpclient extension API. When it's enabled, user applications will need to link openssl library with -lssl option.])],[withval=yes],[withval=no])
++AC_ARG_WITH([openssl],[AS_HELP_STRING([--with-openssl], [This will enable HTTPS support in qhttpclient extension API. When it's enabled, user applications will need to link openssl library with -lssl option.])],[],[withval=no])
+ if test "$withval" = yes; then
+ if test "$with_openssl" = yes; then
+ with_openssl="/usr/include"
+@@ -185,7 +185,7 @@
+ fi
+ fi
+
+-AC_ARG_WITH([mysql],[AS_HELP_STRING([--with-mysql], [This will enable MySQL database support in qdatabase extension API. When it's enabled, user applications need to link mysql client library. (ex: -lmysqlclient)])],[withval=yes],[withval=no])
++AC_ARG_WITH([mysql],[AS_HELP_STRING([--with-mysql], [This will enable MySQL database support in qdatabase extension API. When it's enabled, user applications need to link mysql client library. (ex: -lmysqlclient)])],[],[withval=no])
+ if test "$withval" = yes; then
+ if test "$with_mysql" = yes; then
+ with_mysql="/usr/include/mysql"
--- /dev/null
+################################################################################
+#
+# qlibc
+#
+################################################################################
+
+QLIBC_VERSION = v2.1.6
+QLIBC_SITE = $(call github,wolkykim,qlibc,$(QLIBC_VERSION))
+QLIBC_LICENSE = BSD-2c
+QLIBC_LICENSE_FILES = COPYING
+
+# We're patching configure.ac
+QLIBC_AUTORECONF = YES
+QLIBC_INSTALL_STAGING = YES
+QLIBC_DEPENDENCIES = $(if $(BR2_PACKAGE_LIBICONV),libiconv)
+
+# The configure.ac checks for these use AC_CHECK_FILE() which doesn't
+# work for cross-compilation. If someone wants to enable the support
+# for OpenSSL or MySQL, some changes to the configure.ac will be
+# needed.
+QLIBC_CONF_OPTS = --without-mysql --without-openssl
+
+$(eval $(autotools-package))