---

- name: 'Check existence'
  shell: '[ "$(command -v xwinwrap)" ] || [ -x {{ xwinwrap_prefix | quote }}/bin/xwinwrap ]'
  register: xwinwrap_exists
  changed_when: xwinwrap_exists.rc != 0
  failed_when: false

- name: 'Install build dependencies'
  become: yes
  apt:
    name:
      - 'make'
      - 'gcc'
      - 'libc6-dev'
      - 'xorg-dev'
      - 'libx11-dev'
      - 'libxext-dev'
      - 'libxrender-dev'
      - 'x11proto-dev'
  when: xwinwrap_exists.rc != 0

- name: 'Clone, build and install'
  script: 'install {{ xwinwrap_prefix | quote }} {{ xwinwrap_repo | quote }}'
  when: xwinwrap_exists.rc != 0