(rule
 (targets coqtop-prelude)
 (deps
  %{bin:coqtop}
  %{project_root}/theories/Init/Prelude.vo)
 (action
  (with-stdout-to coqtop-prelude
   (progn
    (echo "#!/usr/bin/env bash\n")
    (bash "echo '\"$(dirname \"$0\")\"/%{bin:coqtop} -coqlib \"$(dirname \"$0\")/%{project_root}\" \"$@\"'")
    (run chmod +x %{targets})))))

(rule
 (targets coqc-prelude)
 (deps
  %{bin:coqc}
  %{project_root}/theories/Init/Prelude.vo)
 (action
  (with-stdout-to coqc-prelude
   (progn
    (echo "#!/usr/bin/env bash\n")
    (bash "echo '\"$(dirname \"$0\")\"/%{bin:coqc} -coqlib \"$(dirname \"$0\")\"/%{project_root} \"$@\"'")
    (run chmod +x %{targets})))))

(rule
 (targets coqbyte-prelude)
 (deps
  %{project_root}/theories/Init/Prelude.vo
  %{bin:coqtop.byte}
  %{lib:coq-core.config:config.cma}
  %{lib:coq-core.clib:clib.cma}
  %{lib:coq-core.lib:lib.cma}
  %{lib:coq-core.kernel:kernel.cma}
  %{lib:coq-core.vm:coqrun.cma}
  %{lib:coq-core.vm:../../stublibs/dllcoqrun_stubs.so}
  %{lib:coq-core.library:library.cma}
  %{lib:coq-core.engine:engine.cma}
  %{lib:coq-core.pretyping:pretyping.cma}
  %{lib:coq-core.gramlib:gramlib.cma}
  %{lib:coq-core.interp:interp.cma}
  %{lib:coq-core.proofs:proofs.cma}
  %{lib:coq-core.parsing:parsing.cma}
  %{lib:coq-core.printing:printing.cma}
  %{lib:coq-core.tactics:tactics.cma}
  %{lib:coq-core.vernac:vernac.cma}
  %{lib:coq-core.stm:stm.cma}
  %{lib:coq-core.sysinit:sysinit.cma}
  %{lib:coq-core.toplevel:toplevel.cma}
  %{lib:coq-core.plugins.number_string_notation:number_string_notation_plugin.cma}
  %{lib:coq-core.plugins.tauto:tauto_plugin.cma}
  %{lib:coq-core.plugins.cc:cc_plugin.cma}
  %{lib:coq-core.plugins.firstorder:firstorder_plugin.cma}
  %{lib:coq-core.plugins.ltac:ltac_plugin.cma})
 (action
  (with-stdout-to %{targets}
   (progn
    (echo "#!/usr/bin/env bash\n")
    (bash "echo '\"$(dirname \"$0\")\"/%{bin:coqtop.byte} -coqlib \"$(dirname \"$0\")\"/%{project_root} \"$@\"'")
    (run chmod +x %{targets})))))

(rule
 (targets coqide-prelude)
 (deps
  ; without this if the gtk libs are not available dune can try to use
  ; coqide from PATH instead of giving a nice error
  ; there is no problem with the other shims since they don't depend on optional build products
  %{project_root}/ide/coqide/coqide_main.exe

  %{bin:coqqueryworker.opt}
  %{bin:coqtacticworker.opt}
  %{bin:coqproofworker.opt}
  %{project_root}/theories/Init/Prelude.vo
  %{project_root}/coqide-server.install
  %{project_root}/coqide.install)
 (action
  (with-stdout-to coqide-prelude
   (progn
    (echo "#!/usr/bin/env bash\n")
    (bash "echo '\"$(dirname \"$0\")\"/%{bin:coqide} -coqlib \"$(dirname \"$0\")\"/%{project_root} \"$@\"'")
    (run chmod +x %{targets})))))
