################################################################################
#
# qt4-qconf.cygclass - functions for building QConf-based Qt4 packages
#
# 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/qt4-qconf.cygclass
#  SYNOPSIS
#  inherit qt4-qconf
#  DESCRIPTION
#  This cygclass builds Qt4-based packages which use the QConf configuration
#  system together with qmake project files.
#  INHERITS
#  qt4.cygclass, qt4-qmake.cygclass
#****

inherit qt4-qmake

#****C* qt4-qconf.cygclass/cygqconf4
#  SYNOPSIS
#  cygqconf4
#  DESCRIPTION
#  Generates a QConf configure script based on the .qc file in the same directory.
#****
cygqconf4() {
	if ! find . -maxdepth 1 -name '*.qc'
	then
		error "cygqconf4: could not find .qc file"
	fi

	rm -f configure
	qconf || error "qconf failed"
}

#****C* qt4-qconf.cygclass/qt4_qconf_compile
#  SYNOPSIS
#  cd $B
#  qt4_qconf_compile [OPTIONS]
#  DESCRIPTION
#  Runs the configure script, passing any options received, then calls cygmake
#  to compile the package.
#****
qt4_qconf_compile() {
	if [ ! -e configure ]
	then
		error "qt4_qconf_compile: could not find configure file"
	fi

	./configure --prefix=$(__host_prefix) --qtdir=${QT4_QTDIR} ${@} || error "qconf configure failed"
	cygqmake4
	cygmake
}

#****o* qt4-qconf.cygclass/src_compile (qt4-qconf)
#  DEFINITION
src_compile() {
	lndirs
	cd ${B}
	cygqconf4
	qt4_qconf_compile
}
#****

readonly -f cygqconf4 qt4_qconf_compile
