fritzkink
2023-12-27 706019354bab81fc3f01995caf1ae1a2dfa346cf
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)
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 else
70 CONFIGURE_BINDIR.32  = $(CONFIGURE_PREFIX)/bin
71 CONFIGURE_BINDIR.64  = $(CONFIGURE_PREFIX)/bin/$(MACH64)
72 CONFIGURE_SBINDIR.32 = $(CONFIGURE_PREFIX)/sbin
73 CONFIGURE_SBINDIR.64 = $(CONFIGURE_PREFIX)/sbin/$(MACH64)
74 endif
75
76 # Regardless of PREFERRED_BITS, 64-bit libraries should always be delivered to
77 # the appropriate subdirectory by default.
78 CONFIGURE_LIBDIR.32  = $(CONFIGURE_PREFIX)/lib
79 CONFIGURE_LIBDIR.64  = $(CONFIGURE_PREFIX)/lib/$(MACH64)
80
4b89a1 81 CONFIGURE_MANDIR =    $(CONFIGURE_PREFIX)/share/man
NJ 82 CONFIGURE_LOCALEDIR =    $(CONFIGURE_PREFIX)/share/locale
83 # all texinfo documentation seems to go to /usr/share/info no matter what
84 CONFIGURE_INFODIR =    /usr/share/info
f0c88f 85 CONFIGURE_INCLUDEDIR =    /usr/include
4b89a1 86
aeb6c4 87 CONFIGURE_ENV = CONFIG_SHELL="$(CONFIG_SHELL)"
8a1ca7 88 CONFIGURE_ENV += PATH="$(PATH)"
6842d7 89 CONFIGURE_ENV += CC="$(CC)"
AS 90 CONFIGURE_ENV += CXX="$(CXX)"
097bb0 91 CONFIGURE_ENV += F77="$(F77)"
AL 92 CONFIGURE_ENV += FC="$(FC)"
dfeb21 93 CONFIGURE_ENV += CFLAGS="$(CFLAGS)"
AS 94 CONFIGURE_ENV += CXXFLAGS="$(CXXFLAGS)"
097bb0 95 CONFIGURE_ENV += FFLAGS="$(F77FLAGS)"
AL 96 CONFIGURE_ENV += FCFLAGS="$(FCFLAGS)"
dfeb21 97 CONFIGURE_ENV += LDFLAGS="$(LDFLAGS)"
AS 98 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
aeb6c4 99
c5572a 100 # Rewrite absolute source-code paths into relative for ccache, so that any
JK 101 # workspace with a shared CCACHE_DIR can benefit when compiling a component
102 ifneq ($(strip $(CCACHE)),)
103 CONFIGURE_ENV += CCACHE="$(CCACHE)"
104 CONFIGURE_OPTIONS += CCACHE="$(CCACHE)"
105 CONFIGURE_ENV += CC_gcc_32="$(CC_gcc_32)"
106 CONFIGURE_ENV += CC_gcc_64="$(CC_gcc_32)"
107 CONFIGURE_ENV += CXX_gcc_32="$(CXX_gcc_64)"
108 CONFIGURE_ENV += CXX_gcc_64="$(CXX_gcc_64)"
109 CONFIGURE_OPTIONS += CC_gcc_32="$(CC_gcc_32)"
110 CONFIGURE_OPTIONS += CC_gcc_64="$(CC_gcc_32)"
111 CONFIGURE_OPTIONS += CXX_gcc_32="$(CXX_gcc_64)"
112 CONFIGURE_OPTIONS += CXX_gcc_64="$(CXX_gcc_64)"
113 CONFIGURE_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
114 CONFIGURE_OPTIONS.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
115
116 ifneq ($(strip $(CCACHE_DIR)),)
117 CONFIGURE_ENV += CCACHE_DIR="$(CCACHE_DIR)"
118 CONFIGURE_OPTIONS += CCACHE_DIR="$(CCACHE_DIR)"
119 endif
120
121 ifneq ($(strip $(CCACHE_LOGFILE)),)
122 CONFIGURE_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
123 CONFIGURE_OPTIONS += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
124 endif
125
126 endif
127
312c03 128 CONFIGURE_DEFAULT_DIRS?=yes
PS 129
f341a6 130 CONFIGURE_OPTIONS += CC="$(CC)"
AS 131 CONFIGURE_OPTIONS += CXX="$(CXX)"
097bb0 132 CONFIGURE_OPTIONS += F77="$(F77)"
AL 133 CONFIGURE_OPTIONS += FC="$(FC)"
dfeb21 134 CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)"
AS 135 CONFIGURE_OPTIONS += CXXFLAGS="$(CXXFLAGS)"
097bb0 136 CONFIGURE_OPTIONS += FFLAGS="$(F77FLAGS)"
AL 137 CONFIGURE_OPTIONS += FCFLAGS="$(FCFLAGS)"
dfeb21 138 CONFIGURE_OPTIONS += LDFLAGS="$(LDFLAGS)"
AS 139 CONFIGURE_OPTIONS += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
f341a6 140
4b89a1 141 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
312c03 142 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
4b89a1 143 CONFIGURE_OPTIONS += --mandir=$(CONFIGURE_MANDIR)
NJ 144 CONFIGURE_OPTIONS += --bindir=$(CONFIGURE_BINDIR.$(BITS))
145 CONFIGURE_OPTIONS += --libdir=$(CONFIGURE_LIBDIR.$(BITS))
9dfd18 146 CONFIGURE_OPTIONS += --sbindir=$(CONFIGURE_SBINDIR.$(BITS))
312c03 147 endif
e83e52 148 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
4b89a1 149
NJ 150 COMPONENT_INSTALL_ARGS +=    DESTDIR=$(PROTO_DIR)
9c75c0 151
4158c0 152 $(BUILD_DIR_32)/.configured:    BITS=32
NJ 153 $(BUILD_DIR_64)/.configured:    BITS=64
9c75c0 154
e83e52 155 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
7999b2 156
9c75c0 157
b74d96 158 # temporarily work around some issues
MS 159 CONFIGURE_ENV += "ac_cv_func_realloc_0_nonnull=yes"
160 COMPONENT_BUILD_ENV += "ac_cv_func_realloc_0_nonnull=yes"
161
9c75c0 162 # configure the unpacked source for building 32 and 64 bit version
9dfd18 163 CONFIGURE_SCRIPT =    $(SOURCE_DIR)/configure
74300c 164 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
9c75c0 165     ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
NJ 166     $(COMPONENT_PRE_CONFIGURE_ACTION)
61c373 167     (cd $(@D) ; $(ENV) $(CONFIGURE_ENV) $(CONFIG_SHELL) \
9dfd18 168         $(CONFIGURE_SCRIPT) $(CONFIGURE_OPTIONS))
9c75c0 169     $(COMPONENT_POST_CONFIGURE_ACTION)
NJ 170     $(TOUCH) $@
171
172 # build the configured source
74300c 173 $(BUILD_DIR)/%/.built:    $(BUILD_DIR)/%/.configured
9c75c0 174     $(COMPONENT_PRE_BUILD_ACTION)
61c373 175     (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
c99122 176         $(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \
DH 177         $(COMPONENT_BUILD_TARGETS))
9c75c0 178     $(COMPONENT_POST_BUILD_ACTION)
NJ 179     $(TOUCH) $@
180
181 # install the built source into a prototype area
74300c 182 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built
9c75c0 183     $(COMPONENT_PRE_INSTALL_ACTION)
61c373 184     (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
4b89a1 185             $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
9c75c0 186     $(COMPONENT_POST_INSTALL_ACTION)
NJ 187     $(TOUCH) $@
74300c 188
aa27f2 189 CONFIGURE_TEST_TRANSFORMS = \
AL 190         '-n ' \
191         '-e "/TOTAL:/p" ' \
192         '-e "/SKIP:/p" ' \
193         '-e "/PASS:/p" ' \
194         '-e "/FAIL:/p" ' \
195         '-e "/ERROR:/p" '
196
8b5563 197 USE_DEFAULT_TEST_TRANSFORMS?=no
AL 198 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes)
199 COMPONENT_TEST_TRANSFORMS+= $(CONFIGURE_TEST_TRANSFORMS)
200 endif
201
3a19d0 202 # test the built source
8d70f8 203 $(BUILD_DIR)/%/.tested-and-compared:    $(BUILD_DIR)/%/.built
237543 204     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
AP 205     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
3a19d0 206     $(COMPONENT_PRE_TEST_ACTION)
8d70f8 207     -(cd $(COMPONENT_TEST_DIR) ; \
RB 208         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
209         $(COMPONENT_TEST_CMD) \
210         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
211         &> $(COMPONENT_TEST_OUTPUT)
3a19d0 212     $(COMPONENT_POST_TEST_ACTION)
8d70f8 213     $(COMPONENT_TEST_CREATE_TRANSFORMS)
RB 214     $(COMPONENT_TEST_PERFORM_TRANSFORM)
215     $(COMPONENT_TEST_COMPARE)
216     $(COMPONENT_TEST_CLEANUP)
217     $(TOUCH) $@
218
89aae0 219 $(BUILD_DIR)/%/.tested:    SHELLOPTS=pipefail
8d70f8 220 $(BUILD_DIR)/%/.tested:    $(BUILD_DIR)/%/.built
89aae0 221     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
MT 222     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
8d70f8 223     $(COMPONENT_PRE_TEST_ACTION)
RB 224     (cd $(COMPONENT_TEST_DIR) ; \
225         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
226         $(COMPONENT_TEST_CMD) \
89aae0 227         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
MT 228         |& $(TEE) $(COMPONENT_TEST_OUTPUT)
8d70f8 229     $(COMPONENT_POST_TEST_ACTION)
89aae0 230     $(COMPONENT_TEST_CREATE_TRANSFORMS)
MT 231     $(COMPONENT_TEST_PERFORM_TRANSFORM)
8d70f8 232     $(COMPONENT_TEST_CLEANUP)
3a19d0 233     $(TOUCH) $@
7999b2 234
74300c 235 clean::
NJ 236     $(RM) -r $(BUILD_DIR) $(PROTO_DIR)