(rule
 (target liquidsoap.config)
 (enabled_if %{env:LIQUIDSOAP_ENABLE_BUILD_CONFIG=true})
 (deps
  src/libs/stdlib.liq
  (source_tree src/libs))
 (mode
  (promote
   (only liquidsoap.config)
   (until-clean)))
 (action
  (progn
   (echo
    "\nCongratulation on building liquidsoap! Here are the details of your build and configuration:\n")
   (run %{bin:liquidsoap} --build-config)
   (with-stdout-to
    %{target}
    (run %{bin:liquidsoap} --opam-config)))))

(rule
 (target liquidsoap.config)
 (package liquidsoap)
 (enabled_if
  (not %{env:LIQUIDSOAP_ENABLE_BUILD_CONFIG=true}))
 (mode
  (promote
   (only liquidsoap.config)
   (until-clean)))
 (action
  (with-stdout-to
   %{target}
   (echo "Congratulation on building liquidsoap!\n"))))

(rule
 (target .git-setup)
 (enabled_if %{bin-available:git})
 (mode
  (promote (until-clean)))
 (action
  (progn
   (run git config --local include.path ../.gitconfig)
   (with-stdout-to
    %{target}
    (echo "")))))

(rule
 (target .git-setup)
 (enabled_if
  (not %{bin-available:git}))
 (mode
  (promote (until-clean)))
 (action
  (with-stdout-to
   %{target}
   (echo ""))))

(alias
 (name default)
 (deps
  .git-setup
  liquidsoap.config
  (alias_rec src/libs/install)))

(alias
 (name runtest)
 (deps
  (alias_rec src/libs/install)))

(alias
 (name citest)
 (deps
  (alias_rec perftest)
  (alias_rec runtest)))

(alias
 (name doctest)
 (deps
  (alias_rec doc)))
