def __setup(self):
        """Based on the Linux distribution and CPU architecture, set values
        accordingly."""

        if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
            self.__ospackages = []

            if self.__upstream and not self.__version:
                self.__version = self.__trunk_version

            if self.__version:
                if Version(self.__version) <= Version('6.0'):
                    self.__compiler_debs = ['clang-{}'.format(self.__version)]
                    self.__runtime_debs = [
                        'libclang1-{}'.format(self.__version)]

                    # Versioned OpenMP libraries do not exist for
                    # older versions
                    if self.__openmp:
                        self.__compiler_debs.append('libomp-dev')
                        self.__runtime_debs.append('libomp5')

                else:
                    self.__compiler_debs = ['clang-{}'.format(self.__version)]
                    self.__runtime_debs = [
                        'libclang1-{}'.format(self.__version)]

                    if self.__openmp:
                        self.__compiler_debs.append(
                            'libomp-{}-dev'.format(self.__version))
                        self.__runtime_debs.append(
                            'libomp5-{}'.format(self.__version))

                if self.__upstream:
                    # Upstream packages from apt.llvm.org
                    if hpccm.config.g_cpu_arch == cpu_arch.PPC64LE:
                        raise RuntimeError('LLVM upstream builds are not available for ppc64le')

                    self.__apt_keys = ['https://apt.llvm.org/llvm-snapshot.gpg.key']
                    self.__apt_repositories = self.__upstream_package_repos()

                    self.__runtime_debs.append(
                        'llvm-{}-runtime'.format(self.__version))

                    self.__ospackages = ['apt-transport-https',
                                         'ca-certificates',
                                         'gnupg', 'wget']

                    self.__runtime_ospackages = self.__ospackages

                # Setup the environment so that the alternate compiler
                # version is the new default
                self.__commands.append('update-alternatives --install /usr/bin/clang clang $(which clang-{}) 30'.format(self.__version))
                self.__commands.append('update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-{}) 30'.format(self.__version))

                # Install and configure clang-format and clang-tidy
                if self.__toolset or self.__extra_tools:
                    self.__compiler_debs.extend([
                        'clang-format-{}'.format(self.__version),
                        'clang-tidy-{}'.format(self.__version)])
                    self.__commands.append('update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-{}) 30'.format(self.__version))
                    self.__commands.append('update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-{}) 30'.format(self.__version))

                # Install and configure all packages
                if self.__toolset:
                    self.__compiler_debs.extend([
                        'clang-tools-{}'.format(self.__version),
                        'libc++-{}-dev'.format(self.__version),
                        'libc++1-{}'.format(self.__version),
                        'libc++abi1-{}'.format(self.__version),
                        'libclang-{}-dev'.format(self.__version),
                        'libclang1-{}'.format(self.__version),
                        'liblldb-{}-dev'.format(self.__version),
                        'lld-{}'.format(self.__version),
                        'lldb-{}'.format(self.__version),
                        'llvm-{}-dev'.format(self.__version),
                        'llvm-{}-runtime'.format(self.__version),
                        'llvm-{}'.format(self.__version)])
                    self.__commands.append('update-alternatives --install /usr/bin/lldb lldb $(which lldb-{}) 30'.format(self.__version))
                    self.__commands.append('update-alternatives --install /usr/bin/llvm-config llvm-config $(which llvm-config-{}) 30'.format(self.__version))
                    self.__commands.append('update-alternatives --install /usr/bin/llvm-cov llvm-cov $(which llvm-cov-{}) 30'.format(self.__version))

            else:
                # Distro default
                self.__compiler_debs = ['clang']
                self.__runtime_debs = ['libclang1']

                if self.__openmp:
                    self.__compiler_debs.append('libomp-dev')
                    self.__runtime_debs.append('libomp5')

                if self.__toolset or self.__extra_tools:
                    self.__compiler_debs.extend(['clang-format', 'clang-tidy'])

                if self.__toolset:
                    self.__compiler_debs.extend([
                        'libc++-dev',
                        'libc++1',
                        'libc++abi1',
                        'libclang-dev',
                        'libclang1',
                        'lldb',
                        'llvm-dev',
                        'llvm-runtime',
                        'llvm'])

        elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
            # Dependencies on the GNU compiler
            self.__ospackages = ['gcc', 'gcc-c++']

            # Version that appears in paths below
            compiler_version = ''

            if self.__version:
                if hpccm.config.g_linux_version >= Version('8.0'):
                    # Multiple versions are not available for CentOS 8
                    self.__compiler_rpms = ['clang', 'llvm-libs']
                    self.__runtime_rpms = ['llvm-libs']
                    compiler_version = '8'

                    if self.__openmp:
                        self.__compiler_rpms.append('libomp')
                        self.__runtime_rpms.append('libomp')

                    if self.__toolset or self.__extra_tools:
                        self.__compiler_rpms.append('clang-tools-extra')

                    if self.__toolset:
                        self.__compiler_rpms.append('llvm-toolset')
                else:
                    # CentOS 7
                    self.__compiler_rpms = [
                        'llvm-toolset-{}-clang'.format(self.__version)]
                    self.__runtime_rpms = [
                        'llvm-toolset-{}-runtime'.format(self.__version),
                        'llvm-toolset-{}-compiler-rt'.format(self.__version)]
                    compiler_version = '4.8.2'

                    if self.__openmp:
                        self.__compiler_rpms.append(
                            'llvm-toolset-{}-libomp-devel'.format(self.__version))
                        self.__runtime_rpms.append(
                            'llvm-toolset-{}-libomp'.format(self.__version))

                    if self.__toolset or self.__extra_tools:
                        self.__compiler_rpms.append('llvm-toolset-{}-clang-tools-extra'.format(self.__version))

                    if self.__toolset:
                        self.__compiler_rpms.append('llvm-toolset-{}'.format(self.__version))

                    # Setup environment for devtoolset
                    self.environment_variables['PATH'] = '/opt/rh/llvm-toolset-{}/root/usr/bin:$PATH'.format(self.__version)
                    self.environment_variables['LD_LIBRARY_PATH'] = '/opt/rh/llvm-toolset-{}/root/usr/lib64:$LD_LIBRARY_PATH'.format(self.__version)
            else:
                # Distro default
                self.__compiler_rpms = ['clang']
                if hpccm.config.g_linux_version >= Version('8.0'):
                    # CentOS 8
                    self.__runtime_rpms = ['llvm-libs']
                    compiler_version = '8'

                    if self.__openmp:
                        self.__runtime_rpms.append('libomp')

                    if self.__toolset or self.__extra_tools:
                        self.__compiler_rpms.append('clang-tools-extra')

                    if self.__toolset:
                        self.__compiler_rpms.append('llvm-toolset')
                else:
                    # CentOS 7
                    self.__runtime_rpms = ['llvm-libs', 'libgomp']
                    compiler_version = '4.8.2'

                    if self.__extra_tools: # pragma: no cover
                        logging.warning('llvm extra tools are not available for default CentOS 7, specify a LLVM version')

                    if self.__toolset:
                        self.__compiler_rpms.append('llvm')

            # The default llvm configuration for CentOS is unable to
            # locate some gcc components. Setup the necessary gcc
            # environment.
            if hpccm.config.g_cpu_arch == cpu_arch.AARCH64:
                self.environment_variables['COMPILER_PATH'] = '/usr/lib/gcc/aarch64-redhat-linux/{}:$COMPILER_PATH'.format(compiler_version)
                self.environment_variables['CPATH'] = '/usr/include/c++/{0}:/usr/include/c++/{0}/aarch64-redhat-linux:/usr/lib/gcc/aarch64-redhat-linux/{0}/include:$CPATH'.format(compiler_version)
                self.environment_variables['LIBRARY_PATH'] = '/usr/lib/gcc/aarch64-redhat-linux/{}'.format(compiler_version)
            elif hpccm.config.g_cpu_arch == cpu_arch.X86_64:
                self.environment_variables['CPATH'] = '/usr/lib/gcc/x86_64-redhat-linux/{}/include:$CPATH'.format(compiler_version)
            else:
                # Packages for CentOS + PPC64LE are not available
                raise RuntimeError('Unsupported processor architecture')

        else: # pragma: no cover
            raise RuntimeError('unknown Linux distribution')
Based on the Linux distribution and CPU architecture, set values
        accordingly.
hpccm/building_blocks/llvm.py