def __setup(self):
        """Construct the series of shell commands, i.e., fill in
           self.__commands"""

        # The download URL format contains MAJOR.MINOR.REVSION and
        # MAJOR_MINOR_REVISION
        buildscript = self.__buildscript.format(
            self.__version.replace('.', '_'))
        url = self.__url.format(self.__version, buildscript)

        # Download source from web
        self.__commands.append(self.download_step(url=url, directory=self.__wd))

        # Set options
        env = []
        opts = self.__opts
        if self.__mpi:
            env.append('PAR_COMPILER=mpicc')
            opts.extend(['--parallel', '--no-icet'])
        if self.__parallel:
            opts.append('--makeflags -j{}'.format(self.__parallel))
        if self.__prefix:
            opts.append('--prefix {}'.format(self.__prefix))
        if self.__system_cmake:
            opts.append('--system-cmake')
        if self.__system_python:
            opts.append('--system-python')
        if self.__thirdparty:
            thirdparty_path = posixpath.join(self.__prefix, 'third-party')
            opts.append('--thirdparty-path {}'.format(thirdparty_path))
            self.__commands.append('mkdir -p {}'.format(thirdparty_path))

        # Build
        self.__commands.append('cd {0} && {1} bash {2} {3}'.format(
            self.__wd, ' '.join(env), buildscript, ' '.join(opts)))

        # Set library path
        libpath = posixpath.join(self.__prefix, self.__version, self.__arch)
        suffix1 = 'lib'
        suffix2 = posixpath.join('libsim', 'V2', 'lib')
        if self.ldconfig:
            self.__commands.append(self.ldcache_step(
                directory=posixpath.join(libpath, suffix1)))
            self.__commands.append(self.ldcache_step(
                directory=posixpath.join(libpath, suffix2)))
        else:
            self.environment_variables['LD_LIBRARY_PATH'] = '{0}:{1}:$LD_LIBRARY_PATH'.format(posixpath.join(libpath, suffix1), posixpath.join(libpath, suffix2))

        # Cleanup
        self.__commands.append(self.cleanup_step(
            items=[posixpath.join(self.__wd)]))

        # Set the environment
        self.environment_variables['PATH'] = '{}:$PATH'.format(
            posixpath.join(self.__prefix, 'bin'))
Construct the series of shell commands, i.e., fill in
           self.__commands
hpccm/building_blocks/libsim.py