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]
21 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
24 # Common perl environment
25 COMMON_PERL_ENV
+= MAKE
=$(GMAKE
)
26 COMMON_PERL_ENV
+= PATH
=$(dir $(CC
)):$(PATH
)
27 COMMON_PERL_ENV
+= LANG
=""
28 COMMON_PERL_ENV
+= CC
="$(CC)"
29 COMMON_PERL_ENV
+= CFLAGS
="$(CC_BITS) $(PERL_OPTIMIZE)"
31 # Particular perl runtime is always required (at least to run Makefile.PL)
32 PERL_REQUIRED_PACKAGES
+= runtime
/perl
34 # Yes. Perl is just scripts, for now, but we need architecture
35 # directories so that it populates all architecture prototype
38 define perl-version-rule
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)
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)
49 $(foreach perlver
,$(PERL_VERSIONS
),$(eval
$(call perl-version-rule
,$(perlver
))))
51 $(BUILD_DIR
)/$(MACH32
)-%/.configured
: BITS
=32
52 $(BUILD_DIR
)/$(MACH64
)-%/.configured
: BITS
=64
54 $(BUILD_DIR
)/$(MACH32
)-%/.built
: BITS
=32
55 $(BUILD_DIR
)/$(MACH64
)-%/.built
: BITS
=64
57 $(BUILD_DIR
)/$(MACH32
)-%/.installed
: BITS
=32
58 $(BUILD_DIR
)/$(MACH64
)-%/.installed
: BITS
=64
60 $(BUILD_DIR
)/$(MACH32
)-%/.tested
: BITS
=32
61 $(BUILD_DIR
)/$(MACH64
)-%/.tested
: BITS
=64
63 $(BUILD_DIR
)/$(MACH32
)-%/.tested-and-compared
: BITS
=32
64 $(BUILD_DIR
)/$(MACH64
)-%/.tested-and-compared
: BITS
=64
66 PERL_32_ONLY_VERSIONS
= $(filter-out $(PERL_64_ONLY_VERSIONS
), $(PERL_VERSIONS
))
68 BUILD_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.built
)
69 BUILD_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.built
)
70 BUILD_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.built
)
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
)
76 COMPONENT_CONFIGURE_ENV
+= $(COMMON_PERL_ENV
)
77 # Avoid interactive behaviour for Module::AutoInstall
78 COMPONENT_CONFIGURE_ENV
+= PERL_AUTOINSTALL
=--skipdeps
79 COMPONENT_CONFIGURE_ENV
+= PERL
="$(PERL)"
80 $(BUILD_DIR
)/%/.configured
: $(SOURCE_DIR
)/.prep
81 ($(RM
) -r
$(@D
) ; $(MKDIR
) $(@D
))
82 $(ENV
) $(CLONEY_ARGS
) $(CLONEY
) $(SOURCE_DIR
) $(@D
)
83 $(COMPONENT_PRE_CONFIGURE_ACTION
)
84 (cd
$(@D
) ; $(COMPONENT_CONFIGURE_ENV
) $(PERL
) $(PERL_FLAGS
) \
85 Makefile.PL
$(CONFIGURE_OPTIONS
))
86 $(COMPONENT_POST_CONFIGURE_ACTION
)
90 COMPONENT_BUILD_ENV
+= $(COMMON_PERL_ENV
)
91 $(BUILD_DIR
)/%/.built
: $(BUILD_DIR
)/%/.configured
92 $(COMPONENT_PRE_BUILD_ACTION
)
93 (cd
$(@D
) ; $(ENV
) $(COMPONENT_BUILD_ENV
) \
94 $(GMAKE
) $(COMPONENT_BUILD_GMAKE_ARGS
) $(COMPONENT_BUILD_ARGS
) \
95 $(COMPONENT_BUILD_TARGETS
))
96 $(COMPONENT_POST_BUILD_ACTION
)
100 COMPONENT_INSTALL_ARGS
+= DESTDIR
="$(PROTO_DIR)"
101 COMPONENT_INSTALL_TARGETS
= install_vendor
102 COMPONENT_INSTALL_ENV
+= $(COMMON_PERL_ENV
)
103 $(BUILD_DIR
)/%/.installed
: $(BUILD_DIR
)/%/.built
104 $(COMPONENT_PRE_INSTALL_ACTION
)
105 (cd
$(@D
) ; $(ENV
) $(COMPONENT_INSTALL_ENV
) $(GMAKE
) \
106 $(COMPONENT_INSTALL_ARGS
) $(COMPONENT_INSTALL_TARGETS
))
107 $(COMPONENT_POST_INSTALL_ACTION
)
110 # Define Perl version specific filenames for tests.
111 ifeq ($(strip $(USE_COMMON_TEST_MASTER
)),no
)
112 COMPONENT_TEST_MASTER
= $(COMPONENT_TEST_RESULTS_DIR
)/results-
$(PERL_VERSION
).master
114 COMPONENT_TEST_BUILD_DIR
= $(BUILD_DIR
)/test-
$(PERL_VERSION
)
115 COMPONENT_TEST_OUTPUT
= $(COMPONENT_TEST_BUILD_DIR
)/test-
$(PERL_VERSION
)-results
116 COMPONENT_TEST_DIFFS
= $(COMPONENT_TEST_BUILD_DIR
)/test-
$(PERL_VERSION
)-diffs
117 COMPONENT_TEST_SNAPSHOT
= $(COMPONENT_TEST_BUILD_DIR
)/results-
$(PERL_VERSION
).snapshot
118 COMPONENT_TEST_TRANSFORM_CMD
= $(COMPONENT_TEST_BUILD_DIR
)/transform-
$(PERL_VERSION
)-results
120 # Normalize perl test results.
121 COMPONENT_TEST_TRANSFORMS
+= '-e "0,/test_harness/d"' # delete any lines up through test_harness
122 COMPONENT_TEST_TRANSFORMS
+= '-e "s/, *[0-9]* wallclock.*//"' # delete timings
123 COMPONENT_TEST_TRANSFORMS
+= '-e "/^\#/d"' # delete comments
124 COMPONENT_TEST_TRANSFORMS
+= '-e "/^make\[/d"' # delete make logs
126 # Add the expected 'test_harness' line if it is missing in the test results.
127 COMPONENT_POST_TEST_ACTION
+= \
128 $(GNU_GREP
) -q test_harness
$(COMPONENT_TEST_OUTPUT
) \
129 ||
$(GSED
) -i
-e
'1i\test_harness' $(COMPONENT_TEST_OUTPUT
) ;
131 COMPONENT_TEST_TARGETS
= test
132 COMPONENT_TEST_ENV
+= $(COMMON_PERL_ENV
)
134 # determine the type of tests we want to run.
135 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR
)/results-
*.master
)),)
136 TEST_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.tested
)
137 TEST_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.tested
)
138 TEST_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.tested
)
140 TEST_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.tested-and-compared
)
141 TEST_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.tested-and-compared
)
142 TEST_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.tested-and-compared
)
145 # test the built source
146 $(BUILD_DIR
)/%/.tested-and-compared
: $(COMPONENT_TEST_DEP
)
147 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
148 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
149 $(COMPONENT_PRE_TEST_ACTION
)
150 -(cd
$(COMPONENT_TEST_DIR
) ; \
151 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
152 $(COMPONENT_TEST_CMD
) \
153 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
154 &> $(COMPONENT_TEST_OUTPUT
)
155 $(COMPONENT_POST_TEST_ACTION
)
156 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
157 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
158 $(COMPONENT_TEST_COMPARE
)
159 $(COMPONENT_TEST_CLEANUP
)
162 $(BUILD_DIR
)/%/.tested
: SHELLOPTS
=pipefail
163 $(BUILD_DIR
)/%/.tested
: $(COMPONENT_TEST_DEP
)
164 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
165 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
166 $(COMPONENT_PRE_TEST_ACTION
)
167 (cd
$(COMPONENT_TEST_DIR
) ; \
168 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
169 $(COMPONENT_TEST_CMD
) \
170 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
171 |
& $(TEE
) $(COMPONENT_TEST_OUTPUT
)
172 $(COMPONENT_POST_TEST_ACTION
)
173 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
174 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
175 $(COMPONENT_TEST_CLEANUP
)
179 # We need to add -$(PLV) to package fmri and add runtime dependencies from metadata to generated manifest
180 GENERATE_EXTRA_DEPS
+= $(BUILD_DIR
)/META.depend-runtime.res
181 GENERATE_EXTRA_CMD
+= | \
182 $(GSED
) -e
's/^\(set name=pkg.fmri [^@]*\)\(.*\)$$/\1-$$(PLV)\2/' | \
185 echo
"\# perl modules are unusable without perl runtime binary" ; \
186 echo
"depend type=require fmri=__TBD pkg.debug.depend.file=perl \\" ; \
187 echo
" pkg.debug.depend.path=usr/perl5/\$$(PERLVER)/bin" ; \
189 echo
"\# Automatically generated dependencies based on distribution metadata" ; \
190 $(CAT
) $(BUILD_DIR
)/META.depend-runtime.res
$(MANGLE_DEPEND_RUNTIME
) |
$(PKGFMT
) \
193 # Add build dependencies from metadata to REQUIRED_PACKAGES.
194 REQUIRED_PACKAGES_RESOLVED
+= $(BUILD_DIR
)/META.depend-build.res
196 # Generate list of TEST_REQUIRED_PACKAGES entries
197 REQUIRED_PACKAGES_EXTRA_DEPS
+= $(BUILD_DIR
)/META.depend-test.required
198 $(BUILD_DIR
)/META.depend-test.required
: $(BUILD_DIR
)/META.depend-test.res
199 $(GSED
) -e
's|^depend.*pkg:/\(library/perl-5/.*\)-\$$(PLV).*$$|TEST_REQUIRED_PACKAGES.perl += \1|' \
200 -e
'/^TEST_REQUIRED_PACKAGES\.perl/!s/.*/\# TODO: &/' < $< > $@
202 # Add META.depend-test.required to the generated list of REQUIRED_PACKAGES
203 REQUIRED_PACKAGES_TRANSFORM
+= -e
'$$r $(BUILD_DIR)/META.depend-test.required'
206 # The configure target should create the MYMETA.json file. If it does not we
207 # need a fallback to use either META.json or META.yml. We probably (and
208 # hopefully) currently have no component requiring such fallback.
209 $(BUILD_DIR
)/%/MYMETA.json
: $(BUILD_DIR
)/%/.configured
210 if
[ ! -f
$@
] ; then \
211 if
[ -e
$(@D
)/META.json
] ; then \
212 $(CAT
) $(@D
)/META.json
; \
213 elif
[ -e
$(@D
)/META.yml
] ; then \
214 $(CAT
) $(@D
)/META.yml \
215 |
$(PYTHON
) -c
'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
216 |
$(JQ
) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
221 $(BUILD_DIR
)/%/.depend-build
: $(BUILD_DIR
)/%/MYMETA.json
222 $(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) configure build
$(PERL_VERSION
) < $< > $@
223 # Get configure requirements from META.json/META.yml too
224 if
[ -e
$(@D
)/META.json
] ; then \
225 $(CAT
) $(@D
)/META.json
; \
226 elif
[ -e
$(@D
)/META.yml
] ; then \
227 $(CAT
) $(@D
)/META.yml \
228 |
$(PYTHON
) -c
'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
229 |
$(JQ
) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
230 fi |
$(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) configure
$(PERL_VERSION
) >> $@
; \
232 $(BUILD_DIR
)/%/.depend-runtime
: $(BUILD_DIR
)/%/MYMETA.json
233 $(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) runtime
$(PERL_VERSION
) < $< > $@
234 $(BUILD_DIR
)/%/.depend-test
: $(BUILD_DIR
)/%/MYMETA.json
235 $(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) test $(PERL_VERSION
) < $< > $@
236 $(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) test runtime suggests
$(PERL_VERSION
) < $< >> $@
238 $(BUILD_DIR
)/META.depend-build.res
: $(BUILD_
$(MK_BITS
):%.built
=%.depend-build
)
239 $(CAT
) $^ |
$(SORT
) -u
> $@
240 $(BUILD_DIR
)/META.depend-runtime.res
: $(BUILD_
$(MK_BITS
):%.built
=%.depend-runtime
)
241 $(CAT
) $^ |
$(SORT
) -u
> $@
242 $(BUILD_DIR
)/META.depend-test.res
: $(BUILD_
$(MK_BITS
):%.built
=%.depend-test
)
243 $(CAT
) $^ |
$(SORT
) -u
> $@
245 # jq is needed for perl-meta-deps and to convert META.yml to JSON format
246 USERLAND_REQUIRED_PACKAGES
+= text
/jq
247 # pyyaml is needed to convert META.yml to MYMETA.json
248 USERLAND_REQUIRED_PACKAGES
+= library
/python
/pyyaml
252 $(RM
) -r
$(BUILD_DIR
) $(PROTO_DIR
)