Skip to content

Instantly share code, notes, and snippets.

@jperkin
Created February 15, 2016 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperkin/1c85056f66ade8f97efc to your computer and use it in GitHub Desktop.
Save jperkin/1c85056f66ade8f97efc to your computer and use it in GitHub Desktop.
diff --git a/lang/ocaml/buildlink3.mk b/lang/ocaml/buildlink3.mk
index e95aaf5..f32df30 100644
--- a/lang/ocaml/buildlink3.mk
+++ b/lang/ocaml/buildlink3.mk
@@ -25,6 +25,7 @@ ocaml-wrappers:
-e 's|@OCAML_PREFIX@|${BUILDLINK_PREFIX.ocaml}|g' \
-e 's|@CFLAGS@|'${CFLAGS:Q}'|g' \
-e 's|@LDFLAGS@|'${LDFLAGS:Q}'|g' \
+ -e 's|@WRAPPEE@|'$$w'|g' \
< ${.CURDIR}/../../lang/ocaml/files/wrapper.sh \
> ${BUILDLINK_DIR}/bin/"$$w"; \
${CHMOD} +x ${BUILDLINK_DIR}/bin/"$$w"; \
diff --git a/lang/ocaml/files/wrapper.sh b/lang/ocaml/files/wrapper.sh
index 7eac075..a512afb 100644
--- a/lang/ocaml/files/wrapper.sh
+++ b/lang/ocaml/files/wrapper.sh
@@ -5,9 +5,9 @@
BINDIR='@OCAML_PREFIX@'
CFLAGS='@CFLAGS@'
LDFLAGS='@LDFLAGS@'
+WRAPPEE='@WRAPPEE@'
-if echo "$@" | grep ' -c ' >/dev/null
-then
+if echo "$@" | grep ' -c ' >/dev/null || [ "${WRAPPEE}" = "ocamlmklib" ]; then
flags="${CFLAGS}"
else
flags="${CFLAGS} ${LDFLAGS}"
@@ -18,4 +18,8 @@ do
MLFLAGS="${MLFLAGS} -ccopt ${f}"
done
-exec "@OCAML_PREFIX@/bin/`basename $0`" ${MLFLAGS} "$@"
+if [ "${WRAPPEE}" = "ocamlmklib" ]; then
+ MLFLAGS="${MLFLAGS} ${LDFLAGS}"
+fi
+
+exec "@OCAML_PREFIX@/bin/${WRAPPEE}" ${MLFLAGS} "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment