On 04/11/13 10:58, Jean-Marc Lasgouttes wrote:
> Have a look at what is done in config/spell.m4 for the different spell 
> checkers, There are two ingredients:
> - a USE_xxx #define, that can be used in the code to do conditional 
> compilation
> - a USE_xxx automake conditional that is used to decide which pieces of code 
> shall be compiled.

Done, thanks! If you have a look at my personal development playground

  git clone [email protected]:developers/tommaso/lyx
  git checkout features/chat

you will find the patch adapted according to what you suggest (didn't try to 
compile without the libraries on my system, but there should not be surprises, 
as I copied the spell-related stuff).

For your convenience, I'm attaching only the part of the patch relative to the 
autoconf-iguration.

        T.

commit 502fcb03
Author: Tommaso Cucinotta <[email protected]>
Date:   Wed Oct 16 22:55:40 2013 +0100

    LyX XMPP Chat

diff --git a/config/Makefile.am b/config/Makefile.am
index d91a889d..f52a840b 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -5,4 +5,5 @@ EXTRA_DIST = \
 	lyxinclude.m4 \
 	pkg.m4 \
 	qt4.m4 \
-	spell.m4
+	spell.m4 \
+	qxmpp.m4
diff --git a/config/qt4.m4 b/config/qt4.m4
index 58edd851..9f0160c5 100644
--- a/config/qt4.m4
+++ b/config/qt4.m4
@@ -37,8 +37,8 @@ AC_DEFUN([QT4_CHECK_COMPILE],
 			fi
 		done
 		qt4_cv_libname=
-		for libname in '-lQtCore -lQtGui' \
-		               '-lQtCore4 -lQtGui4' \
+		for libname in '-lQtCore -lQtGui -lQtNetwork -lQtXml' \
+		               '-lQtCore4 -lQtGui4 -lQtNetwork4 -lQtXml4' \
 		               '-framework QtCore -framework QtConcurrent -framework QtWidgets -framework QtGui'\
 		               '-framework QtCore -framework QtGui'
 		do
@@ -182,18 +182,18 @@ AC_DEFUN([QT4_DO_PKG_CONFIG],
 		QT4_CORE_LIB=`$PKG_CONFIG --libs-only-l QtCore`
 		AC_SUBST(QT4_CORE_LIB)
 	fi
-	PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui,,[:])
+	PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui QtNetwork QtXml,,[:])
 	if test "$pkg_failed" = "no" ; then
 		QT4_INCLUDES=$QT4_FRONTEND_CFLAGS
 		dnl QT4_LDFLAGS=$QT4_FRONTEND_LIBS
-		QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui`
+		QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui QtNetwork QtXml`
 		AC_SUBST(QT4_INCLUDES)
 		AC_SUBST(QT4_LDFLAGS)
 		QT4_VERSION=`$PKG_CONFIG --modversion QtCore`
 		AC_SUBST(QT4_VERSION)
-		QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui`
+		QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui QtNetwork QtXml`
 		AC_SUBST(QT4_LIB)
-		dnl LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui`"
+		dnl LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui QtNetwork QtXml`"
 	fi
 	PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
 	dnl Actually, the values of QT4_LIB and QT4_CORE_LIB can be completely
@@ -225,7 +225,7 @@ AC_DEFUN([QT4_DO_MANUAL_CONFIG],
 	QT4_CORE_LDFLAGS=
 	if test -n "$qt4_cv_includes"; then
 		QT4_INCLUDES="-I$qt4_cv_includes"
-		for i in Qt QtCore QtGui QtWidgets QtConcurrent; do
+		for i in Qt QtCore QtGui QtNetwork QtXml QtWidgets QtConcurrent; do
 			QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
 		done
 		QT4_CORE_INCLUDES="-I$qt4_cv_includes -I$qt4_cv_includes/QtCore"
diff --git a/config/qxmpp.m4 b/config/qxmpp.m4
new file mode 100644
index 00000000..743ff979
--- /dev/null
+++ b/config/qxmpp.m4
@@ -0,0 +1,30 @@
+# Macro to add for using qxmpp libraries!     -*- sh -*-
+AC_DEFUN([CHECK_WITH_QXMPP],
+[
+	lyx_use_qxmpp=true
+	AC_ARG_WITH(qxmpp, AC_HELP_STRING([--without-qxmpp],[do not check for QXMPP library]))
+	test "$with_qxmpp" = "no" && lyx_use_qxmpp=false
+
+	if $lyx_use_qxmpp; then
+		PKG_CHECK_MODULES([QXMPP], [qxmpp], [], [
+			AC_CHECK_HEADERS(qxmpp/QXmppClient.h,
+				[lyx_use_qxmpp=true; break;],
+				[lyx_use_qxmpp=false])
+			AC_CHECK_LIB(qxmpp, main, LIBS="-lqxmpp $LIBS", lyx_use_qxmpp=false)
+		])
+		AC_MSG_CHECKING([whether to use qxmpp])
+		if $lyx_use_qxmpp ; then
+			AC_MSG_RESULT(yes)
+			AC_DEFINE(USE_QXMPP, 1, [Define as 1 to use the qxmpp library])
+			lyx_flags="$lyx_flags use-qxmpp"
+		else
+			AC_MSG_RESULT(no)
+		fi
+	fi
+])
+
+AC_DEFUN([LYX_CHECK_QXMPP],
+[
+	CHECK_WITH_QXMPP
+	AM_CONDITIONAL(USE_QXMPP, $lyx_use_qxmpp)
+	])
diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am
index fc42e9b9..1bff168d 100644
--- a/src/frontends/qt4/Makefile.am
+++ b/src/frontends/qt4/Makefile.am
@@ -49,6 +49,13 @@ AM_CPPFLAGS += \
 	-I$(top_srcdir)/images \
 	$(QT4_INCLUDES) $(BOOST_INCLUDES)
 
+if USE_QXMPP
+CHAT_CPP = GuiChat.cpp GuiBuddies.cpp GuiChatMessenger.cpp
+CHAT_MOC = GuiChat.h GuiBuddies.h GuiChatMessenger.h
+CHAT_UI = ChatUi.ui BuddiesUi.ui
+AM_CPPFLAGS += $(QXMPP_CFLAGS)
+endif
+
 SOURCEFILES = \
 	ButtonPolicy.cpp \
 	ButtonPolicy.h \
@@ -59,6 +66,7 @@ SOURCEFILES = \
 	BulletsModule.cpp \
 	ButtonController.cpp \
 	CategorizedCombo.cpp \
+	$(CHAT_CPP) \
 	ColorCache.cpp \
 	CustomizedWidgets.cpp \
 	EmptyTable.cpp \
@@ -178,6 +186,7 @@ MOCHEADER = \
 	Action.h \
 	BulletsModule.h \
 	CategorizedCombo.h \
+	$(CHAT_MOC) \
 	CustomizedWidgets.h \
 	EmptyTable.h \
 	FancyLineEdit.h \
@@ -274,6 +283,7 @@ UIFILES = \
 	BulletsUi.ui \
 	ChangesUi.ui \
 	CharacterUi.ui \
+	$(CHAT_UI) \
 	CitationUi.ui \
 	ColorUi.ui \
 	CompareUi.ui \

Reply via email to