commit | author | age
|
9074b6
|
1 |
# |
AL |
2 |
# CDDL HEADER START |
|
3 |
# |
|
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. |
|
7 |
# |
|
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. |
|
12 |
# |
|
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] |
|
18 |
# |
|
19 |
# CDDL HEADER END |
|
20 |
# |
|
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. |
|
24 |
# |
|
25 |
|
|
26 |
# |
|
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). |
|
31 |
# |
|
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: |
|
36 |
# |
|
37 |
# build: $(SOURCE_DIR)/build/$(MACH32)/.built \ |
|
38 |
# $(SOURCE_DIR)/build/$(MACH64)/.built |
|
39 |
# |
|
40 |
# install: $(SOURCE_DIR)/build/$(MACH32)/.installed \ |
|
41 |
# $(SOURCE_DIR)/build/$(MACH64)/.installed |
|
42 |
# |
|
43 |
# test: $(SOURCE_DIR)/build/$(MACH32)/.tested \ |
|
44 |
# $(SOURCE_DIR)/build/$(MACH64)/.tested |
|
45 |
# |
|
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 |
|
52 |
# |
|
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 |
|
57 |
# |
|
58 |
|
|
59 |
CMAKE_PREFIX = /usr |
|
60 |
|
|
61 |
# |
|
62 |
# Define path the same way as configure.mk |
|
63 |
# Ref: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs |
|
64 |
# |
|
65 |
|
0b2b25
|
66 |
ifeq ($(strip $(PREFERRED_BITS)),64) |
AL |
67 |
CMAKE_BINDIR.32 = bin/$(MACH32) |
|
68 |
CMAKE_BINDIR.64 = bin |
|
69 |
CMAKE_SBINDIR.32 = sbin/$(MACH32) |
|
70 |
CMAKE_SBINDIR.64 = sbin |
|
71 |
else |
9074b6
|
72 |
CMAKE_BINDIR.32 = bin |
AL |
73 |
CMAKE_BINDIR.64 = bin/$(MACH64) |
|
74 |
CMAKE_SBINDIR.32 = sbin |
|
75 |
CMAKE_SBINDIR.64 = sbin/$(MACH64) |
0b2b25
|
76 |
endif |
9074b6
|
77 |
CMAKE_LIBDIR.32 = lib |
AL |
78 |
CMAKE_LIBDIR.64 = lib/$(MACH64) |
7a33de
|
79 |
# If the component prefers 64-bit binaries, then ensure builds deliver 64-bit |
AW |
80 |
# binaries to the standard directories and 32-bit binaries to the non-standard |
|
81 |
# location. This allows simplification of package manifests and makes it |
|
82 |
# easier to deliver the 64-bit binaries as the default. |
|
83 |
ifeq ($(strip $(PREFERRED_BITS)),64) |
|
84 |
CMAKE_LIBEXECDIR.32 = libexec/$(MACH32) |
|
85 |
CMAKE_LIBEXECDIR.64 = libexec |
|
86 |
else |
|
87 |
CMAKE_LIBEXECDIR.32 = libexec |
|
88 |
CMAKE_LIBEXECDIR.64 = libexec/$(MACH64) |
|
89 |
endif |
9074b6
|
90 |
CMAKE_INCLUDEDIR = include |
AL |
91 |
CMAKE_DATAROOTDIR = share |
c3a1d7
|
92 |
CMAKE_DATADIR = $(CMAKE_DATAROOTDIR) |
33b2d2
|
93 |
CMAKE_INFODIR = $(CMAKE_DATAROOTDIR)/info |
AL |
94 |
CMAKE_LOCALEDIR = $(CMAKE_DATAROOTDIR)/locale |
|
95 |
CMAKE_MANDIR = $(CMAKE_DATAROOTDIR)/man |
0b2b25
|
96 |
CMAKE_DOCDIR = $(CMAKE_DATAROOTDIR)/doc |
9074b6
|
97 |
|
AL |
98 |
CMAKE_ENV = CONFIG_SHELL="$(CONFIG_SHELL)" |
|
99 |
CMAKE_ENV += CC="$(CC)" |
|
100 |
CMAKE_ENV += CXX="$(CXX)" |
|
101 |
CMAKE_ENV += F77="$(F77)" |
|
102 |
CMAKE_ENV += FC="$(FC)" |
|
103 |
CMAKE_ENV += CFLAGS="$(CFLAGS)" |
|
104 |
CMAKE_ENV += CXXFLAGS="$(CXXFLAGS)" |
|
105 |
CMAKE_ENV += FFLAGS="$(F77FLAGS)" |
|
106 |
CMAKE_ENV += FCFLAGS="$(FCFLAGS)" |
|
107 |
CMAKE_ENV += LDFLAGS="$(LDFLAGS)" |
|
108 |
CMAKE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" |
5282a1
|
109 |
CMAKE_ENV += PATH="$(PATH)" |
9074b6
|
110 |
|
c5572a
|
111 |
# Rewrite absolute source-code paths into relative for ccache, so that any |
JK |
112 |
# workspace with a shared CCACHE_DIR can benefit when compiling a component |
|
113 |
ifneq ($(strip $(CCACHE)),) |
|
114 |
CMAKE_ENV += CCACHE="$(CCACHE)" |
|
115 |
CMAKE_ENV += CC_gcc_32="$(CC_gcc_32)" |
|
116 |
CMAKE_ENV += CC_gcc_64="$(CC_gcc_32)" |
|
117 |
CMAKE_ENV += CXX_gcc_32="$(CXX_gcc_64)" |
|
118 |
CMAKE_ENV += CXX_gcc_64="$(CXX_gcc_64)" |
|
119 |
CMAKE_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))" |
|
120 |
|
|
121 |
ifneq ($(strip $(CCACHE_DIR)),) |
|
122 |
CMAKE_ENV += CCACHE_DIR="$(CCACHE_DIR)" |
|
123 |
endif |
|
124 |
|
|
125 |
ifneq ($(strip $(CCACHE_LOGFILE)),) |
|
126 |
CMAKE_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)" |
|
127 |
endif |
|
128 |
|
|
129 |
endif |
|
130 |
|
9074b6
|
131 |
CMAKE_DEFAULT_DIRS?=yes |
AL |
132 |
|
23c6f0
|
133 |
CMAKE_OPTIONS += -DCMAKE_C_COMPILER:STRING="$(CC)" |
AL |
134 |
CMAKE_OPTIONS += -DCMAKE_CXX_COMPILER:STRING="$(CXX)" |
|
135 |
CMAKE_OPTIONS += -DCMAKE_Fortran_COMPILER:STRING="$(FC)" |
|
136 |
CMAKE_OPTIONS += -DCMAKE_C_FLAGS:STRING="$(CFLAGS)" |
|
137 |
CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS:STRING="$(CXXFLAGS)" |
|
138 |
CMAKE_OPTIONS += -DCMAKE_Fortran_FLAGS:STRING="$(FCFLAGS)" |
9074b6
|
139 |
|
AL |
140 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX:PATH=$(CMAKE_PREFIX) |
|
141 |
ifeq ($(CMAKE_DEFAULT_DIRS),yes) |
|
142 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_BINDIR:PATH=$(CMAKE_BINDIR.$(BITS)) |
|
143 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR:PATH=$(CMAKE_LIBDIR.$(BITS)) |
b5ddf2
|
144 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_SBINDIR:PATH=$(CMAKE_SBINDIR.$(BITS)) |
9074b6
|
145 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_DATAROOTDIR:PATH=$(CMAKE_DATAROOTDIR) |
AL |
146 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_DATADIR:PATH=$(CMAKE_DATAROOTDIR) |
|
147 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_INFODIR:PATH=$(CMAKE_INFODIR) |
|
148 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_LOCALEDIR:PATH=$(CMAKE_LOCALEDIR) |
|
149 |
CMAKE_OPTIONS += -DCMAKE_INSTALL_MANDIR:PATH=$(CMAKE_MANDIR) |
b5ddf2
|
150 |
|
AP |
151 |
CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(CMAKE_PREFIX)/$(CMAKE_LIBEXECDIR.$(BITS))" |
|
152 |
|
|
153 |
# Some components use LIB_INSTALL_DIR or CMAKE_INSTALL_LIBDIR, as-is, |
|
154 |
# others forcibly ignore it and set |
|
155 |
# based on CMAKE_INSTALL_PREFIX. Those usually instead offer a LIB_SUFFIX |
|
156 |
# variable that we can generally use to accomplish the same result. Setting |
|
157 |
# them both shouldn't harm anything. |
|
158 |
CMAKE_OPTIONS += -DLIB_INSTALL_DIR="$(CMAKE_PREFIX)/$(CMAKE_LIBDIR.$(BITS))" |
15fd05
|
159 |
CMAKE_OPTIONS.64 += -DCMAKE_LIBRARY_ARCHITECTURE=$(MACH64) |
b5ddf2
|
160 |
CMAKE_OPTIONS.64 += -DLIB_SUFFIX="/$(MACH64)" |
9074b6
|
161 |
endif |
AL |
162 |
CMAKE_OPTIONS += $(CMAKE_OPTIONS.$(BITS)) |
|
163 |
|
|
164 |
COMPONENT_INSTALL_ARGS += DESTDIR=$(PROTO_DIR) |
|
165 |
|
|
166 |
$(BUILD_DIR_32)/.configured: BITS=32 |
|
167 |
$(BUILD_DIR_64)/.configured: BITS=64 |
|
168 |
|
|
169 |
CMAKE_ENV += $(CMAKE_ENV.$(BITS)) |
|
170 |
|
51eb1d
|
171 |
COMPONENT_TEST_CMD=ctest |
AP |
172 |
COMPONENT_TEST_TARGETS= |
|
173 |
|
9074b6
|
174 |
# configure the unpacked source for building 32 and 64 bit version |
AL |
175 |
CMAKE = cmake |
ced62a
|
176 |
|
AW |
177 |
# provide test transforms for ctest |
|
178 |
CMAKE_TEST_TRANSFORMS = \ |
|
179 |
' -e "s/[0-9]*\.[0-9]* sec//" ' \ |
|
180 |
' -n ' \ |
d7f395
|
181 |
' -e "/Not Run/p" ' \ |
ced62a
|
182 |
' -e "/Start/p" ' \ |
67036b
|
183 |
' -e "/Skipped/p" ' \ |
ced62a
|
184 |
' -e "/Failed/p" ' \ |
AW |
185 |
' -e "/Passed/p" ' \ |
|
186 |
' -e "/failed/p" ' |
|
187 |
|
|
188 |
USE_DEFAULT_TEST_TRANSFORMS?=no |
|
189 |
ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes) |
|
190 |
COMPONENT_TEST_TRANSFORMS += $(CMAKE_TEST_TRANSFORMS) |
|
191 |
endif |
|
192 |
|
9074b6
|
193 |
$(BUILD_DIR)/%/.configured: $(SOURCE_DIR)/.prep |
AL |
194 |
($(RM) -rf $(@D) ; $(MKDIR) $(@D)) |
|
195 |
$(COMPONENT_PRE_CMAKE_ACTION) |
|
196 |
(cd $(@D) ; $(ENV) $(CMAKE_ENV) \ |
|
197 |
$(CMAKE) $(CMAKE_OPTIONS) $(SOURCE_DIR)) |
|
198 |
$(COMPONENT_POST_CMAKE_ACTION) |
|
199 |
$(TOUCH) $@ |
|
200 |
|
|
201 |
# build the configured source |
|
202 |
$(BUILD_DIR)/%/.built: $(BUILD_DIR)/%/.configured |
|
203 |
$(COMPONENT_PRE_BUILD_ACTION) |
|
204 |
(cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \ |
|
205 |
$(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \ |
|
206 |
$(COMPONENT_BUILD_TARGETS)) |
|
207 |
$(COMPONENT_POST_BUILD_ACTION) |
|
208 |
$(TOUCH) $@ |
|
209 |
|
|
210 |
# install the built source into a prototype area |
|
211 |
$(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built |
|
212 |
$(COMPONENT_PRE_INSTALL_ACTION) |
|
213 |
(cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \ |
|
214 |
$(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS)) |
|
215 |
$(COMPONENT_POST_INSTALL_ACTION) |
|
216 |
$(TOUCH) $@ |
|
217 |
|
|
218 |
# test the built source |
b6799e
|
219 |
$(BUILD_DIR)/%/.tested-and-compared: $(COMPONENT_TEST_DEP) |
237543
|
220 |
$(RM) -rf $(COMPONENT_TEST_BUILD_DIR) |
AP |
221 |
$(MKDIR) $(COMPONENT_TEST_BUILD_DIR) |
940b86
|
222 |
$(COMPONENT_PRE_TEST_ACTION) |
AP |
223 |
-(cd $(COMPONENT_TEST_DIR) ; \ |
|
224 |
$(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \ |
|
225 |
$(COMPONENT_TEST_CMD) \ |
|
226 |
$(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \ |
|
227 |
&> $(COMPONENT_TEST_OUTPUT) |
|
228 |
$(COMPONENT_POST_TEST_ACTION) |
|
229 |
$(COMPONENT_TEST_CREATE_TRANSFORMS) |
|
230 |
$(COMPONENT_TEST_PERFORM_TRANSFORM) |
|
231 |
$(COMPONENT_TEST_COMPARE) |
|
232 |
$(COMPONENT_TEST_CLEANUP) |
|
233 |
$(TOUCH) $@ |
|
234 |
|
89aae0
|
235 |
$(BUILD_DIR)/%/.tested: SHELLOPTS=pipefail |
b6799e
|
236 |
$(BUILD_DIR)/%/.tested: $(COMPONENT_TEST_DEP) |
89aae0
|
237 |
$(RM) -rf $(COMPONENT_TEST_BUILD_DIR) |
MT |
238 |
$(MKDIR) $(COMPONENT_TEST_BUILD_DIR) |
9074b6
|
239 |
$(COMPONENT_PRE_TEST_ACTION) |
940b86
|
240 |
(cd $(COMPONENT_TEST_DIR) ; \ |
AP |
241 |
$(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \ |
|
242 |
$(COMPONENT_TEST_CMD) \ |
89aae0
|
243 |
$(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \ |
MT |
244 |
|& $(TEE) $(COMPONENT_TEST_OUTPUT) |
9074b6
|
245 |
$(COMPONENT_POST_TEST_ACTION) |
89aae0
|
246 |
$(COMPONENT_TEST_CREATE_TRANSFORMS) |
MT |
247 |
$(COMPONENT_TEST_PERFORM_TRANSFORM) |
940b86
|
248 |
$(COMPONENT_TEST_CLEANUP) |
9074b6
|
249 |
$(TOUCH) $@ |
AL |
250 |
|
|
251 |
clean:: |
|
252 |
$(RM) -r $(BUILD_DIR) $(PROTO_DIR) |