summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/glvis/package.py
blob: c97cf5704c161f91693ca467f27fddcd4beb53ce (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/spack/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *


class Glvis(MakefilePackage):
    """GLVis: an OpenGL tool for visualization of FEM meshes and functions"""

    homepage = "http://glvis.org"
    url      = "https://github.com/GLVis/glvis"

    maintainers = ['goxberry', 'v-dobrev', 'tzanio']

    # glvis (like mfem) is downloaded from a URL shortener at request
    # of upstream author Tzanio Kolev <tzanio@llnl.gov>.  See here:
    # https://github.com/mfem/mfem/issues/53
    #
    # The following procedure should be used to verify security when a
    # new version is added:
    #
    # 1. Verify that no checksums on old versions have changed.
    #
    # 2. Verify that the shortened URL for the new version is listed at:
    #    http://glvis.org/download/
    #
    # 3. Use http://getlinkinfo.com or similar to verify that the
    #    underling download link for the latest version comes has the
    #    prefix: http://glvis.github.io/releases
    #
    # If this quick verification procedure fails, additional discussion
    # will be required to verify the new version.

    version('develop', git='https://github.com/glvis/glvis', branch='master')

    version('3.4',
            '289fbd2e09d4456e5fee6162bdc3e0b4c8c8d54625f3547ad2a69fef319279e7',
            url='https://bit.ly/glvis-3-4',
            extension='.tar.gz')

    version('3.3',
            'e24d7c5cb53f208b691c872fe82ea898242cfdc0fd68dd0579c739e070dcd800',
            url='http://goo.gl/C0Oadw',
            extension='.tar.gz')

    version('3.2',
            'c82cb110396e63b6436a770c55eb6d578441eaeaf3f9cc20436c242392e44e80',
            url='http://goo.gl/hzupg1',
            extension='.tar.gz')

    version('3.1',
            '793e984ddfbf825dcd13dfe1ca00eccd686cd40ad30c8789ba80ee175a1b488c',
            url='http://goo.gl/gQZuu9',
            extension='tar.gz')

    variant('screenshots',
            default='png',
            values=('xwd', 'png', 'tiff'),
            description='Backend used for screenshots')
    variant('fonts', default=True,
            description='Use antialiased fonts via freetype & fontconfig')

    depends_on('mfem@develop', when='@develop')
    depends_on('mfem@3.4', when='@3.4')
    depends_on('mfem@3.3', when='@3.3')
    depends_on('mfem@3.2', when='@3.2')
    depends_on('mfem@3.1', when='@3.1')

    depends_on('gl')
    depends_on('glu')
    depends_on('libx11')

    depends_on('libpng', when='screenshots=png')
    depends_on('libtiff', when='screenshots=tiff')
    depends_on('freetype', when='+fonts')
    depends_on('fontconfig', when='+fonts')

    def edit(self, spec, prefix):

        def yes_no(s):
            return 'YES' if self.spec.satisfies(s) else 'NO'

        mfem = spec['mfem']
        config_mk = mfem.package.config_mk

        gl_libs = spec['glu'].libs + spec['gl'].libs + spec['libx11'].libs
        args = ['CC={0}'.format(env['CC']),
                'PREFIX={0}'.format(prefix.bin),
                'MFEM_DIR={0}'.format(mfem.prefix),
                'CONFIG_MK={0}'.format(config_mk),
                'GL_OPTS=-I{0} -I{1} -I{2}'.format(
                    spec['libx11'].prefix.include,
                    spec['gl'].prefix.include,
                    spec['glu'].prefix.include),
                'GL_LIBS={0}'.format(gl_libs.ld_flags)]

        if 'screenshots=png' in spec:
            args += [
                'USE_LIBPNG=YES', 'USE_LIBTIFF=NO',
                'PNG_OPTS=-DGLVIS_USE_LIBPNG -I{0}'.format(
                    spec['libpng'].prefix.include),
                'PNG_LIBS={0}'.format(spec['libpng'].libs.ld_flags)]
        elif 'screenshots=tiff' in spec:
            args += [
                'USE_LIBPNG=NO', 'USE_LIBTIFF=YES',
                'TIFF_OPTS=-DGLVIS_USE_LIBTIFF -I{0}'.format(
                    spec['libtiff'].prefix.include),
                'TIFF_LIBS={0}'.format(spec['libtiff'].libs.ld_flags)]
        else:
            args += ['USE_LIBPNG=NO', 'USE_LIBTIFF=NO']

        args.append('USE_FREETYPE={0}'.format(yes_no('+fonts')))
        if '+fonts' in spec:
            args += [
                'FT_OPTS=-DGLVIS_USE_FREETYPE -I{0} -I{1}'.format(
                    spec['freetype'].prefix.include.freetype2,
                    spec['fontconfig'].prefix.include),
                'FT_LIBS={0} {1}'.format(
                    spec['freetype'].libs.ld_flags,
                    spec['fontconfig'].libs.ld_flags)]

        self.build_targets = args
        self.install_targets += args