################################################################################
#
# gtkmm.cygclass - functions for building GTKmm C++ bindings
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2015 Yaakov Selkowitz
# Provided by the Cygwin Ports project <http://sourceware.org/cygwinports/>
#
# cygport 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, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <http://www.gnu.org/licenses/>.
#
################################################################################

#****h* Cygclasses/gtkmm.cygclass
#  SYNOPSIS
#  inherit gtkmm
#  DESCRIPTION
#  The GTKmm project provides C++ bindings for most of the GNOME library
#  stack.  Packages are autotools-based with some custom aclocal macros and
#  Makefile segments.  Doxygen API documentation is included in most packages.
#
#  This cygclass builds the GTKmm binding packages.
#  INHERITS
#  autotools.cygclass, gnome.org.cygclass
#****

ORIG_PN=${ORIG_PN:-${PN/[0-9]*/}}
SRC_DIR=${ORIG_PN}-${PV}

inherit gnome.org

#****o* gtkmm.cygclass/CATEGORY (gtkmm)
#  DEFINITION
CATEGORY="Libs"
#****
#****o* gtkmm.cygclass/SUMMARY (gtkmm)
#  DEFINITION
SUMMARY="GNOME C++ bindings for ${ORIG_PN/mm/}-${PV_MAJ}.x"
#****
#****o* gtkmm.cygclass/HOMEPAGE (gtkmm)
#  DEFINITION
HOMEPAGE="http://www.gtkmm.org/"
#****

# .rc files are removed for regeneration by configure
DIFF_EXCLUDES+=" Doxyfile MSVC_Net200*"

KEEP_LA_FILES="none"

#****C* gtkmm.cygclass/gtkmm_autoreconf
#  SYNOPSIS
#  cd $S
#  gtkmm_autoreconf
#  DESCRIPTION
#  Updates the autotool build system with cygautoreconf.
#  WARNING
#  Skipping this step is strongly discouraged.  Patches to configure.ac, aclocal
#  macros, or Makefile.am files will not take effect until their tools have been
#  regenerated.  Also, Cygwin's libtool package often includes patches which
#  are not yet available in the latest upstream release, so libraries may not
#  be built optimally, or even correctly, without this step having been run.
#  REQUIRES
#  autoconf, automake, libtool, mm-common, pkg-config
#****
gtkmm_autoreconf() {
	# make sure mm-common is installed (for the aclocal macros)
	check_prog_req mm-common-prepare mm-common

	__config_set with_aclocal 1
	__config_set with_autoconf 1
	__config_set with_autoheader 1
	__config_set with_automake 1
	__config_set with_libtool 1

	if [ -d scripts ]
	then
		ACLOCAL_FLAGS+=" -I scripts"
	fi
	NO_AUTOHEADER=1
	cygautoreconf

	sed -i -e '/^SUBDIRS = .*/s/tests//' Makefile.in
}

#****C* gtkmm.cygclass/gtkmm_compile
#  SYNOPSIS
#  cd $B
#  gtkmm_compile [CONFIGURE_FLAGS]
#  DESCRIPTION
#  Calls cygconf, followed by cygmake.  All arguments to gtkmm_compile are
#  passed to cygconf as configure flags.
#****
gtkmm_compile() {
	cygconf ${@}
	cygmake LDFLAGS="${LDFLAGS} -no-undefined"
}

#****T* gtkmm.cygclass/gtkmm_test
#  SYNOPSIS
#  cd $B
#  gtkmm_test
#  DESCRIPTION
#  Runs the test programs with "make check".
#  NOTE
#  Not all GTKmm bindings include tests.
#****
gtkmm_test() {
	if [ -d tests ]
	then
		make -C tests check
	else
		make check
	fi
}

#****o* gtkmm.cygclass/src_compile (gtkmm)
#  DEFINITION
src_compile() {
	cd ${S}
	gtkmm_autoreconf
	cd ${B}
	gtkmm_compile
}
#****

#****o* gtkmm.cygclass/src_test (gtkmm)
#  DEFINITION
src_test() {
	cd ${B}
	gtkmm_test
}
#****

readonly -f gtkmm_autoreconf gtkmm_compile gtkmm_test
