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]
21 # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
22 # Copyright 2011 EveryCity Ltd. All rights reserved.
26 # Rules and Macros for building opens source software that uses configure /
27 # GNU auto* tools to configure their build for the system they are on. This
28 # uses GNU Make to build the components to take advantage of the viewpath
29 # support and build multiple version (32/64 bit) from a shared source.
31 # To use these rules, include ../make-rules/configure.mk in your Makefile
32 # and define "build", "install", and "test" targets appropriate to building
36 # build: $(SOURCE_DIR)/build/$(MACH32)/.built \
37 # $(SOURCE_DIR)/build/$(MACH64)/.built
39 # install: $(SOURCE_DIR)/build/$(MACH32)/.installed \
40 # $(SOURCE_DIR)/build/$(MACH64)/.installed
42 # test: $(SOURCE_DIR)/build/$(MACH32)/.tested \
43 # $(SOURCE_DIR)/build/$(MACH64)/.tested
45 # Any additional pre/post configure, build, or install actions can be specified
46 # in your make file by setting them in on of the following macros:
47 # COMPONENT_PRE_CONFIGURE_ACTION, COMPONENT_POST_CONFIGURE_ACTION
48 # COMPONENT_PRE_BUILD_ACTION, COMPONENT_POST_BUILD_ACTION
49 # COMPONENT_PRE_INSTALL_ACTION, COMPONENT_POST_INSTALL_ACTION
50 # COMPONENT_PRE_TEST_ACTION, COMPONENT_POST_TEST_ACTION
52 # If component specific make targets need to be used for build or install, they
54 # COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS
55 # COMPONENT_TEST_TARGETS
58 CONFIGURE_PREFIX
= /usr
60 # If the component prefers 64-bit binaries, then ensure builds deliver 64-bit
61 # binaries to the standard directories and 32-bit binaries to the non-standard
62 # location. This allows simplification of package manifests and makes it
63 # easier to deliver the 64-bit binaries as the default.
64 ifeq ($(strip $(PREFERRED_BITS
)),64)
65 CONFIGURE_BINDIR
.32 = $(CONFIGURE_PREFIX
)/bin
/$(MACH32
)
66 CONFIGURE_BINDIR
.64 = $(CONFIGURE_PREFIX
)/bin
67 CONFIGURE_SBINDIR
.32 = $(CONFIGURE_PREFIX
)/sbin
/$(MACH32
)
68 CONFIGURE_SBINDIR
.64 = $(CONFIGURE_PREFIX
)/sbin
69 CONFIGURE_LIBEXECDIR
.32 = $(CONFIGURE_PREFIX
)/libexec
/$(MACH32
)
70 CONFIGURE_LIBEXECDIR
.64 = $(CONFIGURE_PREFIX
)/libexec
73 CONFIGURE_BINDIR
.32 = $(CONFIGURE_PREFIX
)/bin
74 CONFIGURE_BINDIR
.64 = $(CONFIGURE_PREFIX
)/bin
/$(MACH64
)
75 CONFIGURE_SBINDIR
.32 = $(CONFIGURE_PREFIX
)/sbin
76 CONFIGURE_SBINDIR
.64 = $(CONFIGURE_PREFIX
)/sbin
/$(MACH64
)
77 CONFIGURE_LIBEXECDIR
.32 = $(CONFIGURE_PREFIX
)/libexec
78 CONFIGURE_LIBEXECDIR
.64 = $(CONFIGURE_PREFIX
)/libexec
/$(MACH64
)
81 # Regardless of PREFERRED_BITS, 64-bit libraries should always be delivered to
82 # the appropriate subdirectory by default.
83 CONFIGURE_LIBDIR
.32 = $(CONFIGURE_PREFIX
)/lib
84 CONFIGURE_LIBDIR
.64 = $(CONFIGURE_PREFIX
)/lib
/$(MACH64
)
86 CONFIGURE_MANDIR
= $(CONFIGURE_PREFIX
)/share
/man
87 CONFIGURE_LOCALEDIR
= $(CONFIGURE_PREFIX
)/share
/locale
88 CONFIGURE_LOCALSTATEDIR
= $(VARDIR
)
89 # all texinfo documentation seems to go to /usr/share/info no matter what
90 CONFIGURE_INFODIR
= /usr
/share
/info
91 CONFIGURE_INCLUDEDIR
= /usr
/include
92 CONFIGURE_SYSCONFDIR
= $(ETCDIR
)
94 CONFIGURE_ENV
= CONFIG_SHELL
="$(CONFIG_SHELL)"
95 CONFIGURE_ENV
+= PATH
="$(PATH)"
96 CONFIGURE_ENV
+= CC
="$(CC)"
97 CONFIGURE_ENV
+= CXX
="$(CXX)"
98 CONFIGURE_ENV
+= F77
="$(F77)"
99 CONFIGURE_ENV
+= FC
="$(FC)"
100 CONFIGURE_ENV
+= CFLAGS
="$(CFLAGS)"
101 CONFIGURE_ENV
+= CXXFLAGS
="$(CXXFLAGS)"
102 CONFIGURE_ENV
+= FFLAGS
="$(F77FLAGS)"
103 CONFIGURE_ENV
+= FCFLAGS
="$(FCFLAGS)"
104 CONFIGURE_ENV
+= LDFLAGS
="$(LDFLAGS)"
105 CONFIGURE_ENV
+= PKG_CONFIG_PATH
="$(PKG_CONFIG_PATH)"
107 # Rewrite absolute source-code paths into relative for ccache, so that any
108 # workspace with a shared CCACHE_DIR can benefit when compiling a component
109 ifneq ($(strip $(CCACHE
)),)
110 CONFIGURE_ENV
+= CCACHE
="$(CCACHE)"
111 CONFIGURE_OPTIONS
+= CCACHE
="$(CCACHE)"
112 CONFIGURE_ENV
+= CC_gcc_32
="$(CC_gcc_32)"
113 CONFIGURE_ENV
+= CC_gcc_64
="$(CC_gcc_32)"
114 CONFIGURE_ENV
+= CXX_gcc_32
="$(CXX_gcc_64)"
115 CONFIGURE_ENV
+= CXX_gcc_64
="$(CXX_gcc_64)"
116 CONFIGURE_OPTIONS
+= CC_gcc_32
="$(CC_gcc_32)"
117 CONFIGURE_OPTIONS
+= CC_gcc_64
="$(CC_gcc_32)"
118 CONFIGURE_OPTIONS
+= CXX_gcc_32
="$(CXX_gcc_64)"
119 CONFIGURE_OPTIONS
+= CXX_gcc_64
="$(CXX_gcc_64)"
120 CONFIGURE_ENV.
$(BITS
) += CCACHE_BASEDIR
="$(BUILD_DIR_$(BITS))"
121 CONFIGURE_OPTIONS.
$(BITS
) += CCACHE_BASEDIR
="$(BUILD_DIR_$(BITS))"
123 ifneq ($(strip $(CCACHE_DIR
)),)
124 CONFIGURE_ENV
+= CCACHE_DIR
="$(CCACHE_DIR)"
125 CONFIGURE_OPTIONS
+= CCACHE_DIR
="$(CCACHE_DIR)"
128 ifneq ($(strip $(CCACHE_LOGFILE
)),)
129 CONFIGURE_ENV
+= CCACHE_LOGFILE
="$(CCACHE_LOGFILE)"
130 CONFIGURE_OPTIONS
+= CCACHE_LOGFILE
="$(CCACHE_LOGFILE)"
135 CONFIGURE_DEFAULT_DIRS?
=yes
137 CONFIGURE_OPTIONS
+= CC
="$(CC)"
138 CONFIGURE_OPTIONS
+= CXX
="$(CXX)"
139 CONFIGURE_OPTIONS
+= F77
="$(F77)"
140 CONFIGURE_OPTIONS
+= FC
="$(FC)"
141 CONFIGURE_OPTIONS
+= CFLAGS
="$(CFLAGS)"
142 CONFIGURE_OPTIONS
+= CXXFLAGS
="$(CXXFLAGS)"
143 CONFIGURE_OPTIONS
+= FFLAGS
="$(F77FLAGS)"
144 CONFIGURE_OPTIONS
+= FCFLAGS
="$(FCFLAGS)"
145 CONFIGURE_OPTIONS
+= LDFLAGS
="$(LDFLAGS)"
146 CONFIGURE_OPTIONS
+= PKG_CONFIG_PATH
="$(PKG_CONFIG_PATH)"
148 CONFIGURE_OPTIONS
+= --prefix=$(CONFIGURE_PREFIX
)
149 ifeq ($(CONFIGURE_DEFAULT_DIRS
),yes
)
150 CONFIGURE_OPTIONS
+= --mandir=$(CONFIGURE_MANDIR
)
151 CONFIGURE_OPTIONS
+= --bindir=$(CONFIGURE_BINDIR.
$(BITS
))
152 CONFIGURE_OPTIONS
+= --includedir=$(CONFIGURE_INCLUDEDIR
)
153 CONFIGURE_OPTIONS
+= --infodir=$(CONFIGURE_INFODIR
)
154 CONFIGURE_OPTIONS
+= --libdir=$(CONFIGURE_LIBDIR.
$(BITS
))
155 CONFIGURE_OPTIONS
+= --libexecdir
=$(CONFIGURE_LIBEXECDIR.
$(BITS
))
156 CONFIGURE_OPTIONS
+= --localedir
=$(CONFIGURE_LOCALEDIR
)
157 CONFIGURE_OPTIONS
+= --localstatedir
=$(CONFIGURE_LOCALSTATEDIR
)
158 CONFIGURE_OPTIONS
+= --sbindir
=$(CONFIGURE_SBINDIR.
$(BITS
))
159 CONFIGURE_OPTIONS
+= --sysconfdir
=$(CONFIGURE_SYSCONFDIR
)
161 CONFIGURE_OPTIONS
+= $(CONFIGURE_OPTIONS.
$(BITS
))
163 COMPONENT_INSTALL_ARGS
+= DESTDIR
=$(PROTO_DIR
)
165 $(BUILD_DIR_32
)/.configured
: BITS
=32
166 $(BUILD_DIR_64
)/.configured
: BITS
=64
168 CONFIGURE_ENV
+= $(CONFIGURE_ENV.
$(BITS
))
171 # temporarily work around some issues
172 CONFIGURE_ENV
+= "ac_cv_func_realloc_0_nonnull=yes"
173 COMPONENT_BUILD_ENV
+= "ac_cv_func_realloc_0_nonnull=yes"
175 # configure the unpacked source for building 32 and 64 bit version
176 CONFIGURE_SCRIPT
= $(SOURCE_DIR
)/configure
177 $(BUILD_DIR
)/%/.configured
: $(SOURCE_DIR
)/.prep
178 ($(RM
) -rf
$(@D
) ; $(MKDIR
) $(@D
))
179 $(COMPONENT_PRE_CONFIGURE_ACTION
)
180 (cd
$(@D
) ; $(ENV
) $(CONFIGURE_ENV
) $(CONFIG_SHELL
) \
181 $(CONFIGURE_SCRIPT
) $(CONFIGURE_OPTIONS
))
182 $(COMPONENT_POST_CONFIGURE_ACTION
)
185 # build the configured source
186 $(BUILD_DIR
)/%/.built
: $(BUILD_DIR
)/%/.configured
187 $(COMPONENT_PRE_BUILD_ACTION
)
188 (cd
$(@D
) ; $(ENV
) $(COMPONENT_BUILD_ENV
) \
189 $(GMAKE
) $(COMPONENT_BUILD_GMAKE_ARGS
) $(COMPONENT_BUILD_ARGS
) \
190 $(COMPONENT_BUILD_TARGETS
))
191 $(COMPONENT_POST_BUILD_ACTION
)
194 # install the built source into a prototype area
195 $(BUILD_DIR
)/%/.installed
: $(BUILD_DIR
)/%/.built
196 $(COMPONENT_PRE_INSTALL_ACTION
)
197 (cd
$(@D
) ; $(ENV
) $(COMPONENT_INSTALL_ENV
) $(GMAKE
) \
198 $(COMPONENT_INSTALL_ARGS
) $(COMPONENT_INSTALL_TARGETS
))
199 $(COMPONENT_POST_INSTALL_ACTION
)
202 CONFIGURE_TEST_TRANSFORMS
= \
210 USE_DEFAULT_TEST_TRANSFORMS?
=no
211 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS
)),yes
)
212 COMPONENT_TEST_TRANSFORMS
+= $(CONFIGURE_TEST_TRANSFORMS
)
215 # test the built source
216 $(BUILD_DIR
)/%/.tested-and-compared
: $(COMPONENT_TEST_DEP
)
217 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
218 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
219 $(COMPONENT_PRE_TEST_ACTION
)
220 -(cd
$(COMPONENT_TEST_DIR
) ; \
221 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
222 $(COMPONENT_TEST_CMD
) \
223 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
224 &> $(COMPONENT_TEST_OUTPUT
)
225 $(COMPONENT_POST_TEST_ACTION
)
226 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
227 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
228 $(COMPONENT_TEST_COMPARE
)
229 $(COMPONENT_TEST_CLEANUP
)
232 $(BUILD_DIR
)/%/.tested
: SHELLOPTS
=pipefail
233 $(BUILD_DIR
)/%/.tested
: $(COMPONENT_TEST_DEP
)
234 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
235 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
236 $(COMPONENT_PRE_TEST_ACTION
)
237 (cd
$(COMPONENT_TEST_DIR
) ; \
238 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
239 $(COMPONENT_TEST_CMD
) \
240 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
241 |
& $(TEE
) $(COMPONENT_TEST_OUTPUT
)
242 $(COMPONENT_POST_TEST_ACTION
)
243 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
244 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
245 $(COMPONENT_TEST_CLEANUP
)
249 $(RM
) -r
$(BUILD_DIR
) $(PROTO_DIR
)