summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/cbflib/package.py
blob: ed244db339988890f557f06379a9f0d328d41eb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *
import os


class Cbflib(MakefilePackage):
    """CBFLIB is a library of ANSI-C functions providing a simple mechanism
    for accessing Crystallographic Binary Files (CBF files) and
    Image-supporting CIF (imgCIF) files."""

    homepage = "http://www.bernstein-plus-sons.com/software/CBF/"
    url      = "https://downloads.sourceforge.net/project/cbflib/cbflib/CBFlib_0.9.2/CBFlib-0.9.2.tar.gz"

    version('0.9.2', sha256='367e37e1908a65d5472e921150291332823a751206804866e752b793bca17afc')

    depends_on('m4', type='build')

    patch('cbf_f16.patch')
    patch('cbf_int.patch')

    def setup_build_environment(self, env):
        ce = Executable(self.compiler.cc)
        ce('-E', join_path(os.path.dirname(__file__), "checkint.c"),
           output=str, error=str, fail_on_error=False)
        if ce.returncode != 0:
            env.set('CBF_DONT_USE_LONG_LONG', '1')

    def edit(self, spec, prefix):
        mf = FileFilter('Makefile')
        mf.filter(r'^CC.+', "CC = {0}".format(spack_cc))
        mf.filter(r'^C\+\+.+', "C++ = {0}".format(spack_cxx))
        mf.filter('gfortran', spack_fc)
        mf.filter(r'^INSTALLDIR .+', "INSTALLDIR = {0}".format(prefix))

    def build(self, spec, prefix):
        pass

    def install(self, spec, prefix):
        make('install', parallel=False)