Marcel Telka
2024-03-31 2ba18872f5c70e96d18c8760e6c835c39eb2caca
commit | author | age
9c75c0 1 #
NJ 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 #
0b2b25 21 # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
c99122 22 # Copyright 2011 EveryCity Ltd. All rights reserved.
9c75c0 23 #
NJ 24
25 #
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.
30 #
31 # To use these rules, include ../make-rules/configure.mk in your Makefile
3a19d0 32 # and define "build", "install", and "test" targets appropriate to building
MT 33 # your component.
9c75c0 34 # Ex:
NJ 35 #
74300c 36 #     build:        $(SOURCE_DIR)/build/$(MACH32)/.built \
NJ 37 #             $(SOURCE_DIR)/build/$(MACH64)/.built
3a19d0 38 #
74300c 39 #    install:    $(SOURCE_DIR)/build/$(MACH32)/.installed \
NJ 40 #             $(SOURCE_DIR)/build/$(MACH64)/.installed
3a19d0 41 #
MT 42 #    test:        $(SOURCE_DIR)/build/$(MACH32)/.tested \
43 #             $(SOURCE_DIR)/build/$(MACH64)/.tested
9c75c0 44 #
NJ 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
3a19d0 50 #    COMPONENT_PRE_TEST_ACTION, COMPONENT_POST_TEST_ACTION
9c75c0 51 #
NJ 52 # If component specific make targets need to be used for build or install, they
53 # can be specified in
54 #    COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS
3a19d0 55 #    COMPONENT_TEST_TARGETS
9c75c0 56 #
NJ 57
4b89a1 58 CONFIGURE_PREFIX =    /usr
NJ 59
0b2b25 60 # If the component prefers 64-bit binaries, then ensure builds deliver 64-bit
AL 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)
9dccbc 65 CONFIGURE_BINDIR.32     = $(CONFIGURE_PREFIX)/bin/$(MACH32)
AW 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
71
0b2b25 72 else
9dccbc 73 CONFIGURE_BINDIR.32     = $(CONFIGURE_PREFIX)/bin
AW 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)
0b2b25 79 endif
AL 80
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)
85
4b89a1 86 CONFIGURE_MANDIR =    $(CONFIGURE_PREFIX)/share/man
NJ 87 CONFIGURE_LOCALEDIR =    $(CONFIGURE_PREFIX)/share/locale
88 # all texinfo documentation seems to go to /usr/share/info no matter what
89 CONFIGURE_INFODIR =    /usr/share/info
f0c88f 90 CONFIGURE_INCLUDEDIR =    /usr/include
4b89a1 91
aeb6c4 92 CONFIGURE_ENV = CONFIG_SHELL="$(CONFIG_SHELL)"
8a1ca7 93 CONFIGURE_ENV += PATH="$(PATH)"
6842d7 94 CONFIGURE_ENV += CC="$(CC)"
AS 95 CONFIGURE_ENV += CXX="$(CXX)"
097bb0 96 CONFIGURE_ENV += F77="$(F77)"
AL 97 CONFIGURE_ENV += FC="$(FC)"
dfeb21 98 CONFIGURE_ENV += CFLAGS="$(CFLAGS)"
AS 99 CONFIGURE_ENV += CXXFLAGS="$(CXXFLAGS)"
097bb0 100 CONFIGURE_ENV += FFLAGS="$(F77FLAGS)"
AL 101 CONFIGURE_ENV += FCFLAGS="$(FCFLAGS)"
dfeb21 102 CONFIGURE_ENV += LDFLAGS="$(LDFLAGS)"
AS 103 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
aeb6c4 104
c5572a 105 # Rewrite absolute source-code paths into relative for ccache, so that any
JK 106 # workspace with a shared CCACHE_DIR can benefit when compiling a component
107 ifneq ($(strip $(CCACHE)),)
108 CONFIGURE_ENV += CCACHE="$(CCACHE)"
109 CONFIGURE_OPTIONS += CCACHE="$(CCACHE)"
110 CONFIGURE_ENV += CC_gcc_32="$(CC_gcc_32)"
111 CONFIGURE_ENV += CC_gcc_64="$(CC_gcc_32)"
112 CONFIGURE_ENV += CXX_gcc_32="$(CXX_gcc_64)"
113 CONFIGURE_ENV += CXX_gcc_64="$(CXX_gcc_64)"
114 CONFIGURE_OPTIONS += CC_gcc_32="$(CC_gcc_32)"
115 CONFIGURE_OPTIONS += CC_gcc_64="$(CC_gcc_32)"
116 CONFIGURE_OPTIONS += CXX_gcc_32="$(CXX_gcc_64)"
117 CONFIGURE_OPTIONS += CXX_gcc_64="$(CXX_gcc_64)"
118 CONFIGURE_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
119 CONFIGURE_OPTIONS.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
120
121 ifneq ($(strip $(CCACHE_DIR)),)
122 CONFIGURE_ENV += CCACHE_DIR="$(CCACHE_DIR)"
123 CONFIGURE_OPTIONS += CCACHE_DIR="$(CCACHE_DIR)"
124 endif
125
126 ifneq ($(strip $(CCACHE_LOGFILE)),)
127 CONFIGURE_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
128 CONFIGURE_OPTIONS += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
129 endif
130
131 endif
132
312c03 133 CONFIGURE_DEFAULT_DIRS?=yes
PS 134
f341a6 135 CONFIGURE_OPTIONS += CC="$(CC)"
AS 136 CONFIGURE_OPTIONS += CXX="$(CXX)"
097bb0 137 CONFIGURE_OPTIONS += F77="$(F77)"
AL 138 CONFIGURE_OPTIONS += FC="$(FC)"
dfeb21 139 CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)"
AS 140 CONFIGURE_OPTIONS += CXXFLAGS="$(CXXFLAGS)"
097bb0 141 CONFIGURE_OPTIONS += FFLAGS="$(F77FLAGS)"
AL 142 CONFIGURE_OPTIONS += FCFLAGS="$(FCFLAGS)"
dfeb21 143 CONFIGURE_OPTIONS += LDFLAGS="$(LDFLAGS)"
AS 144 CONFIGURE_OPTIONS += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
f341a6 145
4b89a1 146 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
312c03 147 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
4b89a1 148 CONFIGURE_OPTIONS += --mandir=$(CONFIGURE_MANDIR)
NJ 149 CONFIGURE_OPTIONS += --bindir=$(CONFIGURE_BINDIR.$(BITS))
150 CONFIGURE_OPTIONS += --libdir=$(CONFIGURE_LIBDIR.$(BITS))
9dccbc 151 CONFIGURE_OPTIONS += --libexecdir=$(CONFIGURE_LIBEXECDIR.$(BITS))
9dfd18 152 CONFIGURE_OPTIONS += --sbindir=$(CONFIGURE_SBINDIR.$(BITS))
312c03 153 endif
e83e52 154 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
4b89a1 155
NJ 156 COMPONENT_INSTALL_ARGS +=    DESTDIR=$(PROTO_DIR)
9c75c0 157
4158c0 158 $(BUILD_DIR_32)/.configured:    BITS=32
NJ 159 $(BUILD_DIR_64)/.configured:    BITS=64
9c75c0 160
e83e52 161 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
7999b2 162
9c75c0 163
b74d96 164 # temporarily work around some issues
MS 165 CONFIGURE_ENV += "ac_cv_func_realloc_0_nonnull=yes"
166 COMPONENT_BUILD_ENV += "ac_cv_func_realloc_0_nonnull=yes"
167
9c75c0 168 # configure the unpacked source for building 32 and 64 bit version
9dfd18 169 CONFIGURE_SCRIPT =    $(SOURCE_DIR)/configure
74300c 170 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
9c75c0 171     ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
NJ 172     $(COMPONENT_PRE_CONFIGURE_ACTION)
61c373 173     (cd $(@D) ; $(ENV) $(CONFIGURE_ENV) $(CONFIG_SHELL) \
9dfd18 174         $(CONFIGURE_SCRIPT) $(CONFIGURE_OPTIONS))
9c75c0 175     $(COMPONENT_POST_CONFIGURE_ACTION)
NJ 176     $(TOUCH) $@
177
178 # build the configured source
74300c 179 $(BUILD_DIR)/%/.built:    $(BUILD_DIR)/%/.configured
9c75c0 180     $(COMPONENT_PRE_BUILD_ACTION)
61c373 181     (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
c99122 182         $(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \
DH 183         $(COMPONENT_BUILD_TARGETS))
9c75c0 184     $(COMPONENT_POST_BUILD_ACTION)
NJ 185     $(TOUCH) $@
186
187 # install the built source into a prototype area
74300c 188 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built
9c75c0 189     $(COMPONENT_PRE_INSTALL_ACTION)
61c373 190     (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
4b89a1 191             $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
9c75c0 192     $(COMPONENT_POST_INSTALL_ACTION)
NJ 193     $(TOUCH) $@
74300c 194
aa27f2 195 CONFIGURE_TEST_TRANSFORMS = \
AL 196         '-n ' \
197         '-e "/TOTAL:/p" ' \
198         '-e "/SKIP:/p" ' \
199         '-e "/PASS:/p" ' \
200         '-e "/FAIL:/p" ' \
201         '-e "/ERROR:/p" '
202
8b5563 203 USE_DEFAULT_TEST_TRANSFORMS?=no
AL 204 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes)
205 COMPONENT_TEST_TRANSFORMS+= $(CONFIGURE_TEST_TRANSFORMS)
206 endif
207
3a19d0 208 # test the built source
b6799e 209 $(BUILD_DIR)/%/.tested-and-compared:    $(COMPONENT_TEST_DEP)
237543 210     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
AP 211     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
3a19d0 212     $(COMPONENT_PRE_TEST_ACTION)
8d70f8 213     -(cd $(COMPONENT_TEST_DIR) ; \
RB 214         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
215         $(COMPONENT_TEST_CMD) \
216         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
217         &> $(COMPONENT_TEST_OUTPUT)
3a19d0 218     $(COMPONENT_POST_TEST_ACTION)
8d70f8 219     $(COMPONENT_TEST_CREATE_TRANSFORMS)
RB 220     $(COMPONENT_TEST_PERFORM_TRANSFORM)
221     $(COMPONENT_TEST_COMPARE)
222     $(COMPONENT_TEST_CLEANUP)
223     $(TOUCH) $@
224
89aae0 225 $(BUILD_DIR)/%/.tested:    SHELLOPTS=pipefail
b6799e 226 $(BUILD_DIR)/%/.tested:    $(COMPONENT_TEST_DEP)
89aae0 227     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
MT 228     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
8d70f8 229     $(COMPONENT_PRE_TEST_ACTION)
RB 230     (cd $(COMPONENT_TEST_DIR) ; \
231         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
232         $(COMPONENT_TEST_CMD) \
89aae0 233         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
MT 234         |& $(TEE) $(COMPONENT_TEST_OUTPUT)
8d70f8 235     $(COMPONENT_POST_TEST_ACTION)
89aae0 236     $(COMPONENT_TEST_CREATE_TRANSFORMS)
MT 237     $(COMPONENT_TEST_PERFORM_TRANSFORM)
8d70f8 238     $(COMPONENT_TEST_CLEANUP)
3a19d0 239     $(TOUCH) $@
7999b2 240
74300c 241 clean::
NJ 242     $(RM) -r $(BUILD_DIR) $(PROTO_DIR)