import shutil


def create_make_command(keyboard, keymap, target=None):
    """Create a make compile command

    Args:

        keyboard
            The path of the keyboard, for example 'plank'

        keymap
            The name of the keymap, for example 'algernon'

        target
            Usually a bootloader.

    Returns:

        A command that can be run to make the specified keyboard and keymap
    """
    make_args = [keyboard, keymap]
    make_cmd = 'gmake' if shutil.which('gmake') else 'make'

    if target:
        make_args.append(target)

    return [make_cmd, ':'.join(make_args)]