From 61f532d2f8ad272d4fed2aedde1c10d857f7a776 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Mon, 10 Oct 2016 10:31:47 -0700 Subject: [PATCH] [Makefiles] Use custom CC in ocamlopt only when configure flag is set Summary: Introduce `--enable-ocamlopt-custom-cc` configure flag (disabled by default). Normally it doesn't have to be set. However, when cross-compiling infer itself for another platform it may have to be set. Reviewed By: jberdine Differential Revision: D3995032 fbshipit-source-id: ce2fd72 --- Makefile.config.in | 1 + configure.ac | 6 ++++++ infer/src/Makefile | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile.config.in b/Makefile.config.in index 7606f68ac..2df66d433 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -20,6 +20,7 @@ CLANG_PREFIX = @CLANG_PREFIX@ CPP = @CPP@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ +ENABLE_OCAMLOPT_CUSTOM_CC = @ENABLE_OCAMLOPT_CUSTOM_CC@ ENABLE_OCAML_ANNOT = @ENABLE_OCAML_ANNOT@ ENABLE_OCAML_BINANNOT = @ENABLE_OCAML_BINANNOT@ exec_prefix = @exec_prefix@ diff --git a/configure.ac b/configure.ac index e6750f5eb..e2e5bceed 100644 --- a/configure.ac +++ b/configure.ac @@ -102,6 +102,12 @@ AS_IF([test "x$enable_c_analyzers" = "xyes"], [ AC_CHECK_TOOL([CMAKE], [cmake], [no]) AC_ASSERT_PROG([cmake], [$CMAKE]) ]) + AC_ARG_ENABLE(ocamlopt-custom-cc, + AS_HELP_STRING([--enable-ocamlopt-custom-cc], [use CC in ocamlopt invocations]), + , + enable_ocamlopt_custom_cc=no) + ENABLE_OCAMLOPT_CUSTOM_CC=$enable_ocamlopt_custom_cc + AC_SUBST([ENABLE_OCAMLOPT_CUSTOM_CC]) ]) # end if($enable_c_analyzers) diff --git a/infer/src/Makefile b/infer/src/Makefile index 262f6429a..d86ef627b 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -22,8 +22,6 @@ OCAML_FATAL_WARNINGS = +5+6+8+10+11+12+18+19+20+23+26+29+27+32+33+34+35+37+38+39 OCAMLBUILD_OPTIONS = \ -r \ - -lflags -cc,$(CC) \ - -cflags -cc,$(CC) \ -cflags -g -lflags -g \ -cflags -short-paths \ -cflags -safe-string \ @@ -42,6 +40,10 @@ ifeq ($(ENABLE_OCAML_BINANNOT),yes) OCAMLBUILD_OPTIONS += -cflags -bin-annot endif +ifeq ($(ENABLE_OCAMLOPT_CUSTOM_CC),yes) +OCAMLBUILD_OPTIONS += -lflags -cc,$(CC) -cflags -cc,$(CC) +endif + ifneq (,$(findstring s,$(MAKEFLAGS))) OCAMLBUILD_OPTIONS += -quiet endif