# 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 Eztrace(AutotoolsPackage):
    """EZTrace is a tool to automatically generate execution traces
       of HPC applications."""

    homepage = "http://eztrace.gforge.inria.fr"
    url      = "https://gitlab.com/eztrace/eztrace/-/archive/eztrace-1.1-10/eztrace-eztrace-1.1-10.tar.gz"
    maintainers = ['trahay']

    version('1.1-10', sha256='97aba8f3b3b71e8e2f7ef47e00c262234e27b9cb4a870c85c525317a83a3f0d4')

    depends_on('mpi')

    # Does not work on Darwin due to MAP_POPULATE
    conflicts('platform=darwin')

    def configure_args(self):
        args = ["--with-mpi={0}".format(self.spec["mpi"].prefix)]
        return args

@@ -748,112 +748,755 @@
 def 
-configure_args(self):%0A        args = %5B%22--with-mpi=%7B0%7D%22.format(self.spec%5B%22mpi%22%5D.prefix)%5D%0A        return args
+patch(self):%0A        filter_file(%0A            '%22DEFAULT_OUTFILE%22',%0A            '%22 DEFAULT_OUTFILE %22',%0A            'extlib/gtg/extlib/otf/tools/otfshrink/otfshrink.cpp',%0A            string=True%0A        )%0A%0A    def setup_build_environment(self, env):%0A        if self.spec.satisfies('%25fj'):%0A            env.set('LDFLAGS', '--linkfortran')%0A%0A    def configure_args(self):%0A        args = %5B%22--with-mpi=%7B0%7D%22.format(self.spec%5B%22mpi%22%5D.prefix)%5D%0A        return args%0A%0A    @run_before('build')%0A    def fix_libtool(self):%0A        if self.spec.satisfies('%25fj'):%0A            libtools = %5B'extlib/gtg/libtool',%0A                        'extlib/opari2/build-frontend/libtool'%5D%0A            for f in libtools:%0A                filter_file('wl=%22%22', 'wl=%22-Wl,%22', f, string=True)
 %0A

add space, --linkfortran, -Wl (#17801)