curl: update to 8.11.1
[oi-userland.git] / make-rules / common.mk
blobb0e44442bc6d412039349fc031606c4b0d332022
2 # CDDL HEADER START
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]
19 # CDDL HEADER END
23 # Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
27 # This file sets up the standard, default options and base requirements for
28 # userland components.
30 .NOTPARALLEL:
32 # Assume components use a configure script-style build by default.
33 BUILD_STYLE ?= configure
35 # Some build styles might want to set some defaults before prep.mk is included.
36 -include $(WS_MAKE_RULES)/$(strip $(BUILD_STYLE))-defaults.mk
38 # The SINGLE_PERL_VERSION variable is used to select building a component for
39 # single or multiple Perl versions. By default we build for single Perl
40 # version only unless the component is a Perl module. If the default value of
41 # SINGLE_PERL_VERSION is not what is needed for a component it could be
42 # overridden in component's Makefile.
43 SINGLE_PERL_VERSION ?= yes
44 ifeq ($(strip $(SINGLE_PERL_VERSION)),yes)
45 PERL_VERSIONS = $(PERL_VERSION)
46 endif
48 # The SINGLE_PYTHON_VERSION variable is used to select building a component for
49 # single or multiple Python versions. By default we build for single Python
50 # version only unless the component is a Python project. If the default value
51 # of SINGLE_PYTHON_VERSION is not what is needed for a component it could be
52 # overridden in component's Makefile.
53 SINGLE_PYTHON_VERSION ?= yes
54 ifeq ($(strip $(SINGLE_PYTHON_VERSION)),yes)
55 PYTHON_VERSIONS = $(PYTHON_VERSION)
56 endif
58 include $(WS_MAKE_RULES)/prep.mk
60 # Override this to limit builds and publication to a single architecture.
61 BUILD_ARCH ?= $(MACH)
62 ifneq ($(strip $(BUILD_ARCH)),$(MACH))
63 PUBLISH_STAMP=
65 target-na:
66 @echo "Not available for $(MACH)"
68 BUILD_TARGET ?= target-na
69 INSTALL_TARGET ?= target-na
70 TEST_TARGET ?= target-na
71 SYSTEM_TEST_TARGET ?= target-na
72 endif
74 # If not an archive build (i.e. extract and copy) or pkg build (publish only),
75 # include relevant makefile.
76 ifneq ($(strip $(BUILD_STYLE)),archive)
77 ifneq ($(strip $(BUILD_STYLE)),pkg)
78 include $(WS_MAKE_RULES)/$(strip $(BUILD_STYLE)).mk
80 # Include common rules used by build styles that opted to use them
81 USE_COMMON_RULES ?= no
82 ifneq ($(strip $(USE_COMMON_RULES)),no)
83 include $(WS_MAKE_RULES)/common-rules.mk
84 endif
85 endif
86 endif
88 ifeq ($(strip $(BUILD_STYLE)),configure)
89 # Assume these items should always be set in the configure environment. strip
90 # is used to work around potential problems with extra blank characters
91 # inserted into strings during nested configure invocations within builds for
92 # components such as gdb.
93 ifneq ($(strip $(CFLAGS)),)
94 # Only if provided.
95 CONFIGURE_ENV += CFLAGS="$(strip $(CFLAGS))"
96 endif
97 ifneq ($(strip $(CXXFLAGS)),)
98 # Only if provided.
99 CONFIGURE_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
100 endif
101 # Always process LDFLAGS.
102 CONFIGURE_ENV += LDFLAGS="$(strip $(LDFLAGS))"
103 endif
105 ifeq ($(strip $(BUILD_STYLE)),justmake)
106 # Assume these items should always be set in the build environment.
107 COMPONENT_BUILD_ENV += CC="$(CC)"
108 COMPONENT_BUILD_ENV += CXX="$(CXX)"
109 ifneq ($(strip $(CFLAGS)),)
110 # Only if provided.
111 COMPONENT_BUILD_ENV += CFLAGS="$(strip $(CFLAGS))"
112 endif
113 ifneq ($(strip $(CXXFLAGS)),)
114 # Only if provided.
115 COMPONENT_BUILD_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
116 endif
117 # Always process LDFLAGS.
118 COMPONENT_BUILD_ENV += LDFLAGS="$(strip $(LDFLAGS))"
119 endif
121 # Assume components built with ant do not need ASLR.
122 ifeq ($(strip $(BUILD_STYLE)),ant)
123 ASLR_MODE= $(ASLR_NOT_APPLICABLE)
124 else
125 ifeq ($(strip $(DEFAULT_ASLR_ENABLE)),yes)
126 # Enable ASLR by default unless target build is NO_ARCH.
127 ifneq ($(strip $(BUILD_BITS)),NO_ARCH)
128 ASLR_MODE= $(ASLR_ENABLE)
129 endif # DEFAULT_ASLR_ENABLE yes
130 endif # BUILD_BITS NO_ARCH
131 endif # BUILD_STYLE ant
133 # Default targets; to omit a specific target, explicitly set the related target
134 # variable to empty before including this file or set COMMON_TARGETS=no.
135 COMMON_TARGETS ?= yes
137 ifneq ($(strip $(COMMON_TARGETS)),no)
138 # For ant-based build style, assume that install is provided by simply building
139 # the component and that no tests are available.
140 ifeq ($(strip $(BUILD_STYLE)),ant)
141 INSTALL_TARGET ?= build
142 TEST_TARGET ?= $(NO_TESTS)
143 SYSTEM_TEST_TARGET ?= $(NO_TESTS)
144 endif
146 # For archive-based build style, assume that the build, install, and test
147 # targets will be provided.
148 ifeq ($(strip $(BUILD_STYLE)),archive)
149 BUILD_TARGET ?=
150 INSTALL_TARGET ?=
151 TEST_TARGET ?=
152 endif
154 # For pkg-based build style, assume there are no build, install, or test steps;
155 # just a package to be published. However, 'gmake sample-manifest' requires
156 # proto dir. Since sample-manifest generation depends on install target we
157 # will abuse it to get the required dir created.
158 ifeq ($(strip $(BUILD_STYLE)),pkg)
159 BUILD_TARGET=
160 INSTALL_TARGET = $(BUILD_DIR)/.installed
161 TEST_TARGET=
162 SYSTEM_TEST_TARGET=
163 build:
164 test system-test: $(NO_TESTS)
166 $(BUILD_DIR)/.installed:
167 $(RM) -r $(BUILD_DIR)
168 $(MKDIR) $(PROTO_DIR)
169 $(TOUCH) $@
171 clean::
172 $(RM) -r $(BUILD_DIR)
173 endif
175 # If TEST_TARGET is NO_TESTS, assume no system tests by default.
176 ifeq ($(strip $(TEST_TARGET)),$(NO_TESTS))
177 SYSTEM_TEST_TARGET ?= $(NO_TESTS)
178 endif
180 # If TEST_TARGET is SKIP_TEST, assume system tests are skipped by default.
181 ifeq ($(strip $(TEST_TARGET)),$(SKIP_TEST))
182 SYSTEM_TEST_TARGET ?= $(SKIP_TEST)
183 endif
185 # Otherwise, attempt to define common targets assuming defaults.
186 BUILD_TARGET ?= $(BUILD_$(MK_BITS))
187 ifneq ($(strip $(BUILD_TARGET)),)
188 build: $(BUILD_TARGET)
189 endif
191 INSTALL_TARGET ?= $(INSTALL_$(MK_BITS))
192 ifneq ($(strip $(INSTALL_TARGET)),)
193 install: $(INSTALL_TARGET)
194 endif
196 TEST_TARGET ?= $(TEST_$(MK_BITS))
197 ifneq ($(strip $(TEST_TARGET)),)
198 test: $(TEST_TARGET)
199 endif
201 # For the system-test target, assume that none have been implemented.
202 SYSTEM_TEST_TARGET ?= $(SYSTEM_TESTS_NOT_IMPLEMENTED)
203 ifneq ($(strip $(SYSTEM_TEST_TARGET)),)
204 system-test: $(SYSTEM_TEST_TARGET)
205 endif
206 endif # COMMON_TARGETS
208 # Always needed; every component builds packages.
209 include $(WS_MAKE_RULES)/ips.mk
211 # Determine if we should automatically add files directory to PKG_PROTO_DIRS.
212 ifeq ($(wildcard files),files)
213 PKG_PROTO_DIRS += $(COMPONENT_DIR)/files
214 endif
216 # Add bit and mach-specific logic to general actions.
217 COMPONENT_PRE_CONFIGURE_ACTION += $(COMPONENT_PRE_CONFIGURE_ACTION.$(BITS))
218 COMPONENT_PRE_CONFIGURE_ACTION += $(COMPONENT_PRE_CONFIGURE_ACTION.$(MACH))
219 COMPONENT_POST_CONFIGURE_ACTION += $(COMPONENT_POST_CONFIGURE_ACTION.$(BITS))
220 COMPONENT_POST_CONFIGURE_ACTION += $(COMPONENT_POST_CONFIGURE_ACTION.$(MACH))
221 COMPONENT_PRE_BUILD_ACTION += $(COMPONENT_PRE_BUILD_ACTION.$(BITS))
222 COMPONENT_PRE_BUILD_ACTION += $(COMPONENT_PRE_BUILD_ACTION.$(MACH))
223 COMPONENT_POST_BUILD_ACTION += $(COMPONENT_POST_BUILD_ACTION.$(BITS))
224 COMPONENT_POST_BUILD_ACTION += $(COMPONENT_POST_BUILD_ACTION.$(MACH))
225 COMPONENT_PRE_INSTALL_ACTION += $(COMPONENT_PRE_INSTALL_ACTION.$(BITS))
226 COMPONENT_PRE_INSTALL_ACTION += $(COMPONENT_PRE_INSTALL_ACTION.$(MACH))
227 COMPONENT_POST_INSTALL_ACTION += $(COMPONENT_POST_INSTALL_ACTION.$(BITS))
228 COMPONENT_POST_INSTALL_ACTION += $(COMPONENT_POST_INSTALL_ACTION.$(MACH))
229 COMPONENT_PRE_TEST_ACTION += $(COMPONENT_PRE_TEST_ACTION.$(BITS))
230 COMPONENT_PRE_TEST_ACTION += $(COMPONENT_PRE_TEST_ACTION.$(MACH))
231 COMPONENT_POST_TEST_ACTION += $(COMPONENT_POST_TEST_ACTION.$(BITS))
232 COMPONENT_POST_TEST_ACTION += $(COMPONENT_POST_TEST_ACTION.$(MACH))
234 # In an ideal world all components should support parallel build but it is
235 # often not the case. So by default we do not run parallel build and allow
236 # components to opt-in for parallel build by setting USE_PARALLEL_BUILD = yes.
237 PARALLEL_JOBS ?= $(shell /usr/sbin/psrinfo -t -c)
238 ifeq ($(strip $(USE_PARALLEL_BUILD)),yes)
239 COMPONENT_BUILD_CMAKE_ARGS += -j$(PARALLEL_JOBS)
240 COMPONENT_BUILD_GMAKE_ARGS += -j$(PARALLEL_JOBS)
241 COMPONENT_BUILD_SETUP_PY_ARGS += -j$(PARALLEL_JOBS)
242 endif