+# How do we link OCaml executables with LLVM?
+# 1) If this is a --enable-shared build, build stub libraries. This also allows
+# to use LLVM from toplevels.
+# 2) If this is a --disable-shared build, embed ocamlc options for building
+# a custom runtime and a static executable. It is not possible to use LLVM
+# from toplevels.
+ifneq ($(ObjectsO),)
+ifeq ($(ENABLE_SHARED),1)
+OCAMLSTUBS := 1
+OCAMLSTUBFLAGS := $(patsubst %,-cclib %, $(LLVMLibsOptions) -l$(LIBRARYNAME))
+endif
+endif
+
+# Avoid the need for LD_LIBRARY_PATH
+ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ifneq ($(HOST_OS),Darwin)
+OCAMLRPATH := $(RPATH) -Wl,'$$ORIGIN/../../lib'
+endif
+endif
+