# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../multisync/multisync.conf
# Copyright (C) 2007 - 2008 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2004 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

build_multisync_plugin() {
	local plugin=$1; shift

	echo "Building multisync plugin $plugin..."
	cd plugins/$plugin

	# CVS version ...
	sed -i '/TOP.*spec$/d' configure.in
	automake

	eval_config_command $( eval echo $confopt $* )
	eval $MAKE $makeopt
	eval $MAKE $makeinstopt

	cd ../..
}

multisync_pm() {
	local each

	build_multisync_plugin backup_plugin

# multisync is not ready for evo-2.0 yet
#	if pkginstalled evolution; then
#		pkgprefix -t evolution
#		build_multisync_plugin evolution_sync \
#			--with-evo-libs=$( pkgprefix libdir evolution )
#	fi

	build_multisync_plugin palm_sync
	build_multisync_plugin opie_sync
	build_multisync_plugin syncml_plugin

	if pkginstalled openldap && pkginstalled cyrus-sasl2; then
		pkgprefix -t openldap
		build_multisync_plugin ldap_plugin \
			CFLAGS="-I$( pkgprefix includedir openldap )" \
			LDFLAGS="-L$( pkgprefix libdir openldap )"
	fi

# FIXME the configure scripts needs a fix to add
#   the -L.* for gnome24/glib-2.0 when trying to detect openobex
#	if pkginstalled openobex; then
#		build_multisync_plugin irmc_sync
#	fi
}

var_append GCC_WRAPPER_REMOVE " " "-Werror"

hook_add postmake 3 multisync_pm