OCAMLBUILD(1)

πŸ’– OCAMLBUILD(1) πŸ’–

okay bestie, welcome to the General Commands Manual entry for ocamlbuild β€” the OCaml project compilation tool. pull up a chair, grab a strawberry, and let's get you compiling πŸ“βœ¨


🌸 NAME 🌸

ocamlbuild β€” the OCaml project compilation tool πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

ocamlbuild [ -Is dir1,... ] [ -libs lib1,... ] [ -lflags flag1,... ]
           [ -pp flags ] [ -tags tag1,... ] [ -j parallel-jobs ] target.native
           [ -- arg1 arg2 ... ]

(same options)

like, that's the whole vibe. one target, a pile of flags, and optionally some args you're yeeting straight at your own program 🫢


✨ DESCRIPTION ✨

so ocamlbuild(1) orchestrates the compilation process of your OCaml project. it's giving make(1) energy, except it's tailor-made to automatically compile most OCaml projects with very little user input. main character energy fr fr πŸ‘‘

ocamlbuild should be invoked in the root of a clean project tree β€” and yes, "clean" means like, no leftover compilation files lying around. no cap. πŸ™ˆ

give it one or more targets to compile and it:

  • scans the required subdirectories to gather info about the various files present
  • runs tools such as ocamldep(1) to extract dependency information
  • gathers optional files that fine-tune its behaviour
bestie, listen: target names are very significant. iykyk πŸ”₯

πŸŽ€ TARGET NAMES πŸŽ€

ocamlbuild uses a set of target naming conventions to pick what kind of object to produce. target names look like base.extension where base is usually the name of the underlying OCaml module, and extension says what kind of object to make from that file β€” a byte code executable, a native executable, documentation... literally whatever ✨

and ofc extensions like .cmo, .cma, .cmi... map to their usual counterparts, as they should πŸ’–

here's the list of the most important ocamlbuild-specific extensions:

  • .native β€” Native code executable πŸ”₯
  • .byte β€” Byte code executable πŸ¦‹
  • .inferred.mli β€” Interface inferred with ocamlc-i πŸ‘‘
  • .docdir/index.html β€” HTML documentation generated with ocamldoc πŸ“š

πŸ’… OPTIONS πŸ’…

the following command-line options are recognized by ocamlbuild(1). yes, there are a LOT. we're doing all of them. no skipping. periodt. πŸ’€

  • -version β€” Display the version
  • --version β€” same as -version
  • -vnum β€” Display the version number
  • --vnum β€” same as -vnum
  • -quiet β€” Make as quiet as possible 🀫
  • -verbose <level> β€” Set the verbosity level on a scale from 0 to 8 (included)
  • -documentation β€” Show rules and flags
  • -log <file> β€” Set log file
  • -no-log β€” No log file
  • -clean β€” Remove build directory and other files, then exit 🧹
  • -r β€” Traverse directories by default (true: traverse)
  • -I <path> β€” Add to include directories
  • -Is <path,...> β€” (same as above, but accepts a (comma or blank)-separated list)
  • -X <path> β€” Directory to ignore πŸ™…β€β™€οΈ
  • -Xs <path,...> β€” (idem)
  • -lib <flag> β€” Link to this ocaml library
  • -libs <flag,...> β€” (idem)
  • -mod <module> β€” Link to this ocaml module
  • -mods <module,...> β€” (idem)
  • -pkg <package> β€” Link to this ocaml findlib package
  • -pkgs <package,...> β€” (idem)
  • -package <package> β€” (idem)
  • -syntax <syntax> β€” Specify syntax using ocamlfind
  • -lflag <flag> β€” Add to ocamlc link flags
  • -lflags <flag,...> β€” (idem)
  • -cflag <flag> β€” Add to ocamlc compile flags
  • -cflags <flag,...> β€” (idem)
  • -docflag <flag> β€” Add to ocamldoc flags
  • -docflags <flag,...> β€” (idem)
  • -yaccflag <flag> β€” Add to ocamlyacc flags
  • -yaccflags <flag,...> β€” (idem)
  • -lexflag <flag> β€” Add to ocamllex flags
  • -lexflags <flag,...> β€” (idem)
  • -ppflag <flag> β€” Add to ocaml preprocessing flags
  • -pp <flag,...> β€” (idem)
  • -tag <tag> β€” Add to default tags
  • -tags <tag,...> β€” (idem)
  • -plugin-tag <tag> β€” Use this tag when compiling the myocamlbuild.ml plugin
  • -plugin-tags <tag,...> β€” (idem)
  • -tag-line <tag> β€” Use this line of tags (as in _tags)
  • -show-tags <path> β€” Show tags that applies on that pathname
  • -ignore <module,...> β€” Don't try to build these modules
  • -no-links β€” Don't make links of produced final targets
  • -no-skip β€” Don't skip modules that are requested by ocamldep but cannot be built
  • -no-hygiene β€” Don't apply sanity-check rules
  • -no-plugin β€” Don't build myocamlbuild.ml
  • -no-stdlib β€” Don't ignore stdlib modules
  • -dont-catch-errors β€” Don't catch and display exceptions (useful to display the call stack)
  • -just-plugin β€” Just build myocamlbuild.ml
  • -byte-plugin β€” Don't use a native plugin but bytecode
  • -plugin-option β€” Use the option only when plugin is run
  • -sanitization-script β€” Change the file name for the generated sanitization script
  • -no-sanitize β€” Do not generate sanitization script
  • -nothing-should-be-rebuilt β€” Fail if something needs to be rebuilt
  • -classic-display β€” Display executed commands the old-fashioned way
  • -use-menhir β€” Use menhir instead of ocamlyacc
  • -use-jocaml β€” Use jocaml compilers instead of ocaml ones
  • -use-ocamlfind β€” Use the 'ocamlfind' wrapper instead of using Findlib directly to determine command-line arguments. Use -no-ocamlfind to disable. Implies -plugin-use-ocamlfind.
  • -no-ocamlfind β€” Don't use ocamlfind. Implies -plugin-no-ocamlfind.
  • -plugin-use-ocamlfind β€” Use the 'ocamlfind' wrapper for building myocamlbuild.ml
  • -plugin-no-ocamlfind β€” Don't use ocamlfind for building myocamlbuild.ml
  • -toolchain <toolchain> β€” Set the Findlib toolchain to use. The default toolchain is always used for building myocamlbuild.ml.
  • -j <N> β€” Allow N jobs at once (0 for unlimited)
  • -build-dir <path> β€” Set build directory (implies no-links)
  • -install-lib-dir <path> β€” Set the install library directory
  • -install-bin-dir <path> β€” Set the install binary directory
  • -where β€” Display the install library directory
  • -which <command> β€” Display path to the tool command
  • -ocamlc <command> β€” Set the OCaml bytecode compiler
  • -plugin-ocamlc <command> β€” Set the OCaml bytecode compiler used when building myocamlbuild.ml (only)
  • -ocamlopt <command> β€” Set the OCaml native compiler
  • -plugin-ocamlopt <command> β€” Set the OCaml native compiler used when building myocamlbuild.ml (only)
  • -ocamldep <command> β€” Set the OCaml dependency tool
  • -ocamldoc <command> β€” Set the OCaml documentation generator
  • -ocamlyacc <command> β€” Set the ocamlyacc tool
  • -menhir <command> β€” Set the menhir tool (use it after -use-menhir)
  • -ocamllex <command> β€” Set the ocamllex tool
  • -ocamlmklib <command> β€” Set the ocamlmklib tool
  • -ocamlmktop <command> β€” Set the ocamlmktop tool
  • -ocamlrun <command> β€” Set the ocamlrun tool
  • -- β€” Stop argument processing, remaining arguments are given to the user program
  • -help β€” Display this list of options
  • --help β€” Display this list of options

🌈 SEE ALSO 🌈

  • The ocamlbuild manual, ocaml(1), make(1).
  • The OCaml user's manual, chapter Batch compilation.

and that's the whole page bestie πŸ’œ you made it to the end, iconic behaviour honestly. this was OCAMLBUILD(1) from the General Commands Manual β€” go forth and build, and remember: target names are significant, keep your tree clean, and slay βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from