def AcPathProg(context, program, selection=None, value_if_not_found=None,
                  path=None, pathext=None, reject=[], prog_str=None):
    """Corresponds to AC_PATH_PROG_ autoconf macro.

    :Parameters:
        context
            SCons configuration context.
        program
            Name of the program to be checked.
        selection
            If ``None`` (default), the program will be found automatically,
            otherwise the method will return the value of **selection**.
        value_if_not_found
            Value to be returned, when the program is not found.
        path
            Search path.
        pathext
            Extensions used for executable files.
        reject
            List of file names to be rejected if found.
        prog_str
            Used to display 'Checking for <prog_str>...' message.

    .. _AC_PATH_PROG: http://www.gnu.org/software/autoconf/manual/autoconf.html#index-AC_005fPATH_005fPROG-318
    """
    if prog_str is None:
        prog_str = program

    context.Display("Checking for %s... " % prog_str)

    if not selection:
        progpath = context.env.WhereIs(program, path, pathext, reject)
        if progpath:
            context.Result(progpath)
        else:
            if value_if_not_found:
                progpath = value_if_not_found
                context.Result("not found, using '%s'" % progpath)
            else:
                context.Result('no')
        return progpath
    else:
        context.Result(str(selection))
        return selection