@@ -0,0 +1,3037 @@
+from spack import *%0Aimport os%0Aimport glob%0A%0Aclass Tbb(Package):%0A    %22%22%22Widely used C++ template library for task parallelism.%0A    Intel Threading Building Blocks (Intel TBB) lets you easily write parallel%0A    C++ programs that take full advantage of multicore performance, that are%0A    portable and composable, and that have future-proof scalability.%0A    %22%22%22%0A    homepage = %22http://www.threadingbuildingblocks.org/%22%0A%0A    # Only version-specific URL's work for TBB%0A    version('4.4.3', '80707e277f69d9b20eeebdd7a5f5331137868ce1', url='https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb44_20160128oss_src_0.tgz')%0A%0A    def coerce_to_spack(self,tbb_build_subdir):%0A        for compiler in %5B%22icc%22,%22gcc%22,%22clang%22%5D:%0A              fs = glob.glob(join_path(tbb_build_subdir,%22*.%25s.inc%22 %25 compiler ))%0A              for f in fs:%0A                  lines = open(f).readlines()%0A                  of = open(f,%22w%22)%0A                  for l in lines:%0A                      if l.strip().startswith(%22CPLUS =%22):%0A                        of.write(%22# coerced to spack%5Cn%22)%0A                        of.write(%22CPLUS = $(CXX)%5Cn%22)%0A                      elif l.strip().startswith(%22CPLUS =%22):%0A                        of.write(%22# coerced to spack%5Cn%22)%0A                        of.write(%22CONLY = $(CC)%5Cn%22)%0A                      else:%0A                        of.write(l);%0A%0A    def install(self, spec, prefix):%0A        #%0A        # we need to follow TBB's compiler selection logic to get the proper build + link flags%0A        # but we still need to use spack's compiler wrappers%0A        # to accomplish this, we do two things:%0A        #%0A        # * Look at the spack spec to determine which compiler we should pass to tbb's Makefile%0A        #%0A        # * patch tbb's build system to use the compiler wrappers (CC, CXX) for%0A        #    icc, gcc, clang%0A        #    (see coerce_to_spack())%0A        #%0A        self.coerce_to_spack(%22build%22)%0A%0A        if spec.satisfies('%25clang'):%0A            tbb_compiler = %22clang%22%0A        elif spec.satisfies('%25intel'):%0A            tbb_compiler = %22icc%22%0A        else:%0A            tbb_compiler = %22gcc%22%0A%0A%0A        mkdirp(prefix)%0A        mkdirp(prefix.lib)%0A%0A        #%0A        # tbb does not have a configure script or make install target%0A        # we simply call make, and try to put the pieces together%0A        #%0A        make(%22compiler=%25s%22  %25(tbb_compiler))%0A%0A        # install headers to %7Bprefix%7D/include%0A        install_tree('include',prefix.include)%0A%0A        # install libs to %7Bprefix%7D/lib%0A        tbb_lib_names = %5B%22libtbb%22,%0A                         %22libtbbmalloc%22,%0A                         %22libtbbmalloc_proxy%22%5D%0A%0A        for lib_name in tbb_lib_names:%0A            # install release libs%0A            fs = glob.glob(join_path(%22build%22,%22*release%22,lib_name + %22.*%22))%0A            for f in fs:%0A                install(f, prefix.lib)%0A            # install debug libs if they exist%0A            fs = glob.glob(join_path(%22build%22,%22*debug%22,lib_name + %22_debug.*%22))%0A            for f in fs:%0A                install(f, prefix.lib)%0A

add Intel TBB package