From a2e0cf9108081663607706f661f411a5fcf86e1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Tue, 16 Jun 2009 21:57:48 +0200
Subject: Make Swift compilation optional.


diff --git a/Makefile b/Makefile
index d46ffb4..f94111c 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,9 @@ include 3rdParty/ZLib/Makefile.inc
 include 3rdParty/Expat/Makefile.inc
 include 3rdParty/SQLite/Makefile.inc
 include Swiften/Makefile.inc
+ifeq ($(BUILD_SWIFT),yes)
 include Swift/Makefile.inc
+endif
 include QA/Makefile.inc
 
 ################################################################################
@@ -53,6 +55,13 @@ include QA/Makefile.inc
 .PHONY: all
 all: $(TARGETS)
 
+.PHONY: install
+install: install-dirs $(INSTALL_TARGETS)
+
+.PHONY: install-dirs
+install-dirs:
+	install -d $(includedir) $(libdir)
+
 .PHONY: coverage
 coverage:
 	tools/coverage/GenerateCoverageResults.sh
diff --git a/Makefile.config.in b/Makefile.config.in
index 374bea5..08c6dd3 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -1,7 +1,14 @@
 ################################################################################
 # Configuration Settings
+# These values are filled in by 'configure'
 ################################################################################
 
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+libdir=@libdir@
+includedir=@includedir@
+
 @SET_MAKE@
 MM=@MM@
 CXX=@CONFIG_CXX@
@@ -16,4 +23,5 @@ HAVE_LIBXML=@CONFIG_HAVE_LIBXML@
 HAVE_OPENSSL=@CONFIG_HAVE_OPENSSL@
 WIN32=@CONFIG_WIN32@
 MACOSX=@CONFIG_MACOSX@
+BUILD_SWIFT=@BUILD_SWIFT@
 QMAKE=@QMAKE@
diff --git a/Swiften/Makefile.inc b/Swiften/Makefile.inc
index 12323db..ce14110 100644
--- a/Swiften/Makefile.inc
+++ b/Swiften/Makefile.inc
@@ -31,8 +31,11 @@ SWIFTEN_OBJECTS = \
 	$(BOOST_OBJECTS) \
 	$(ZLIB_OBJECTS) \
 	$(SQLITE_OBJECTS)
+SWIFTEN_HEADERS += \
+	Swiften/config.h
 
 TARGETS += $(SWIFTEN_TARGET)
+INSTALL_TARGETS += install-swiften
 UNITTEST_LIBS += $(SWIFTEN_TARGET)
 CLEANFILES += $(SWIFTEN_TARGET) $(SWIFTEN_OBJECTS)
 
@@ -42,5 +45,12 @@ lib: $(SWIFTEN_TARGET)
 $(SWIFTEN_TARGET): $(SWIFTEN_OBJECTS)
 	$(QUIET_AR)$(AR) $(ARFLAGS) $@ $(SWIFTEN_OBJECTS)
 
+.PHONY: install-swiften
+install-swiften: $(SWIFTEN_TARGET) $(SWIFTEN_HEADERS)
+	install -d $(includedir)/Swiften/3rdParty
+	rsync -a 3rdParty/Boost/boost $(includedir)/Swiften/3rdParty/Boost
+	for header in $(SWIFTEN_HEADERS); do headerdir=$(includedir)/`dirname $$header`; echo $$header install -d $$headerdir; install $$header $$headerdir; done
+	install $(SWIFTEN_TARGET) $(libdir)
+
 include Swiften/QA/Makefile.inc
 include Swiften/Examples/Makefile.inc
diff --git a/configure.in b/configure.in
index f703be9..41ef7a7 100644
--- a/configure.in
+++ b/configure.in
@@ -46,6 +46,8 @@ case $host in
     CONFIG_LIBS="$CONFIG_LIBS -lstdc++"
 esac
 
+AC_CHECK_FILE([Swift/Makefile.inc], [BUILD_SWIFT="yes"], [BUILD_SWIFT="no"])
+
 ################################################################################
 # Configure options
 ################################################################################
@@ -127,9 +129,11 @@ if test -z "$MM"; then
 fi
 
 # Qt
-AX_QT()
-if test "$HAVE_QT" != yes; then
-  AC_MSG_ERROR([Could not find Qt])
+if test "$BUILD_SWIFT" == "yes"; then
+  AX_QT()
+  if test "$HAVE_QT" != yes; then
+    AC_MSG_ERROR([Could not find Qt])
+  fi
 fi
 
 # Expat
@@ -206,6 +210,7 @@ AC_SUBST(CONFIG_HAVE_OPENSSL)
 AC_SUBST(USE_BUNDLED_EXPAT)
 AC_SUBST(CONFIG_HAVE_LIBXML)
 AC_SUBST(QMAKE)
+AC_SUBST(BUILD_SWIFT)
 
 AC_CONFIG_FILES([Makefile.config])
 AC_OUTPUT
-- 
cgit v0.10.2-6-g49f6