# Maintainer: Bjoern Lemke <lemke@lemke-it.com>
_realname=cego
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.47.0
pkgrel=1
pkgdesc="Cego database system (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='http://www.lemke-it.com/'
license=('GPL3')
source=("http://www.lemke-it.com/${_realname}-${pkgver}.tar.gz")
depends=("${MINGW_PACKAGE_PREFIX}-readline"
	"${MINGW_PACKAGE_PREFIX}-lfcbase"
	"${MINGW_PACKAGE_PREFIX}-lfcxml")

makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")

sha256sums=('1a2d0ec39e8123adcb69df33005000f7f7713255d7e16656c4ecb2acdf1d7168')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make

  ${MINGW_PREFIX}/bin/gcc -fPIC -shared \
    -Wl,--out-implib,libcego.dll.a \
    -o libcego-0.dll \
    ${srcdir}/build-${CARCH}/src/Cego.o \
    ${srcdir}/build-${CARCH}/src/CegoAction.o \
    ${srcdir}/build-${CARCH}/src/CegoAdm.o \
    ${srcdir}/build-${CARCH}/src/CegoAdmNet.o \
    ${srcdir}/build-${CARCH}/src/CegoAdmAction.o \
    ${srcdir}/build-${CARCH}/src/CegoAdminThread.o \
    ${srcdir}/build-${CARCH}/src/CegoAdminThreadPool.o \
    ${srcdir}/build-${CARCH}/src/CegoAdminHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoAggregation.o \
    ${srcdir}/build-${CARCH}/src/CegoAliasObject.o \
    ${srcdir}/build-${CARCH}/src/CegoAlterDesc.o \
    ${srcdir}/build-${CARCH}/src/CegoAttrAlias.o \
    ${srcdir}/build-${CARCH}/src/CegoAttrCond.o \
    ${srcdir}/build-${CARCH}/src/CegoAttrDesc.o \
    ${srcdir}/build-${CARCH}/src/CegoAttrComp.o \
    ${srcdir}/build-${CARCH}/src/CegoAVLIndexCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoAVLIndexEntry.o \
    ${srcdir}/build-${CARCH}/src/CegoAVLIndexManager.o \
    ${srcdir}/build-${CARCH}/src/CegoBlob.o \
    ${srcdir}/build-${CARCH}/src/CegoBTreeCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoBTreeManager.o \
    ${srcdir}/build-${CARCH}/src/CegoBTreeNode.o \
    ${srcdir}/build-${CARCH}/src/CegoBTreeObject.o \
    ${srcdir}/build-${CARCH}/src/CegoBTreeValue.o \
    ${srcdir}/build-${CARCH}/src/CegoBeatConnection.o \
    ${srcdir}/build-${CARCH}/src/CegoBeatThread.o \
    ${srcdir}/build-${CARCH}/src/CegoBufferPage.o \
    ${srcdir}/build-${CARCH}/src/CegoBufferPool.o \
    ${srcdir}/build-${CARCH}/src/CegoBufferPoolEntry.o \
    ${srcdir}/build-${CARCH}/src/CegoCaseCond.o \
    ${srcdir}/build-${CARCH}/src/CegoClob.o \
    ${srcdir}/build-${CARCH}/src/CegoCheckpoint.o \
    ${srcdir}/build-${CARCH}/src/CegoCheckpointDump.o \
    ${srcdir}/build-${CARCH}/src/CegoCheckObject.o \
    ${srcdir}/build-${CARCH}/src/CegoCondDesc.o \
    ${srcdir}/build-${CARCH}/src/CegoContentObject.o \
    ${srcdir}/build-${CARCH}/src/CegoDatabaseFormater.o \
    ${srcdir}/build-${CARCH}/src/CegoDatabaseManager.o \
    ${srcdir}/build-${CARCH}/src/CegoDbThreadPool.o \
    ${srcdir}/build-${CARCH}/src/CegoDbThread.o \
    ${srcdir}/build-${CARCH}/src/CegoDistManager.o \
    ${srcdir}/build-${CARCH}/src/CegoDistCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoDistDbHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoDataPointer.o \
    ${srcdir}/build-${CARCH}/src/CegoDbHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoDecodableObject.o \
    ${srcdir}/build-${CARCH}/src/CegoExpr.o \
    ${srcdir}/build-${CARCH}/src/CegoExpOutStream.o \
    ${srcdir}/build-${CARCH}/src/CegoField.o \
    ${srcdir}/build-${CARCH}/src/CegoFieldValue.o \
    ${srcdir}/build-${CARCH}/src/CegoFactor.o \
    ${srcdir}/build-${CARCH}/src/CegoFileHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoFunction.o \
    ${srcdir}/build-${CARCH}/src/CegoGroupCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoGroupNode.o \
    ${srcdir}/build-${CARCH}/src/CegoGroupSpace.o \
    ${srcdir}/build-${CARCH}/src/CegoHavingDesc.o \
    ${srcdir}/build-${CARCH}/src/CegoImpInStream.o \
    ${srcdir}/build-${CARCH}/src/CegoJDBCInfo.o \
    ${srcdir}/build-${CARCH}/src/CegoJoinObject.o \
    ${srcdir}/build-${CARCH}/src/CegoKeyObject.o \
    ${srcdir}/build-${CARCH}/src/CegoLockHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoLogHandler.o \
    ${srcdir}/build-${CARCH}/src/CegoLogManager.o \
    ${srcdir}/build-${CARCH}/src/CegoLogThreadPool.o \
    ${srcdir}/build-${CARCH}/src/CegoLogThread.o \
    ${srcdir}/build-${CARCH}/src/CegoLogRecord.o \
    ${srcdir}/build-${CARCH}/src/CegoMediatorThread.o \
    ${srcdir}/build-${CARCH}/src/CegoModule.o \
    ${srcdir}/build-${CARCH}/src/CegoNet.o \
    ${srcdir}/build-${CARCH}/src/CegoObject.o \
    ${srcdir}/build-${CARCH}/src/CegoOutput.o \
    ${srcdir}/build-${CARCH}/src/CegoObjectCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoObjectManager.o \
    ${srcdir}/build-${CARCH}/src/CegoOrderCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoOrderNode.o \
    ${srcdir}/build-${CARCH}/src/CegoOrderSpace.o \
    ${srcdir}/build-${CARCH}/src/CegoPredDesc.o \
    ${srcdir}/build-${CARCH}/src/CegoProcedure.o \
    ${srcdir}/build-${CARCH}/src/CegoProcThrowStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcAssignStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcBlock.o \
    ${srcdir}/build-${CARCH}/src/CegoProcBlockStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcCond.o \
    ${srcdir}/build-${CARCH}/src/CegoProcCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoProcCursorCloseStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcCursorCreateStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcException.o \
    ${srcdir}/build-${CARCH}/src/CegoProcFetch.o \
    ${srcdir}/build-${CARCH}/src/CegoProcIfStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcNoopStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcPred.o \
    ${srcdir}/build-${CARCH}/src/CegoProcQueryStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcReturnStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcWhileStmt.o \
    ${srcdir}/build-${CARCH}/src/CegoProcObject.o \
    ${srcdir}/build-${CARCH}/src/CegoProcVar.o \
    ${srcdir}/build-${CARCH}/src/CegoQuery.o \
    ${srcdir}/build-${CARCH}/src/CegoQueryCache.o \
    ${srcdir}/build-${CARCH}/src/CegoQueryException.o \
    ${srcdir}/build-${CARCH}/src/CegoQueryHelper.o \
    ${srcdir}/build-${CARCH}/src/CegoRecoveryManager.o \
    ${srcdir}/build-${CARCH}/src/CegoReturnVar.o \
    ${srcdir}/build-${CARCH}/src/CegoSelect.o \
    ${srcdir}/build-${CARCH}/src/CegoSerial.o \
    ${srcdir}/build-${CARCH}/src/CegoSystemObject.o \
    ${srcdir}/build-${CARCH}/src/CegoTableCache.o \
    ${srcdir}/build-${CARCH}/src/CegoTableObject.o \
    ${srcdir}/build-${CARCH}/src/CegoTableCursor.o \
    ${srcdir}/build-${CARCH}/src/CegoTableManager.o \
    ${srcdir}/build-${CARCH}/src/CegoTerm.o \
    ${srcdir}/build-${CARCH}/src/CegoTransactionManager.o \
    ${srcdir}/build-${CARCH}/src/CegoTrigger.o \
    ${srcdir}/build-${CARCH}/src/CegoTriggerObject.o \
    ${srcdir}/build-${CARCH}/src/CegoTypeConverter.o \
    ${srcdir}/build-${CARCH}/src/CegoView.o \
    ${srcdir}/build-${CARCH}/src/CegoViewObject.o \
    ${srcdir}/build-${CARCH}/src/CegoXMLHelper.o \
    ${srcdir}/build-${CARCH}/src/CegoXMLSpace.o \
    ${srcdir}/build-${CARCH}/src/CegoXPorter.o \
    -llfcxml -llfcbase -lsystre -lws2_32 -lpthread -lstdc++

}

check() {
  cd "${srcdir}"/build-${CARCH}
  make check
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"

  mkdir -p "${pkgdir}"${MINGW_PREFIX}/{bin,lib}
  install -m 0755 libcego-0.dll "${pkgdir}${MINGW_PREFIX}/bin"
  install -m 0644 libcego.dll.a "${pkgdir}${MINGW_PREFIX}/lib"

}

