Revert "gcc-6: drop documentation patches"
[unleashed-userland.git] / make-rules / cmake.mk
blobbf0f58476f872f3a47d86d6a86fbef312cfcb5be
2 # CDDL HEADER START
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
19 # CDDL HEADER END
21 # Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
22 # Copyright 2011 EveryCity Ltd. All rights reserved.
23 # Copyright 2013 Aurelien Larcher. All rights reserved.
27 # Rules and Macros for building open source software that uses the CMake utility
28 # from Kitware (http://www.cmake.org) to configure the build.
29 # This file implements the same rules as configure.mk and thus uses GNU Make
30 # to build the components with support of multiple version (32/64 bit).
32 # To use these rules, include ../make-rules/cmake.mk in your Makefile
33 # and define "build", "install", and "test" targets appropriate to building
34 # your component.
35 # Ex:
37 # build: $(SOURCE_DIR)/build/$(MACH32)/.built \
38 # $(SOURCE_DIR)/build/$(MACH64)/.built
40 # install: $(SOURCE_DIR)/build/$(MACH32)/.installed \
41 # $(SOURCE_DIR)/build/$(MACH64)/.installed
43 # test: $(SOURCE_DIR)/build/$(MACH32)/.tested \
44 # $(SOURCE_DIR)/build/$(MACH64)/.tested
46 # Any additional pre/post configure, build, or install actions can be specified
47 # in your make file by setting them in on of the following macros:
48 # COMPONENT_PRE_CMAKE_ACTION, COMPONENT_POST_CMAKE_ACTION
49 # COMPONENT_PRE_BUILD_ACTION, COMPONENT_POST_BUILD_ACTION
50 # COMPONENT_PRE_INSTALL_ACTION, COMPONENT_POST_INSTALL_ACTION
51 # COMPONENT_PRE_TEST_ACTION, COMPONENT_POST_TEST_ACTION
53 # If component specific make targets need to be used for build or install, they
54 # can be specified in
55 # COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS
56 # COMPONENT_TEST_TARGETS
59 CMAKE_PREFIX = /usr
62 # Define path the same way as configure.mk
63 # Ref: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs
66 CMAKE_BINDIR.32 = bin
67 CMAKE_BINDIR.64 = bin/$(MACH64)
68 CMAKE_SBINDIR.32 = sbin
69 CMAKE_SBINDIR.64 = sbin/$(MACH64)
70 CMAKE_LIBDIR.32 = lib
71 CMAKE_LIBDIR.64 = lib/$(MACH64)
72 CMAKE_INCLUDEDIR = include
73 CMAKE_DATAROOTDIR = share
74 CMAKE_INFODIR = share/info
75 CMAKE_LOCALEDIR = share/locale
76 CMAKE_MANDIR = share/man
78 CMAKE_ENV = CC="$(CC)"
79 CMAKE_ENV += CXX="$(CXX)"
80 CMAKE_ENV += F77="$(F77)"
81 CMAKE_ENV += FC="$(FC)"
82 CMAKE_ENV += CFLAGS="$(CFLAGS)"
83 CMAKE_ENV += CXXFLAGS="$(CXXFLAGS)"
84 CMAKE_ENV += FFLAGS="$(F77FLAGS)"
85 CMAKE_ENV += FCFLAGS="$(FCFLAGS)"
86 CMAKE_ENV += LDFLAGS="$(LDFLAGS)"
87 CMAKE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
89 # Rewrite absolute source-code paths into relative for ccache, so that any
90 # workspace with a shared CCACHE_DIR can benefit when compiling a component
91 ifneq ($(strip $(CCACHE)),)
92 CMAKE_ENV += CCACHE="$(CCACHE)"
93 CMAKE_ENV += CC_gcc_32="$(CC_gcc_32)"
94 CMAKE_ENV += CC_gcc_64="$(CC_gcc_32)"
95 CMAKE_ENV += CXX_gcc_32="$(CXX_gcc_64)"
96 CMAKE_ENV += CXX_gcc_64="$(CXX_gcc_64)"
97 CMAKE_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
99 ifneq ($(strip $(CCACHE_DIR)),)
100 CMAKE_ENV += CCACHE_DIR="$(CCACHE_DIR)"
101 endif
103 ifneq ($(strip $(CCACHE_LOGFILE)),)
104 CMAKE_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
105 endif
107 endif
109 CMAKE_DEFAULT_DIRS?=yes
111 CMAKE_OPTIONS += -DCMAKE_C_COMPILER:STRING="$(CC)"
112 CMAKE_OPTIONS += -DCMAKE_CXX_COMPILER:STRING="$(CXX)"
113 CMAKE_OPTIONS += -DCMAKE_Fortran_COMPILER:STRING="$(FC)"
114 CMAKE_OPTIONS += -DCMAKE_C_FLAGS:STRING="$(CFLAGS)"
115 CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS:STRING="$(CXXFLAGS)"
116 CMAKE_OPTIONS += -DCMAKE_Fortran_FLAGS:STRING="$(FCFLAGS)"
118 CMAKE_OPTIONS += LDFLAGS="$(LDFLAGS)"
119 CMAKE_OPTIONS += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
121 CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX:PATH=$(CMAKE_PREFIX)
122 ifeq ($(CMAKE_DEFAULT_DIRS),yes)
123 CMAKE_OPTIONS += -DCMAKE_INSTALL_BINDIR:PATH=$(CMAKE_BINDIR.$(BITS))
124 CMAKE_OPTIONS += -DCMAKE_INSTALL_SBINDIR:PATH=$(CMAKE_SBINDIR.$(BITS))
125 CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR:PATH=$(CMAKE_LIBDIR.$(BITS))
126 CMAKE_OPTIONS += -DCMAKE_INSTALL_DATAROOTDIR:PATH=$(CMAKE_DATAROOTDIR)
127 CMAKE_OPTIONS += -DCMAKE_INSTALL_DATADIR:PATH=$(CMAKE_DATAROOTDIR)
128 CMAKE_OPTIONS += -DCMAKE_INSTALL_INFODIR:PATH=$(CMAKE_INFODIR)
129 CMAKE_OPTIONS += -DCMAKE_INSTALL_LOCALEDIR:PATH=$(CMAKE_LOCALEDIR)
130 CMAKE_OPTIONS += -DCMAKE_INSTALL_MANDIR:PATH=$(CMAKE_MANDIR)
131 endif
132 CMAKE_OPTIONS += $(CMAKE_OPTIONS.$(BITS))
134 COMPONENT_INSTALL_ARGS += DESTDIR=$(PROTO_DIR)
136 $(BUILD_DIR_32)/.configured: BITS=32
137 $(BUILD_DIR_64)/.configured: BITS=64
139 CMAKE_ENV += $(CMAKE_ENV.$(BITS))
141 # configure the unpacked source for building 32 and 64 bit version
142 CMAKE = cmake
143 $(BUILD_DIR)/%/.configured: $(SOURCE_DIR)/.prep
144 ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
145 $(COMPONENT_PRE_CMAKE_ACTION)
146 (cd $(@D) ; $(ENV) $(CMAKE_ENV) \
147 $(CMAKE) $(CMAKE_OPTIONS) $(SOURCE_DIR))
148 $(COMPONENT_POST_CMAKE_ACTION)
149 $(TOUCH) $@
151 # build the configured source
152 $(BUILD_DIR)/%/.built: $(BUILD_DIR)/%/.configured
153 $(COMPONENT_PRE_BUILD_ACTION)
154 (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
155 $(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \
156 $(COMPONENT_BUILD_TARGETS))
157 $(COMPONENT_POST_BUILD_ACTION)
158 ifeq ($(strip $(PARFAIT_BUILD)),yes)
159 -$(PARFAIT) build
160 endif
161 $(TOUCH) $@
163 # install the built source into a prototype area
164 $(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built
165 $(COMPONENT_PRE_INSTALL_ACTION)
166 (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
167 $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
168 $(COMPONENT_POST_INSTALL_ACTION)
169 $(TOUCH) $@
171 # test the built source
172 $(BUILD_DIR)/%/.tested-and-compared: $(BUILD_DIR)/%/.built
173 $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
174 $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
175 $(COMPONENT_PRE_TEST_ACTION)
176 -(cd $(COMPONENT_TEST_DIR) ; \
177 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
178 $(COMPONENT_TEST_CMD) \
179 $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
180 &> $(COMPONENT_TEST_OUTPUT)
181 $(COMPONENT_POST_TEST_ACTION)
182 $(COMPONENT_TEST_CREATE_TRANSFORMS)
183 $(COMPONENT_TEST_PERFORM_TRANSFORM)
184 $(COMPONENT_TEST_COMPARE)
185 $(COMPONENT_TEST_CLEANUP)
186 $(TOUCH) $@
188 $(BUILD_DIR)/%/.tested: $(BUILD_DIR)/%/.built
189 $(COMPONENT_PRE_TEST_ACTION)
190 (cd $(COMPONENT_TEST_DIR) ; \
191 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
192 $(COMPONENT_TEST_CMD) \
193 $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS))
194 $(COMPONENT_POST_TEST_ACTION)
195 $(COMPONENT_TEST_CLEANUP)
196 $(TOUCH) $@
198 ifeq ($(strip $(PARFAIT_BUILD)),yes)
199 parfait: install
200 -$(PARFAIT) build
201 else
202 parfait:
203 $(MAKE) PARFAIT_BUILD=yes parfait
204 endif
206 clean::
207 $(RM) -r $(BUILD_DIR) $(PROTO_DIR)