Skip to content

Instantly share code, notes, and snippets.

@colin-daniels
Last active May 9, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colin-daniels/d8c0926e16d87facd63668723ff756e3 to your computer and use it in GitHub Desktop.
Save colin-daniels/d8c0926e16d87facd63668723ff756e3 to your computer and use it in GitHub Desktop.
PKGBUILD for the DFTB+ library for use with dftbplus-sys (https://github.com/ExpHP/dftbplus-sys)
# Maintainer: Colin Daniels <colin.r.daniels@gmail.com>
pkgname=libdftb+-git
pkgver=18.2.r602.4d795c89
_pkgname=dftbplus
pkgver() {
cd "$srcdir/$_pkgname"
printf "%s" "$(git describe --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')"
}
pkgrel=1
pkgdesc="C library for DFTB+, a fast and efficient versatile quantum mechanical simulation software package."
arch=('x86_64')
url="http://www.dftbplus.org/"
license=('LGPL3')
depends=('blas' 'lapack' 'gcc-libs')
makedepends=('gcc-fortran' 'time' 'git' 'python')
source=(dftbplus::git://github.com/dftbplus/dftbplus.git)
md5sums=('SKIP')
# specific flags needed when linking...
LIB_LAPACK='-llapack -lblas'
OTHERLIBS_C='-lgfortran -lm -lgomp'
prepare() {
cd "$srcdir/$_pkgname"
# dependencies
./utils/get_opt_externals
# default build flags work for us
cp sys/make.x86_64-linux-gnu make.arch
# ...but make sure they're set to what we expect
sed -i \
-e 's/^LIB_LAPACK\s*=.*$/LIB_LAPACK = '"$LIB_LAPACK"'\n#/' \
-e 's/^OTHERLIBS_C\s*=.*$/OTHERLIBS_C = '"$OTHERLIBS_C"'\n#/' \
make.arch
}
build() {
cd "$srcdir/$_pkgname"
make api
}
check() {
cd "$srcdir/$_pkgname"
# dftb+ uses test not check (although check does...something)
make -k test_api
}
package() {
cd "$srcdir/$_pkgname"
# dftb+ doesn't honor PREFIX and the like, and by default uses INSTALLDIR, so we
# do both...just in case
make PREFIX="$pkgdir/usr" INSTALLDIR="$pkgdir/usr" install_api
# a bunch of fortran mod files we don't want
rm -f "$pkgdir/usr/include/"*.mod
# license
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$_pkgname/LICENSE
# header file, which isn't copied by make install
install -Dm644 api/mm/dftbplus.h "$pkgdir"/usr/include/dftbplus.h
# same deal here
install -D _build/external/xmlf90/libxmlf90.a "$pkgdir"/usr/lib/libxmlf90.a
# make a pkgconfig...pretty hacky atm though
sed 's/%/$/' <<EOF > libdftb+.pc
prefix=/usr
exec_prefix=%{prefix}
libdir=%{exec_prefix}/lib
includedir=%{prefix}/include
api_version=$(cat api/mm/API_VERSION)
Name: DFTB+
Description: $pkgdesc
Version: $pkgver
Requires.private:
Libs: -L%{libdir} -ldftb+ -lxmlf90
Libs.private: $LIB_LAPACK $OTHERLIBS_C
Cflags: -I%{includedir}
EOF
install -Dm644 libdftb+.pc "$pkgdir/usr/lib/pkgconfig/libdftb+.pc"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment