# Maintainer: Maurizio D'Addona <mauritiusdadd@gmail.com>
# Contributor: Sven Niese <Fd3querm@yahoo.de>
# Contributor: Daniel Murphy <mosquitogang201@gmail.com>

# NOTE: !buildflags is needed in order to compile the code

pkgname=calculix-cgx
pkgver=2.22
pkgrel=1
pkgdesc="CalculiX: 3D Structural Finite Element Program - Post Processor"
arch=('i686' 'x86_64')
options=(!buildflags)
url="http://www.calculix.de/"
license=('GPL2')
depends=('libsnl-svn' 'mesa' 'glu' 'libxmu' 'libxi')
optdepends=('calculix-doc: documentation and examples')
makedepends=('gcc-fortran' 'perl')
checkdepends=('perl')

source=("http://www.dhondt.de/cgx_${pkgver}.all.tar.bz2"
        "calculix_cgx_${pkgver}_archlinux.patch")

sha256sums=('c642431089560eec21b1a6a5d7f5a40bc23ea946115a296b8dd8cb8a596921d1'
            '10fb41e0d53457c100df59428f1ad9bb4cbb953fbf30297c89c6d1c4be673b63')

prepare()
{
    cd "${srcdir}"

    msg "Patching makefiles..."
    rm -rf CalculiX/libSNL
    patch -p0 -f -l -s -i calculix_cgx_${pkgver}_archlinux.patch
    msg2 "Done"
}

build()
{   
    cd "${srcdir}/CalculiX/cgx_${pkgver}/src"
    make  CFLAGS="-O2 -Wall -Wno-narrowing -I./ -I/usr/include/libSNL -I../../glut-3.5/src" \
          LFLAGS="-lGL -lGLU -lX11 -lXi -lXmu -lXext -lXt -lSM -lICE -lSNL -lm -lpthread -lrt"
}

package() 
{
    install -d  ${pkgdir}/usr/bin
    install -Dm755 ${srcdir}/CalculiX/cgx_${pkgver}/src/cgx ${pkgdir}/usr/bin/cgx
}