#!/bin/bash

set -ex

if [ "x$CIP_ENV" == "x" ]; then
  echo "please set CIP_ENV to one of:"
  echo " export CIP_ENV=ALIEN_INSTALL_TYPE=share"
  echo " export CIP_ENV=ALIEN_INSTALL_TYPE=system"
  false
fi

if echo $CIP_ENV | grep -q system; then
  echo use system flex
  cip sudo apt-get update
  cip sudo apt-get -y install flex
else
  echo use internet flex
  if echo $CIP_TAG | grep -q fedora; then
    cip sudo dnf install -y m4 texinfo
  else
    cip sudo apt-get update
    cip sudo apt-get -y install m4
  fi
  env ALIEN_INSTALL_TYPE=default cip exec cpanm -n Alien::m4
fi

cip exec dzil-cpanm -n Alien::Build::Plugin::Probe::GnuWin32
