Marcel Telka
2024-04-06 e3d6dbd6d802688684024dece3f85bc623dfcba7
commit | author | age
abaa48 1 #
AP 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 #
21 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
22 #
23 #
24 # Rules and Macros for building opens source software that uses the waf
25 # build system from https://waf.io/
26 #
27 # To use these rules, include $(WS_MAKE_RULES)/waf.mk in your Makefile
28 # and define "build", "install" targets appropriate to building your component.
29 # Ex:
30 #
31 #     build:        $(BUILD_32) \
32 #             $(BUILD_64)
33
34 #    install:    $(INSTALL_32) \
35 #             $(INSTALL_64)
36 #
37 # Any additional pre/post configure, build, or install actions can be specified
38 # in your Makefile by setting them in on of the following macros:
39 #    COMPONENT_PRE_BUILD_ACTION, COMPONENT_POST_BUILD_ACTION
40 #    COMPONENT_PRE_INSTALL_ACTION, COMPONENT_POST_INSTALL_ACTION
41 #
42 # If component specific make targets need to be used for build or install, they
43 # can be specified in
44 #    COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS
45 #
46
47 # Defaults to looking for waf script in top level of cloned source
48 WAF = $(PYTHON) waf
49
50 CONFIGURE_PREFIX =    /usr
51
0b2b25 52 ifeq ($(strip $(PREFERRED_BITS)),64)
AL 53 CONFIGURE_BINDIR.32 =    $(CONFIGURE_PREFIX)/bin/$(MACH32)
54 CONFIGURE_BINDIR.64 =    $(CONFIGURE_PREFIX)/bin
55 CONFIGURE_SBINDIR.32 =    $(CONFIGURE_PREFIX)/sbin/$(MACH32)
56 CONFIGURE_SBINDIR.64 =    $(CONFIGURE_PREFIX)/sbin
57 else
abaa48 58 CONFIGURE_BINDIR.32 =    $(CONFIGURE_PREFIX)/bin
AP 59 CONFIGURE_BINDIR.64 =    $(CONFIGURE_PREFIX)/bin/$(MACH64)
60 CONFIGURE_SBINDIR.32 =    $(CONFIGURE_PREFIX)/sbin
61 CONFIGURE_SBINDIR.64 =    $(CONFIGURE_PREFIX)/sbin/$(MACH64)
0b2b25 62 endif
AL 63 CONFIGURE_LIBDIR.32 =    $(CONFIGURE_PREFIX)/lib
64 CONFIGURE_LIBDIR.64 =    $(CONFIGURE_PREFIX)/lib/$(MACH64)
abaa48 65 CONFIGURE_MANDIR =    $(CONFIGURE_PREFIX)/share/man
AP 66 CONFIGURE_LOCALEDIR =    $(CONFIGURE_PREFIX)/share/locale
67
68 CONFIGURE_DEFAULT_DIRS?=yes
69 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
70 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
71 CONFIGURE_OPTIONS += --mandir=$(CONFIGURE_MANDIR)
72 ifeq ($(INITIAL_BITS),64)
73 CONFIGURE_OPTIONS += --bindir=$(CONFIGURE_BINDIR.32)
74 CONFIGURE_OPTIONS += --sbindir=$(CONFIGURE_SBINDIR.32)
75 else
76 CONFIGURE_OPTIONS += --bindir=$(CONFIGURE_BINDIR.$(BITS))
77 CONFIGURE_OPTIONS += --sbindir=$(CONFIGURE_SBINDIR.$(BITS))
78 endif
79 CONFIGURE_OPTIONS += --libdir=$(CONFIGURE_LIBDIR.$(BITS))
80 endif
81 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
82 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH))
83 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH).$(BITS))
84
85 CONFIGURE_ENV += CC="$(CC) $(CC_BITS)"
86 CONFIGURE_ENV += CFLAGS="$(CFLAGS)"
87 CONFIGURE_ENV += CXX="$(CXX) $(CC_BITS)"
88 CONFIGURE_ENV += CXXFLAGS="$(CXXFLAGS)"
89 CONFIGURE_ENV += LDFLAGS="$(LDFLAGS)"
90 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
91 CONFIGURE_ENV += PYTHON="$(PYTHON)"
92 CONFIGURE_ENV += PYTHONDIR="$(PYTHON_LIB)"
93 CONFIGURE_ENV += PYTHONARCHDIR="$(PYTHON_VENDOR_PACKAGES)"
94
95 # configure the unpacked source
96 COMPONENT_CONFIGURE_TARGETS ?= configure
97
98 $(BUILD_DIR_32)/.configured:        BITS=32
99 $(BUILD_DIR_64)/.configured:        BITS=64
100 $(BUILD_DIR)/$(MACH32)-%/.configured:    BITS=32
101 $(BUILD_DIR)/$(MACH64)-%/.configured:    BITS=64
102 $(foreach pyver, $(PYTHON_VERSIONS), \
103     $(eval $(BUILD_DIR)/%-$(pyver)/.configured: PYTHON_VERSION=$(pyver)) \
104 )
105
106 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
107     $(RM) -r $(@D) ; $(MKDIR) $(@D)
c529ec 108     $(ENV) $(CLONEY_ARGS) $(CLONEY) $(SOURCE_DIR) $(@D)
abaa48 109     $(COMPONENT_PRE_CONFIGURE_ACTION)
AP 110     (cd $(@D) ; $(ENV) $(CONFIGURE_ENV) \
111         $(WAF) $(COMPONENT_CONFIGURE_TARGETS) $(CONFIGURE_OPTIONS))
112     $(COMPONENT_POST_CONFIGURE_ACTION)
113     $(TOUCH) $@
114
115 # build the configured source
116 COMPONENT_BUILD_TARGETS ?= build
117
118 $(BUILD_DIR_32)/.built:            BITS=32
119 $(BUILD_DIR_64)/.built:            BITS=64
120 $(BUILD_DIR)/$(MACH32)-%/.built:    BITS=32
121 $(BUILD_DIR)/$(MACH64)-%/.built:    BITS=64
122 $(foreach pyver, $(PYTHON_VERSIONS), \
123     $(eval $(BUILD_DIR)/%-$(pyver)/.built: PYTHON_VERSION=$(pyver)) \
124 )
125
126 $(BUILD_DIR)/%/.built:    $(BUILD_DIR)/%/.configured
127     $(COMPONENT_PRE_BUILD_ACTION)
128     (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
129         $(WAF) $(COMPONENT_BUILD_TARGETS) $(COMPONENT_BUILD_ARGS))
130     $(COMPONENT_POST_BUILD_ACTION)
131     $(TOUCH) $@
132
133 # If BUILD_STYLE is set, provide a default configure target.
134 ifeq   ($(strip $(BUILD_STYLE)),waf)
135 configure:    $(CONFIGURE_$(MK_BITS))
136 endif
137
138 # install the built source into a prototype area
139 COMPONENT_INSTALL_ARGS += --destdir=$(PROTO_DIR)
140 COMPONENT_INSTALL_ARGS += $(COMPONENT_INSTALL_ARGS.$(BITS))
141
142 $(BUILD_DIR_32)/.installed:        BITS=32
143 $(BUILD_DIR_64)/.installed:        BITS=64
144 $(BUILD_DIR)/$(MACH32)-%/.installed:    BITS=32
145 $(BUILD_DIR)/$(MACH64)-%/.installed:    BITS=64
146 $(foreach pyver, $(PYTHON_VERSIONS), \
147     $(eval $(BUILD_DIR)/%-$(pyver)/.installed: PYTHON_VERSION=$(pyver)) \
148 )
149
150 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built
151     $(COMPONENT_PRE_INSTALL_ACTION)
152     (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) \
153          $(WAF) $(COMPONENT_INSTALL_TARGETS) $(COMPONENT_INSTALL_ARGS))
154     $(COMPONENT_POST_INSTALL_ACTION)
155     $(TOUCH) $@
156
157 # test the built source
158 COMPONENT_TEST_CMD = $(WAF)
159 COMPONENT_TEST_TARGETS = test
160
161 $(BUILD_DIR_32)/.tested-and-compared:        BITS=32
162 $(BUILD_DIR_64)/.tested-and-compared:        BITS=64
163 $(BUILD_DIR)/$(MACH32)-%/.tested-and-compared:    BITS=32
164 $(BUILD_DIR)/$(MACH64)-%/.tested-and-compared:    BITS=64
165 $(foreach pyver, $(PYTHON_VERSIONS), \
166     $(eval $(BUILD_DIR)/%-$(pyver)/.tested-and-compared: PYTHON_VERSION=$(pyver)) \
167 )
168
b6799e 169 $(BUILD_DIR)/%/.tested-and-compared:    $(COMPONENT_TEST_DEP)
abaa48 170     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
AP 171     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
172     $(COMPONENT_PRE_TEST_ACTION)
173     -(cd $(COMPONENT_TEST_DIR) ; \
174         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
175         $(COMPONENT_TEST_CMD) \
176         $(COMPONENT_TEST_TARGETS) $(COMPONENT_TEST_ARGS)) \
177         &> $(COMPONENT_TEST_OUTPUT)
178     $(COMPONENT_POST_TEST_ACTION)
179     $(COMPONENT_TEST_CREATE_TRANSFORMS)
180     $(COMPONENT_TEST_PERFORM_TRANSFORM)
181     $(COMPONENT_TEST_COMPARE)
182     $(COMPONENT_TEST_CLEANUP)
183     $(TOUCH) $@
184
185 $(BUILD_DIR_32)/.tested:        BITS=32
186 $(BUILD_DIR_64)/.tested:        BITS=64
187 $(BUILD_DIR)/$(MACH32)-%/.tested:    BITS=32
188 $(BUILD_DIR)/$(MACH64)-%/.tested:    BITS=64
189 $(foreach pyver, $(PYTHON_VERSIONS), \
190     $(eval $(BUILD_DIR)/%-$(pyver)/.tested: PYTHON_VERSION=$(pyver)) \
191 )
192
89aae0 193 $(BUILD_DIR)/%/.tested:    SHELLOPTS=pipefail
b6799e 194 $(BUILD_DIR)/%/.tested:    $(COMPONENT_TEST_DEP)
89aae0 195     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
MT 196     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
abaa48 197     $(COMPONENT_PRE_TEST_ACTION)
AP 198     (cd $(COMPONENT_TEST_DIR) ; \
199         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
200         $(COMPONENT_TEST_CMD) \
89aae0 201         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
MT 202         |& $(TEE) $(COMPONENT_TEST_OUTPUT)
abaa48 203     $(COMPONENT_POST_TEST_ACTION)
89aae0 204     $(COMPONENT_TEST_CREATE_TRANSFORMS)
MT 205     $(COMPONENT_TEST_PERFORM_TRANSFORM)
abaa48 206     $(COMPONENT_TEST_CLEANUP)
AP 207     $(TOUCH) $@
208
209 # Test the installed packages.  The targets above depend on .built which
210 # means $(CLONEY) has already run.  System-test needs cloning but not
211 # building; thus ideally, we would want to depend on .cloned here and below,
212 # but since we don't have that, we depend on .prep and run $(CLONEY) here.
213 $(BUILD_DIR)/%/.system-tested-and-compared:    $(SOURCE_DIR)/.prep
214     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
215     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
c529ec 216     $(ENV) $(CLONEY_ARGS) $(CLONEY) $(SOURCE_DIR) $(@D)
abaa48 217     $(COMPONENT_PRE_SYSTEM_TEST_ACTION)
AP 218     -(cd $(COMPONENT_SYSTEM_TEST_DIR) ; \
219         $(COMPONENT_SYSTEM_TEST_ENV_CMD) $(COMPONENT_SYSTEM_TEST_ENV) \
220         $(COMPONENT_SYSTEM_TEST_CMD) \
221         $(COMPONENT_SYSTEM_TEST_ARGS) $(COMPONENT_SYSTEM_TEST_TARGETS)) \
222         &> $(COMPONENT_TEST_OUTPUT)
223     $(COMPONENT_POST_SYSTEM_TEST_ACTION)
224     $(COMPONENT_TEST_CREATE_TRANSFORMS)
225     $(COMPONENT_TEST_PERFORM_TRANSFORM)
226     $(COMPONENT_TEST_COMPARE)
227     $(COMPONENT_SYSTEM_TEST_CLEANUP)
228     $(TOUCH) $@
229
89aae0 230 $(BUILD_DIR)/%/.system-tested:    SHELLOPTS=pipefail
abaa48 231 $(BUILD_DIR)/%/.system-tested:    $(SOURCE_DIR)/.prep
89aae0 232     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
MT 233     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
c529ec 234     $(ENV) $(CLONEY_ARGS) $(CLONEY) $(SOURCE_DIR) $(@D)
abaa48 235     $(COMPONENT_PRE_SYSTEM_TEST_ACTION)
AP 236     (cd $(COMPONENT_SYSTEM_TEST_DIR) ; \
237         $(COMPONENT_SYSTEM_TEST_ENV_CMD) $(COMPONENT_SYSTEM_TEST_ENV) \
238         $(COMPONENT_SYSTEM_TEST_CMD) \
89aae0 239         $(COMPONENT_SYSTEM_TEST_ARGS) $(COMPONENT_SYSTEM_TEST_TARGETS)) \
MT 240         |& $(TEE) $(COMPONENT_TEST_OUTPUT)
abaa48 241     $(COMPONENT_POST_SYSTEM_TEST_ACTION)
89aae0 242     $(COMPONENT_TEST_CREATE_TRANSFORMS)
MT 243     $(COMPONENT_TEST_PERFORM_TRANSFORM)
abaa48 244     $(COMPONENT_SYSTEM_TEST_CLEANUP)
AP 245     $(TOUCH) $@
246
247 clean::
248     $(RM) -r $(BUILD_DIR) $(PROTO_DIR)