summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/molden/package.py
blob: a1c55de4025910e4e29f7e65938670c72d158a18 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright 2013-2020 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 *


class Molden(MakefilePackage):
    """A package for displaying Molecular Density from various
       Ab Initio packages"""

    homepage = "https://www3.cmbi.umcn.nl/molden/"
    url      = "ftp://ftp.cmbi.ru.nl/pub/molgraph/molden/molden6.5.tar.gz"

    maintainers = ['dev-zero']

    version('6.5', sha256='192631a0996b2bfa9f6b0769f83da38a9e4f83b1db9358982b23d6a594b4e8d4')

    depends_on('libx11')
    depends_on('libxmu')
    depends_on('gl@3:')
    depends_on('glu@1.3')
    depends_on('makedepend', type='build')

    parallel = False  # building in parallel is broken
    build_targets = ['clean', 'all']

    patch('for_aarch64.patch', when='target=aarch64:')

    def edit(self, spec, prefix):
        makefile = FileFilter('makefile')

        # never register extensions
        makefile.filter(r'(\s*)EXTEN = .*', r'\1EXTEN =')

        # always Spacks wrappers:
        makefile.filter(r'(\s*)CC = .*', r'\1CC = cc')
        makefile.filter(r'(\s*)FC = .*', r'\1FC = f77')

        # make sure we don't link in system X11 libs:
        makefile.filter(
            r'(.+)-L/usr/(?:X11R6/lib|X11R6/lib64|lib/X11) (.*)',
            r'\1 \2')
        makefile.filter(
            r'(.+)-I/usr/(?:X11R6/include|include/X11) (.*)',
            r'\1 \2')

        # enable basic optimization flags, arch-specific is done via wrappers
        cflags = '-O2 -funroll-loops'
        fflags = cflags

        if '%gcc@10:' in self.spec:
            fflags += '-fallow-argument-mismatch'

        makefile.filter(r'CFLAGS = (.*)', r'CFLAGS = {0} \1'.format(cflags))
        makefile.filter(r'FFLAGS = (.*)', r'FFLAGS = {0} \1'.format(fflags))

        if spec.target.family == 'aarch64':
            makefile.filter(r'AFLAG=*', r'AFLAG=')
            makefile.filter(r'rm -f src/', r'rm -f ')

    def install(self, spec, prefix):
        install_tree('bin', prefix.bin)