Marcel Telka
2023-07-21 8f1b0ee62a3589b6b0bfd4f886ae9f6bfd9ea76a
commit | author | age
5a9d2b 1
6bc9bf 2 # CDDL HEADER START
CM 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 #
702558 21 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
6bc9bf 22 #
CM 23
de49ed 24 # Common perl environment
6bc9bf 25 COMMON_PERL_ENV +=    MAKE=$(GMAKE)
0f8a2f 26 COMMON_PERL_ENV +=    PATH=$(dir $(CC)):$(PATH)
6bc9bf 27 COMMON_PERL_ENV +=    LANG=""
CM 28 COMMON_PERL_ENV +=    CC="$(CC)"
e552f1 29 COMMON_PERL_ENV +=    CFLAGS="$(CC_BITS) $(PERL_OPTIMIZE)"
6bc9bf 30
20542b 31 # Particular perl runtime is always required (at least to run Makefile.PL)
MT 32 PERL_REQUIRED_PACKAGES += runtime/perl
33
6bc9bf 34 # Yes.  Perl is just scripts, for now, but we need architecture
CM 35 # directories so that it populates all architecture prototype
36 # directories.
37
ecce9a 38 define perl-version-rule
MT 39 $(BUILD_DIR)/%-$(1)/.configured:        PERL_VERSION=$(1)
40 $(BUILD_DIR)/%-$(1)/.built:            PERL_VERSION=$(1)
41 $(BUILD_DIR)/%-$(1)/.installed:            PERL_VERSION=$(1)
42 $(BUILD_DIR)/%-$(1)/.tested:            PERL_VERSION=$(1)
43 $(BUILD_DIR)/%-$(1)/.tested-and-compared:    PERL_VERSION=$(1)
372e47 44
MT 45 $(BUILD_DIR)/%-$(1)/.depend-build:        PERL_VERSION=$(1)
46 $(BUILD_DIR)/%-$(1)/.depend-runtime:        PERL_VERSION=$(1)
47 $(BUILD_DIR)/%-$(1)/.depend-test:        PERL_VERSION=$(1)
ecce9a 48 endef
MT 49 $(foreach perlver,$(PERL_VERSIONS),$(eval $(call perl-version-rule,$(perlver))))
50
6b1597 51 $(BUILD_DIR)/$(MACH32)-%/.configured:    BITS=32
TM 52 $(BUILD_DIR)/$(MACH64)-%/.configured:    BITS=64
6bc9bf 53
6b1597 54 $(BUILD_DIR)/$(MACH32)-%/.built:    BITS=32
TM 55 $(BUILD_DIR)/$(MACH64)-%/.built:    BITS=64
74a265 56
6b1597 57 $(BUILD_DIR)/$(MACH32)-%/.installed:    BITS=32
TM 58 $(BUILD_DIR)/$(MACH64)-%/.installed:    BITS=64
8d70f8 59
6b1597 60 $(BUILD_DIR)/$(MACH32)-%/.tested:    BITS=32
TM 61 $(BUILD_DIR)/$(MACH64)-%/.tested:    BITS=64
8d70f8 62
6b1597 63 $(BUILD_DIR)/$(MACH32)-%/.tested-and-compared:    BITS=32
TM 64 $(BUILD_DIR)/$(MACH64)-%/.tested-and-compared:    BITS=64
cacdb3 65
6b1597 66 PERL_32_ONLY_VERSIONS = $(filter-out $(PERL_64_ONLY_VERSIONS), $(PERL_VERSIONS))
6bc9bf 67
6b1597 68 BUILD_32 =    $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
TM 69 BUILD_64 =    $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
70 BUILD_NO_ARCH =    $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
71
72 INSTALL_32 = $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
73 INSTALL_64 = $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
74 INSTALL_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
6bc9bf 75
CM 76 COMPONENT_CONFIGURE_ENV +=    $(COMMON_PERL_ENV)
77 COMPONENT_CONFIGURE_ENV +=    PERL="$(PERL)"
9581d1 78 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
6bc9bf 79     ($(RM) -r $(@D) ; $(MKDIR) $(@D))
6feee0 80     $(ENV) $(CLONEY_ARGS) $(CLONEY) $(SOURCE_DIR) $(@D)
6bc9bf 81     $(COMPONENT_PRE_CONFIGURE_ACTION)
CM 82     (cd $(@D) ; $(COMPONENT_CONFIGURE_ENV) $(PERL) $(PERL_FLAGS) \
0f8a2f 83                 Makefile.PL $(CONFIGURE_OPTIONS))
6bc9bf 84     $(COMPONENT_POST_CONFIGURE_ACTION)
CM 85     $(TOUCH) $@
86
87
88 COMPONENT_BUILD_ENV +=    $(COMMON_PERL_ENV)
9581d1 89 $(BUILD_DIR)/%/.built:    $(BUILD_DIR)/%/.configured
6bc9bf 90     $(COMPONENT_PRE_BUILD_ACTION)
CM 91     (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
c99122 92         $(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \
DH 93         $(COMPONENT_BUILD_TARGETS))
6bc9bf 94     $(COMPONENT_POST_BUILD_ACTION)
CM 95     $(TOUCH) $@
96
97
98 COMPONENT_INSTALL_ARGS +=    DESTDIR="$(PROTO_DIR)"
99 COMPONENT_INSTALL_TARGETS =    install_vendor
100 COMPONENT_INSTALL_ENV +=    $(COMMON_PERL_ENV)
9581d1 101 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built
6bc9bf 102     $(COMPONENT_PRE_INSTALL_ACTION)
CM 103     (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
104             $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
105     $(COMPONENT_POST_INSTALL_ACTION)
106     $(TOUCH) $@
107
40031f 108 # Define Perl version specific filenames for tests.
f82b69 109 ifeq ($(strip $(USE_COMMON_TEST_MASTER)),no)
4d6c70 110 COMPONENT_TEST_MASTER = $(COMPONENT_TEST_RESULTS_DIR)/results-$(PERL_VERSION).master
f82b69 111 endif
5d7921 112 COMPONENT_TEST_BUILD_DIR = $(BUILD_DIR)/test-$(PERL_VERSION)
4d6c70 113 COMPONENT_TEST_OUTPUT = $(COMPONENT_TEST_BUILD_DIR)/test-$(PERL_VERSION)-results
MT 114 COMPONENT_TEST_DIFFS =  $(COMPONENT_TEST_BUILD_DIR)/test-$(PERL_VERSION)-diffs
115 COMPONENT_TEST_SNAPSHOT = $(COMPONENT_TEST_BUILD_DIR)/results-$(PERL_VERSION).snapshot
116 COMPONENT_TEST_TRANSFORM_CMD = $(COMPONENT_TEST_BUILD_DIR)/transform-$(PERL_VERSION)-results
a4588e 117
MT 118 # Normalize perl test results.
96719f 119 COMPONENT_TEST_TRANSFORMS += '-e "0,/test_harness/d"'        # delete any lines up through test_harness
a4588e 120 COMPONENT_TEST_TRANSFORMS += '-e "s/,  *[0-9]* wallclock.*//"'    # delete timings
MT 121 COMPONENT_TEST_TRANSFORMS += '-e "/^\#/d"'            # delete comments
122 COMPONENT_TEST_TRANSFORMS += '-e "/^make\[/d"'            # delete make logs
6bc9bf 123
96719f 124 # Add the expected 'test_harness' line if it is missing in the test results.
89aae0 125 COMPONENT_POST_TEST_ACTION += \
e51347 126     $(GNU_GREP) -q test_harness $(COMPONENT_TEST_OUTPUT) \
96719f 127     || $(GSED) -i -e '1i\test_harness' $(COMPONENT_TEST_OUTPUT) ;
MT 128
5a9d2b 129 COMPONENT_TEST_TARGETS =    test
6bc9bf 130 COMPONENT_TEST_ENV +=    $(COMMON_PERL_ENV)
8d70f8 131
RB 132 # determine the type of tests we want to run.
133 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),)
6b1597 134 TEST_32 =    $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested)
TM 135 TEST_64 =    $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested)
136 TEST_NO_ARCH =    $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
8d70f8 137 else
6b1597 138 TEST_32 =    $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared)
TM 139 TEST_64 =    $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared)
140 TEST_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested-and-compared)
7999b2 141 endif
8d70f8 142
RB 143 # test the built source
144 $(BUILD_DIR)/%/.tested-and-compared:    $(BUILD_DIR)/%/.built
237543 145     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
AP 146     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
8d70f8 147     $(COMPONENT_PRE_TEST_ACTION)
RB 148     -(cd $(COMPONENT_TEST_DIR) ; \
149         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
150         $(COMPONENT_TEST_CMD) \
151         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
152         &> $(COMPONENT_TEST_OUTPUT)
153     $(COMPONENT_POST_TEST_ACTION)
154     $(COMPONENT_TEST_CREATE_TRANSFORMS)
155     $(COMPONENT_TEST_PERFORM_TRANSFORM)
156     $(COMPONENT_TEST_COMPARE)
157     $(COMPONENT_TEST_CLEANUP)
6bc9bf 158     $(TOUCH) $@
CM 159
89aae0 160 $(BUILD_DIR)/%/.tested:    SHELLOPTS=pipefail
8d70f8 161 $(BUILD_DIR)/%/.tested:    $(BUILD_DIR)/%/.built
89aae0 162     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
MT 163     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
8d70f8 164     $(COMPONENT_PRE_TEST_ACTION)
RB 165     (cd $(COMPONENT_TEST_DIR) ; \
166         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
167         $(COMPONENT_TEST_CMD) \
89aae0 168         $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
MT 169         |& $(TEE) $(COMPONENT_TEST_OUTPUT)
8d70f8 170     $(COMPONENT_POST_TEST_ACTION)
89aae0 171     $(COMPONENT_TEST_CREATE_TRANSFORMS)
MT 172     $(COMPONENT_TEST_PERFORM_TRANSFORM)
8d70f8 173     $(COMPONENT_TEST_CLEANUP)
RB 174     $(TOUCH) $@
175
32921b 176
372e47 177 # We need to add -$(PLV) to package fmri and add runtime dependencies from metadata to generated manifest
MT 178 GENERATE_EXTRA_DEPS += $(BUILD_DIR)/META.depend-runtime.res
9c1e84 179 GENERATE_EXTRA_CMD += | \
32921b 180     $(GSED) -e 's/^\(set name=pkg.fmri [^@]*\)\(.*\)$$/\1-$$(PLV)\2/' | \
d8670c 181     $(CAT) - <( \
MT 182         echo "" ; \
183         echo "\# perl modules are unusable without perl runtime binary" ; \
184         echo "depend type=require fmri=__TBD pkg.debug.depend.file=perl \\" ; \
185         echo "    pkg.debug.depend.path=usr/perl5/\$$(PERLVER)/bin" ; \
372e47 186         echo "" ; \
MT 187         echo "\# Automatically generated dependencies based on distribution metadata" ; \
188         $(CAT) $(BUILD_DIR)/META.depend-runtime.res | $(PKGFMT) \
d8670c 189     )
32921b 190
372e47 191 # Add build dependencies from metadata to REQUIRED_PACKAGES.
0d899f 192 REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend-build.res
f045de 193
0d899f 194 # Generate list of TEST_REQUIRED_PACKAGES entries
372e47 195 REQUIRED_PACKAGES_EXTRA_DEPS += $(BUILD_DIR)/META.depend-test.required
MT 196 $(BUILD_DIR)/META.depend-test.required: $(BUILD_DIR)/META.depend-test.res
197     $(GSED) -e 's|^depend.*pkg:/\(library/perl-5/.*\)-\$$(PLV).*$$|TEST_REQUIRED_PACKAGES.perl += \1|' < $< > $@
0d899f 198
MT 199 # Add META.depend-test.required to the generated list of REQUIRED_PACKAGES
200 REQUIRED_PACKAGES_TRANSFORM += -e '$$r $(BUILD_DIR)/META.depend-test.required'
201
32921b 202
372e47 203 # The configure target should create the MYMETA.json file.  If it does not we
MT 204 # need a fallback to use either META.json or META.yml.  We probably (and
205 # hopefully) currently have no component requiring such fallback.
206 $(BUILD_DIR)/%/MYMETA.json:    $(BUILD_DIR)/%/.configured
207     if [ ! -f $@ ] ; then \
208         if [ -e $(@D)/META.json ] ; then \
209             $(CAT) $(@D)/META.json ; \
210         elif [ -e $(@D)/META.yml ] ; then \
211             $(CAT) $(@D)/META.yml \
212                 | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
213                 | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
214         fi > $@ ; \
4d1e46 215     fi ; \
MT 216     $(TOUCH) $@
372e47 217
MT 218 $(BUILD_DIR)/%/.depend-build:    $(BUILD_DIR)/%/MYMETA.json
4d1e46 219     $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure build $(PERL_VERSION) < $< > $@
MT 220     # Get configure requirements from META.json/META.yml too
221     if [ -e $(@D)/META.json ] ; then \
222         $(CAT) $(@D)/META.json ; \
223     elif [ -e $(@D)/META.yml ] ; then \
224         $(CAT) $(@D)/META.yml \
225             | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
226             | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
227     fi | $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure $(PERL_VERSION) >> $@ ; \
228     $(TOUCH) $@
372e47 229 $(BUILD_DIR)/%/.depend-runtime:    $(BUILD_DIR)/%/MYMETA.json
MT 230     $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) runtime $(PERL_VERSION) < $< > $@
231 $(BUILD_DIR)/%/.depend-test:    $(BUILD_DIR)/%/MYMETA.json
232     $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) test $(PERL_VERSION) < $< > $@
8f1b0e 233     $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) test runtime suggests $(PERL_VERSION) < $< >> $@
372e47 234
MT 235 $(BUILD_DIR)/META.depend-build.res:    $(BUILD_$(MK_BITS):%.built=%.depend-build)
236     $(CAT) $^ | $(SORT) -u > $@
237 $(BUILD_DIR)/META.depend-runtime.res:    $(BUILD_$(MK_BITS):%.built=%.depend-runtime)
238     $(CAT) $^ | $(SORT) -u > $@
239 $(BUILD_DIR)/META.depend-test.res:    $(BUILD_$(MK_BITS):%.built=%.depend-test)
240     $(CAT) $^ | $(SORT) -u > $@
241
4d1e46 242 # jq is needed for perl-meta-deps and to convert META.yml to JSON format
32921b 243 USERLAND_REQUIRED_PACKAGES += text/jq
372e47 244 # pyyaml is needed to convert META.yml to MYMETA.json
f045de 245 USERLAND_REQUIRED_PACKAGES += library/python/pyyaml
32921b 246
MT 247
6bc9bf 248 clean:: 
CM 249     $(RM) -r $(BUILD_DIR) $(PROTO_DIR)