12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788(************************************************************************)(* * The Rocq Prover / The Rocq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)(* Makefile's escaping rules are awful: $ is escaped by doubling and
other special characters are escaped by backslash prefixing while
backslashes themselves must be escaped only if part of a sequence
followed by a special character (i.e. in case of ambiguity with a
use of it as escaping character). Moreover (even if not crucial)
it is apparently not possible to directly escape ';' and leading '\t'. *)letescape=lets'=Buffer.create10infuns->Buffer.clears';fori=0toString.lengths-1doletc=s.[i]inifc=' '||c='#'||c=':'(* separators and comments *)||c='%'(* pattern *)||c='?'||c='['||c=']'||c='*'(* expansion in filenames *)||i=0&&c='~'&&(String.lengths=1||s.[1]='/'||'A'<=s.[1]&&s.[1]<='Z'||'a'<=s.[1]&&s.[1]<='z')(* homedir expansion *)thenbeginletj=ref(i-1)inwhile!j>=0&&s.[!j]='\\'doBuffer.add_chars''\\';decrj(* escape all preceding '\' *)done;Buffer.add_chars''\\';end;ifc='$'thenBuffer.add_chars''$';Buffer.add_chars'cdone;Buffer.contentss'openFormattypedynlink=Opt|Byte|Both|No|Variableletoption_dynlink=refBothletset_dyndep=function|"no"->option_dynlink:=No|"opt"->option_dynlink:=Opt|"byte"->option_dynlink:=Byte|"both"->option_dynlink:=Both|"var"->option_dynlink:=Variable|o->CErrors.user_errPp.(str"Incorrect -dyndep option: "++stro)letmldep_to_makebase=match!option_dynlinkwith|No->[]|Byte->[sprintf"%s.cma"base]|Opt->[sprintf"%s.cmxs"base]|Both->[sprintf"%s.cma"base;sprintf"%s.cmxs"base]|Variable->[sprintf"%s%s"base"$(DYNLIB)"]letstring_of_dep~suffix=letopenDep_info.Depinfunction|Requirebasename->[escapebasename^suffix]|Mlbase->mldep_to_make(escapebase)|Others->[escapes]letstring_of_dependency_list~suffixdeps=List.map(string_of_dep~suffix)deps|>List.concat|>String.concat" "letoption_noglob=reffalseletoption_write_vos=reffalseletset_noglobglob=option_noglob:=globletset_write_vosvos=option_write_vos:=vosletprint_depfmt{Dep_info.name;deps}=letename=escapenameinletglob=if!option_noglobthen""elseename^".glob "infprintffmt"%s.vo %s%s.v.beautified %s.required_vo: %s.v %s\n"enameglobenameenameename(string_of_dependency_list~suffix:".vo"deps);if!option_write_vosthenfprintffmt"%s.vos %s.vok %s.required_vos: %s.v %s\n"enameenameenameename(string_of_dependency_list~suffix:".vos"deps);fprintffmt"%!"