--- a/make-rules/cmake.mk Fri Jan 27 16:34:13 2017 -0800
+++ b/make-rules/cmake.mk Wed Mar 08 22:04:29 2017 -0800
@@ -20,7 +20,7 @@
#
#
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
#
#
@@ -33,7 +33,7 @@
include $(WS_MAKE_RULES)/justmake.mk
# Ensure correct version of libraries are linked to.
-LDFLAGS += "$(CC_BITS)"
+LDFLAGS += $(CC_BITS)
# This component uses cmake to generate Makefiles and so has no configure
CMAKE = $(shell which cmake)
@@ -47,23 +47,47 @@
CMAKE_OPTIONS += -DCMAKE_C_COMPILER="$(CC)"
CMAKE_OPTIONS += -DCMAKE_C_FLAGS="$(CFLAGS)"
CMAKE_OPTIONS += -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)"
+CMAKE_OPTIONS += -DCMAKE_AR="/usr/bin/ar"
# Must start install paths with a leading '/' or files will be installed into
# wrong location!
+ifeq ($(strip $(PREFERRED_BITS)),64)
+CMAKE_BINDIR.32 ?= $(CMAKE_PREFIX)/bin/$(MACH32)
+CMAKE_SBINDIR.32 ?= $(CMAKE_PREFIX)/sbin/$(MACH32)
+CMAKE_EXECDIR.32 ?= $(CMAKE_PREFIX)/lib/$(MACH32)
+CMAKE_BINDIR.64 ?= $(CMAKE_PREFIX)/bin
+CMAKE_SBINDIR.64 ?= $(CMAKE_PREFIX)/sbin
+CMAKE_EXECDIR.64 ?= $(CMAKE_PREFIX)/lib
+else
+CMAKE_BINDIR.32 ?= $(CMAKE_PREFIX)/bin
+CMAKE_SBINDIR.32 ?= $(CMAKE_PREFIX)/sbin
+CMAKE_EXECDIR.32 ?= $(CMAKE_PREFIX)/lib
+CMAKE_BINDIR.64 ?= $(CMAKE_PREFIX)/bin/$(MACH64)
+CMAKE_SBINDIR.64 ?= $(CMAKE_PREFIX)/sbin/$(MACH64)
+CMAKE_EXECDIR.64 ?= $(CMAKE_PREFIX)/lib/$(MACH64)
+endif
+
+CMAKE_OPTIONS += -DCMAKE_MAKE_PROGRAM=$(GMAKE)
+
+# Which variables to set to control installation location has changed over time
+# for CMake, so cover all of the common ones.
CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX="$(CMAKE_PREFIX)"
CMAKE_OPTIONS += -DCMAKE_MODULE_LINKER_FLAGS="$(LDFLAGS)"
CMAKE_OPTIONS += -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS)"
CMAKE_OPTIONS += -DGETTEXT_MSGFMT_EXECUTABLE="$(GNUBIN)/msgfmt"
-CMAKE_OPTIONS += -DBIN_INSTALL_DIR="$(USRBIN)"
-CMAKE_OPTIONS += -DEXEC_INSTALL_DIR="$(USRBIN)"
+CMAKE_OPTIONS += -DBIN_INSTALL_DIR="$(CMAKE_BINDIR.$(BITS))"
+CMAKE_OPTIONS += -DEXEC_INSTALL_DIR="$(CMAKE_EXECDIR.$(BITS))"
+CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(CMAKE_EXECDIR.$(BITS))"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_BINDIR="$(CMAKE_BINDIR.$(BITS))"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBEXECDIR="$(CMAKE_EXECDIR.$(BITS))"
# Some components use LIB_INSTALL_DIR, as-is, others forcibly ignore it and set
# based on CMAKE_INSTALL_PREFIX. Those usually instead offer a LIB_SUFFIX
# variable that we can generally use to accomplish the same result. Setting
# them both shouldn't harm anything.
CMAKE_OPTIONS += -DLIB_INSTALL_DIR="$(USRLIB)"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR="$(USRLIB)"
CMAKE_OPTIONS.64 += -DLIB_SUFFIX="/$(MACH64)"
-CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(USRLIB)"
# Required to ensure expected defines are set; also, ensures project's
# optimisation level set appropriately.
@@ -71,12 +95,14 @@
CMAKE_OPTIONS += $(CMAKE_OPTIONS.$(BITS))
+# Ensure cmake finds the matching 32/64-bit version of dependencies.
+COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
+
COMPONENT_PRE_BUILD_ACTION += cd $(@D);
COMPONENT_PRE_BUILD_ACTION += echo Running cmake with $(CMAKE_OPTIONS);
-COMPONENT_PRE_BUILD_ACTION += $(CMAKE) . $(CMAKE_OPTIONS);
-
-# Ensure cmake finds the matching 32/64-bit version of dependencies.
-COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
+COMPONENT_PRE_BUILD_ACTION += /usr/bin/env - $(COMPONENT_BUILD_ENV) \
+ $(CMAKE) $(CMAKE_OPTIONS) \
+ $(COMPONENT_DIR)/$(COMPONENT_SRC);
REQUIRED_PACKAGES += developer/build/cmake
REQUIRED_PACKAGES += developer/build/pkg-config