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, 2014, 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 CONFIGURE_BINDIR
.32 = $(CONFIGURE_PREFIX
)/bin
61 CONFIGURE_BINDIR
.64 = $(CONFIGURE_PREFIX
)/bin
/$(MACH64
)
62 CONFIGURE_LIBDIR
.32 = $(CONFIGURE_PREFIX
)/lib
63 CONFIGURE_LIBDIR
.64 = $(CONFIGURE_PREFIX
)/lib
/$(MACH64
)
64 CONFIGURE_SBINDIR
.32 = $(CONFIGURE_PREFIX
)/sbin
65 CONFIGURE_SBINDIR
.64 = $(CONFIGURE_PREFIX
)/sbin
/$(MACH64
)
66 CONFIGURE_MANDIR
= $(CONFIGURE_PREFIX
)/share
/man
67 CONFIGURE_LOCALEDIR
= $(CONFIGURE_PREFIX
)/share
/locale
68 # all texinfo documentation seems to go to /usr/share/info no matter what
69 CONFIGURE_INFODIR
= /usr
/share
/info
70 CONFIGURE_INCLUDEDIR
= /usr
/include
72 CONFIGURE_ENV
= CONFIG_SHELL
="$(CONFIG_SHELL)"
73 CONFIGURE_ENV
+= CC
="$(CC)"
74 CONFIGURE_ENV
+= CXX
="$(CXX)"
75 CONFIGURE_ENV
+= F77
="$(F77)"
76 CONFIGURE_ENV
+= FC
="$(FC)"
77 CONFIGURE_ENV
+= CFLAGS
="$(CFLAGS)"
78 CONFIGURE_ENV
+= CXXFLAGS
="$(CXXFLAGS)"
79 CONFIGURE_ENV
+= FFLAGS
="$(F77FLAGS)"
80 CONFIGURE_ENV
+= FCFLAGS
="$(FCFLAGS)"
81 CONFIGURE_ENV
+= LDFLAGS
="$(LDFLAGS)"
82 CONFIGURE_ENV
+= PKG_CONFIG_PATH
="$(PKG_CONFIG_PATH)"
84 # Rewrite absolute source-code paths into relative for ccache, so that any
85 # workspace with a shared CCACHE_DIR can benefit when compiling a component
86 ifneq ($(strip $(CCACHE
)),)
87 CONFIGURE_ENV
+= CCACHE
="$(CCACHE)"
88 CONFIGURE_OPTIONS
+= CCACHE
="$(CCACHE)"
89 CONFIGURE_ENV
+= CC_gcc_32
="$(CC_gcc_32)"
90 CONFIGURE_ENV
+= CC_gcc_64
="$(CC_gcc_32)"
91 CONFIGURE_ENV
+= CXX_gcc_32
="$(CXX_gcc_64)"
92 CONFIGURE_ENV
+= CXX_gcc_64
="$(CXX_gcc_64)"
93 CONFIGURE_OPTIONS
+= CC_gcc_32
="$(CC_gcc_32)"
94 CONFIGURE_OPTIONS
+= CC_gcc_64
="$(CC_gcc_32)"
95 CONFIGURE_OPTIONS
+= CXX_gcc_32
="$(CXX_gcc_64)"
96 CONFIGURE_OPTIONS
+= CXX_gcc_64
="$(CXX_gcc_64)"
97 CONFIGURE_ENV.
$(BITS
) += CCACHE_BASEDIR
="$(BUILD_DIR_$(BITS))"
98 CONFIGURE_OPTIONS.
$(BITS
) += CCACHE_BASEDIR
="$(BUILD_DIR_$(BITS))"
100 ifneq ($(strip $(CCACHE_DIR
)),)
101 CONFIGURE_ENV
+= CCACHE_DIR
="$(CCACHE_DIR)"
102 CONFIGURE_OPTIONS
+= CCACHE_DIR
="$(CCACHE_DIR)"
105 ifneq ($(strip $(CCACHE_LOGFILE
)),)
106 CONFIGURE_ENV
+= CCACHE_LOGFILE
="$(CCACHE_LOGFILE)"
107 CONFIGURE_OPTIONS
+= CCACHE_LOGFILE
="$(CCACHE_LOGFILE)"
112 CONFIGURE_DEFAULT_DIRS?
=yes
114 CONFIGURE_OPTIONS
+= CC
="$(CC)"
115 CONFIGURE_OPTIONS
+= CXX
="$(CXX)"
116 CONFIGURE_OPTIONS
+= F77
="$(F77)"
117 CONFIGURE_OPTIONS
+= FC
="$(FC)"
118 CONFIGURE_OPTIONS
+= CFLAGS
="$(CFLAGS)"
119 CONFIGURE_OPTIONS
+= CXXFLAGS
="$(CXXFLAGS)"
120 CONFIGURE_OPTIONS
+= FFLAGS
="$(F77FLAGS)"
121 CONFIGURE_OPTIONS
+= FCFLAGS
="$(FCFLAGS)"
122 CONFIGURE_OPTIONS
+= LDFLAGS
="$(LDFLAGS)"
123 CONFIGURE_OPTIONS
+= PKG_CONFIG_PATH
="$(PKG_CONFIG_PATH)"
125 CONFIGURE_OPTIONS
+= --prefix=$(CONFIGURE_PREFIX
)
126 ifeq ($(CONFIGURE_DEFAULT_DIRS
),yes
)
127 CONFIGURE_OPTIONS
+= --mandir=$(CONFIGURE_MANDIR
)
128 CONFIGURE_OPTIONS
+= --bindir=$(CONFIGURE_BINDIR.
$(BITS
))
129 CONFIGURE_OPTIONS
+= --libdir=$(CONFIGURE_LIBDIR.
$(BITS
))
130 CONFIGURE_OPTIONS
+= --sbindir
=$(CONFIGURE_SBINDIR.
$(BITS
))
132 CONFIGURE_OPTIONS
+= $(CONFIGURE_OPTIONS.
$(BITS
))
134 COMPONENT_INSTALL_ARGS
+= DESTDIR
=$(PROTO_DIR
)
136 $(BUILD_DIR_32
)/.configured
: BITS
=32
137 $(BUILD_DIR_64
)/.configured
: BITS
=64
139 CONFIGURE_ENV
+= $(CONFIGURE_ENV.
$(BITS
))
140 ifeq ($(strip $(PARFAIT_BUILD
)),yes
)
141 # parfait creates '*.bc' files which can confuse configure's
142 # object/exe extension detection. which we really don't need it
143 # to do anyway, so we'll just tell it what they are.
144 CONFIGURE_ENV
+= ac_cv_objext
=o
145 CONFIGURE_ENV
+= ac_cv_exeext
=""
146 # this is fixed in the clang compiler but we can't use it yet
147 CONFIGURE_ENV
+= ac_cv_header_stdbool_h
=yes
151 # temporarily work around some issues
152 CONFIGURE_ENV
+= "ac_cv_func_realloc_0_nonnull=yes"
153 COMPONENT_BUILD_ENV
+= "ac_cv_func_realloc_0_nonnull=yes"
155 # configure the unpacked source for building 32 and 64 bit version
156 CONFIGURE_SCRIPT
= $(SOURCE_DIR
)/configure
157 $(BUILD_DIR
)/%/.configured
: $(SOURCE_DIR
)/.prep
158 ($(RM
) -rf
$(@D
) ; $(MKDIR
) $(@D
))
159 $(COMPONENT_PRE_CONFIGURE_ACTION
)
160 (cd
$(@D
) ; $(ENV
) $(CONFIGURE_ENV
) $(CONFIG_SHELL
) \
161 $(CONFIGURE_SCRIPT
) $(CONFIGURE_OPTIONS
))
162 $(COMPONENT_POST_CONFIGURE_ACTION
)
165 # build the configured source
166 $(BUILD_DIR
)/%/.built
: $(BUILD_DIR
)/%/.configured
167 $(COMPONENT_PRE_BUILD_ACTION
)
168 (cd
$(@D
) ; $(ENV
) $(COMPONENT_BUILD_ENV
) \
169 $(GMAKE
) $(COMPONENT_BUILD_GMAKE_ARGS
) $(COMPONENT_BUILD_ARGS
) \
170 $(COMPONENT_BUILD_TARGETS
))
171 $(COMPONENT_POST_BUILD_ACTION
)
172 ifeq ($(strip $(PARFAIT_BUILD
)),yes
)
177 # install the built source into a prototype area
178 $(BUILD_DIR
)/%/.installed
: $(BUILD_DIR
)/%/.built
179 $(COMPONENT_PRE_INSTALL_ACTION
)
180 (cd
$(@D
) ; $(ENV
) $(COMPONENT_INSTALL_ENV
) $(GMAKE
) \
181 $(COMPONENT_INSTALL_ARGS
) $(COMPONENT_INSTALL_TARGETS
))
182 $(COMPONENT_POST_INSTALL_ACTION
)
185 # test the built source
186 $(BUILD_DIR
)/%/.tested-and-compared
: $(BUILD_DIR
)/%/.built
187 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
188 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
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_TEST_OUTPUT
)
195 $(COMPONENT_POST_TEST_ACTION
)
196 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
197 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
198 $(COMPONENT_TEST_COMPARE
)
199 $(COMPONENT_TEST_CLEANUP
)
202 $(BUILD_DIR
)/%/.tested
: $(BUILD_DIR
)/%/.built
203 $(COMPONENT_PRE_TEST_ACTION
)
204 (cd
$(COMPONENT_TEST_DIR
) ; \
205 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
206 $(COMPONENT_TEST_CMD
) \
207 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
))
208 $(COMPONENT_POST_TEST_ACTION
)
209 $(COMPONENT_TEST_CLEANUP
)
212 ifeq ($(strip $(PARFAIT_BUILD
)),yes
)
217 $(MAKE
) PARFAIT_BUILD
=yes parfait
221 $(RM
) -r
$(BUILD_DIR
) $(PROTO_DIR
)