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 $(foreach perlver
,$(PERL_VERSIONS
),$(eval
$(call perl-version-rule
,$(perlver
))))
47 $(BUILD_DIR
)/$(MACH32
)-%/.configured
: BITS
=32
48 $(BUILD_DIR
)/$(MACH64
)-%/.configured
: BITS
=64
50 $(BUILD_DIR
)/$(MACH32
)-%/.built
: BITS
=32
51 $(BUILD_DIR
)/$(MACH64
)-%/.built
: BITS
=64
53 $(BUILD_DIR
)/$(MACH32
)-%/.installed
: BITS
=32
54 $(BUILD_DIR
)/$(MACH64
)-%/.installed
: BITS
=64
56 $(BUILD_DIR
)/$(MACH32
)-%/.tested
: BITS
=32
57 $(BUILD_DIR
)/$(MACH64
)-%/.tested
: BITS
=64
59 $(BUILD_DIR
)/$(MACH32
)-%/.tested-and-compared
: BITS
=32
60 $(BUILD_DIR
)/$(MACH64
)-%/.tested-and-compared
: BITS
=64
62 PERL_32_ONLY_VERSIONS
= $(filter-out $(PERL_64_ONLY_VERSIONS
), $(PERL_VERSIONS
))
64 BUILD_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.built
)
65 BUILD_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.built
)
66 BUILD_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.built
)
68 INSTALL_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.installed
)
69 INSTALL_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.installed
)
70 INSTALL_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.installed
)
72 COMPONENT_CONFIGURE_ENV
+= $(COMMON_PERL_ENV
)
73 COMPONENT_CONFIGURE_ENV
+= PERL
="$(PERL)"
74 $(BUILD_DIR
)/%/.configured
: $(SOURCE_DIR
)/.prep
75 ($(RM
) -r
$(@D
) ; $(MKDIR
) $(@D
))
76 $(ENV
) $(CLONEY_ARGS
) $(CLONEY
) $(SOURCE_DIR
) $(@D
)
77 $(COMPONENT_PRE_CONFIGURE_ACTION
)
78 (cd
$(@D
) ; $(COMPONENT_CONFIGURE_ENV
) $(PERL
) $(PERL_FLAGS
) \
79 Makefile.PL
$(CONFIGURE_OPTIONS
))
80 $(COMPONENT_POST_CONFIGURE_ACTION
)
84 COMPONENT_BUILD_ENV
+= $(COMMON_PERL_ENV
)
85 $(BUILD_DIR
)/%/.built
: $(BUILD_DIR
)/%/.configured
86 $(COMPONENT_PRE_BUILD_ACTION
)
87 (cd
$(@D
) ; $(ENV
) $(COMPONENT_BUILD_ENV
) \
88 $(GMAKE
) $(COMPONENT_BUILD_GMAKE_ARGS
) $(COMPONENT_BUILD_ARGS
) \
89 $(COMPONENT_BUILD_TARGETS
))
90 $(COMPONENT_POST_BUILD_ACTION
)
94 COMPONENT_INSTALL_ARGS
+= DESTDIR
="$(PROTO_DIR)"
95 COMPONENT_INSTALL_TARGETS
= install_vendor
96 COMPONENT_INSTALL_ENV
+= $(COMMON_PERL_ENV
)
97 $(BUILD_DIR
)/%/.installed
: $(BUILD_DIR
)/%/.built
98 $(COMPONENT_PRE_INSTALL_ACTION
)
99 (cd
$(@D
) ; $(ENV
) $(COMPONENT_INSTALL_ENV
) $(GMAKE
) \
100 $(COMPONENT_INSTALL_ARGS
) $(COMPONENT_INSTALL_TARGETS
))
101 $(COMPONENT_POST_INSTALL_ACTION
)
104 # Define Perl version specific filenames for tests.
105 ifeq ($(strip $(USE_COMMON_TEST_MASTER
)),no
)
106 COMPONENT_TEST_MASTER
= $(COMPONENT_TEST_RESULTS_DIR
)/results-
$(PERL_VERSION
).master
108 COMPONENT_TEST_BUILD_DIR
= $(BUILD_DIR
)/test-
$(PERL_VERSION
)
109 COMPONENT_TEST_OUTPUT
= $(COMPONENT_TEST_BUILD_DIR
)/test-
$(PERL_VERSION
)-results
110 COMPONENT_TEST_DIFFS
= $(COMPONENT_TEST_BUILD_DIR
)/test-
$(PERL_VERSION
)-diffs
111 COMPONENT_TEST_SNAPSHOT
= $(COMPONENT_TEST_BUILD_DIR
)/results-
$(PERL_VERSION
).snapshot
112 COMPONENT_TEST_TRANSFORM_CMD
= $(COMPONENT_TEST_BUILD_DIR
)/transform-
$(PERL_VERSION
)-results
114 # Normalize perl test results.
115 COMPONENT_TEST_TRANSFORMS
+= '-e "0,/test_harness/d"' # delete any lines up through test_harness
116 COMPONENT_TEST_TRANSFORMS
+= '-e "s/, *[0-9]* wallclock.*//"' # delete timings
117 COMPONENT_TEST_TRANSFORMS
+= '-e "/^\#/d"' # delete comments
118 COMPONENT_TEST_TRANSFORMS
+= '-e "/^make\[/d"' # delete make logs
120 # Add the expected 'test_harness' line if it is missing in the test results.
121 COMPONENT_POST_TEST_ACTION
+= \
122 $(GNU_GREP
) -q test_harness
$(COMPONENT_TEST_OUTPUT
) \
123 ||
$(GSED
) -i
-e
'1i\test_harness' $(COMPONENT_TEST_OUTPUT
) ;
125 COMPONENT_TEST_TARGETS
= test
126 COMPONENT_TEST_ENV
+= $(COMMON_PERL_ENV
)
128 # determine the type of tests we want to run.
129 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR
)/results-
*.master
)),)
130 TEST_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.tested
)
131 TEST_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.tested
)
132 TEST_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.tested
)
134 TEST_32
= $(PERL_32_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH32
)-%/.tested-and-compared
)
135 TEST_64
= $(PERL_64_ONLY_VERSIONS
:%=$(BUILD_DIR
)/$(MACH64
)-%/.tested-and-compared
)
136 TEST_NO_ARCH
= $(PERL_VERSIONS
:%=$(BUILD_DIR
)/$(MACH
)-%/.tested-and-compared
)
139 # test the built source
140 $(BUILD_DIR
)/%/.tested-and-compared
: $(BUILD_DIR
)/%/.built
141 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
142 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
143 $(COMPONENT_PRE_TEST_ACTION
)
144 -(cd
$(COMPONENT_TEST_DIR
) ; \
145 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
146 $(COMPONENT_TEST_CMD
) \
147 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
148 &> $(COMPONENT_TEST_OUTPUT
)
149 $(COMPONENT_POST_TEST_ACTION
)
150 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
151 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
152 $(COMPONENT_TEST_COMPARE
)
153 $(COMPONENT_TEST_CLEANUP
)
156 $(BUILD_DIR
)/%/.tested
: SHELLOPTS
=pipefail
157 $(BUILD_DIR
)/%/.tested
: $(BUILD_DIR
)/%/.built
158 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
159 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
160 $(COMPONENT_PRE_TEST_ACTION
)
161 (cd
$(COMPONENT_TEST_DIR
) ; \
162 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
163 $(COMPONENT_TEST_CMD
) \
164 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
165 |
& $(TEE
) $(COMPONENT_TEST_OUTPUT
)
166 $(COMPONENT_POST_TEST_ACTION
)
167 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
168 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
169 $(COMPONENT_TEST_CLEANUP
)
173 # We need to add -$(PLV) to package fmri and generate runtime dependencies based on META.json
174 GENERATE_EXTRA_DEPS
+= $(BUILD_DIR
)/META.json
175 GENERATE_EXTRA_CMD
+= | \
176 $(GSED
) -e
's/^\(set name=pkg.fmri [^@]*\)\(.*\)$$/\1-$$(PLV)\2/' | \
179 echo
"\# perl modules are unusable without perl runtime binary" ; \
180 echo
"depend type=require fmri=__TBD pkg.debug.depend.file=perl \\" ; \
181 echo
" pkg.debug.depend.path=usr/perl5/\$$(PERLVER)/bin" ; \
182 $(CAT
) $(BUILD_DIR
)/META.json \
183 |
$(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) runtime
$(PERL_VERSION
) \
184 |
$(GSED
) -e
's|^\(depend.*pkg:/runtime/perl-\$$(PLV).*\)$$|\#\1|g' \
187 # Add build dependencies from META.json to REQUIRED_PACKAGES. The dependency
188 # on META.depend-test.required here is purely to get the file created as a side
189 # effect of this target.
190 REQUIRED_PACKAGES_RESOLVED
+= $(BUILD_DIR
)/META.depend-build.res
191 $(BUILD_DIR
)/META.depend-build.res
: $(BUILD_DIR
)/META.json
$(BUILD_DIR
)/META.depend-test.required
192 $(CAT
) $(BUILD_DIR
)/META.json |
$(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) build
$(PERL_VERSION
) > $@
194 # Generate list of TEST_REQUIRED_PACKAGES entries
195 $(BUILD_DIR
)/META.depend-test.required
: $(BUILD_DIR
)/META.json
196 $(CAT
) $(BUILD_DIR
)/META.json \
197 |
$(WS_TOOLS
)/perl-meta-deps
$(WS_MACH
) $(BUILD_DIR
) test $(PERL_VERSION
) \
198 |
$(GNU_GREP
) '^depend.*pkg:/library/perl-5/.*\$$(PLV)' \
199 |
$(GSED
) -e
's|^depend.*pkg:/\(library/perl-5/.*\)-\$$(PLV).*$$|TEST_REQUIRED_PACKAGES.perl += \1|' > $@
201 # Add META.depend-test.required to the generated list of REQUIRED_PACKAGES
202 REQUIRED_PACKAGES_TRANSFORM
+= -e
'$$r $(BUILD_DIR)/META.depend-test.required'
205 $(BUILD_DIR
)/META.json
: $(SOURCE_DIR
)/.prep
206 $(MKDIR
) $(BUILD_DIR
)
207 if
[ -f
$(SOURCE_DIR
)/META.json
] ; then \
208 $(CAT
) $(SOURCE_DIR
)/META.json
; \
209 elif
[ -f
$(SOURCE_DIR
)/META.yml
] ; then \
210 $(CAT
) $(SOURCE_DIR
)/META.yml \
211 | python
-c
'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
212 | jq
'{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
215 # perl-meta-deps requires jq
216 USERLAND_REQUIRED_PACKAGES
+= text
/jq
217 # pyyaml is needed to convert META.yml to META.json
218 USERLAND_REQUIRED_PACKAGES
+= library
/python
/pyyaml
222 $(RM
) -r
$(BUILD_DIR
) $(PROTO_DIR
)