unixodbc: Fix dependency to library/readline-8 library/readline-8/32
[oi-userland.git] / make-rules / makemaker.mk
blobe93a2f4af334587c3b84a15dda89f9caf63074f1
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
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)"
30 COMMON_PERL_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
32 # Particular perl runtime is always required (at least to run Makefile.PL)
33 PERL_REQUIRED_PACKAGES += runtime/perl
35 # Yes. Perl is just scripts, for now, but we need architecture
36 # directories so that it populates all architecture prototype
37 # directories.
39 define perl-version-rule
40 $(BUILD_DIR)/%-$(1)/.configured: PERL_VERSION=$(1)
41 $(BUILD_DIR)/%-$(1)/.built: PERL_VERSION=$(1)
42 $(BUILD_DIR)/%-$(1)/.installed: PERL_VERSION=$(1)
43 $(BUILD_DIR)/%-$(1)/.tested: PERL_VERSION=$(1)
44 $(BUILD_DIR)/%-$(1)/.tested-and-compared: PERL_VERSION=$(1)
46 $(BUILD_DIR)/%-$(1)/.depend-build: PERL_VERSION=$(1)
47 $(BUILD_DIR)/%-$(1)/.depend-runtime: PERL_VERSION=$(1)
48 $(BUILD_DIR)/%-$(1)/.depend-test: PERL_VERSION=$(1)
49 endef
50 $(foreach perlver,$(PERL_VERSIONS),$(eval $(call perl-version-rule,$(perlver))))
52 $(BUILD_DIR)/$(MACH32)-%/.configured: BITS=32
53 $(BUILD_DIR)/$(MACH64)-%/.configured: BITS=64
55 $(BUILD_DIR)/$(MACH32)-%/.built: BITS=32
56 $(BUILD_DIR)/$(MACH64)-%/.built: BITS=64
58 $(BUILD_DIR)/$(MACH32)-%/.installed: BITS=32
59 $(BUILD_DIR)/$(MACH64)-%/.installed: BITS=64
61 $(BUILD_DIR)/$(MACH32)-%/.tested: BITS=32
62 $(BUILD_DIR)/$(MACH64)-%/.tested: BITS=64
64 $(BUILD_DIR)/$(MACH32)-%/.tested-and-compared: BITS=32
65 $(BUILD_DIR)/$(MACH64)-%/.tested-and-compared: BITS=64
67 PERL_32_ONLY_VERSIONS = $(filter-out $(PERL_64_ONLY_VERSIONS), $(PERL_VERSIONS))
69 BUILD_32 = $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
70 BUILD_64 = $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
71 BUILD_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
73 INSTALL_32 = $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
74 INSTALL_64 = $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
75 INSTALL_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
77 COMPONENT_CONFIGURE_ENV += $(COMMON_PERL_ENV)
78 # Avoid interactive behaviour for Module::AutoInstall
79 COMPONENT_CONFIGURE_ENV += PERL_AUTOINSTALL=--skipdeps
80 COMPONENT_CONFIGURE_ENV += PERL="$(PERL)"
81 $(BUILD_DIR)/%/.configured: $(SOURCE_DIR)/.prep
82 ($(RM) -r $(@D) ; $(MKDIR) $(@D))
83 $(ENV) $(CLONEY_ARGS) $(CLONEY) $(SOURCE_DIR) $(@D)
84 $(COMPONENT_PRE_CONFIGURE_ACTION)
85 (cd $(@D) ; $(COMPONENT_CONFIGURE_ENV) $(PERL) $(PERL_FLAGS) \
86 Makefile.PL $(CONFIGURE_OPTIONS))
87 $(COMPONENT_POST_CONFIGURE_ACTION)
88 $(TOUCH) $@
91 COMPONENT_BUILD_ENV += $(COMMON_PERL_ENV)
92 $(BUILD_DIR)/%/.built: $(BUILD_DIR)/%/.configured
93 $(COMPONENT_PRE_BUILD_ACTION)
94 (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \
95 $(GMAKE) $(COMPONENT_BUILD_GMAKE_ARGS) $(COMPONENT_BUILD_ARGS) \
96 $(COMPONENT_BUILD_TARGETS))
97 $(COMPONENT_POST_BUILD_ACTION)
98 $(TOUCH) $@
101 COMPONENT_INSTALL_ARGS += DESTDIR="$(PROTO_DIR)"
102 COMPONENT_INSTALL_TARGETS = install_vendor
103 COMPONENT_INSTALL_ENV += $(COMMON_PERL_ENV)
104 $(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built
105 $(COMPONENT_PRE_INSTALL_ACTION)
106 (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \
107 $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS))
108 $(COMPONENT_POST_INSTALL_ACTION)
109 $(TOUCH) $@
111 # Define Perl version specific filenames for tests.
112 ifeq ($(strip $(USE_COMMON_TEST_MASTER)),no)
113 COMPONENT_TEST_MASTER = $(COMPONENT_TEST_RESULTS_DIR)/results-$(PERL_VERSION).master
114 endif
115 COMPONENT_TEST_BUILD_DIR = $(BUILD_DIR)/test-$(PERL_VERSION)
116 COMPONENT_TEST_OUTPUT = $(COMPONENT_TEST_BUILD_DIR)/test-$(PERL_VERSION)-results
117 COMPONENT_TEST_DIFFS = $(COMPONENT_TEST_BUILD_DIR)/test-$(PERL_VERSION)-diffs
118 COMPONENT_TEST_SNAPSHOT = $(COMPONENT_TEST_BUILD_DIR)/results-$(PERL_VERSION).snapshot
119 COMPONENT_TEST_TRANSFORM_CMD = $(COMPONENT_TEST_BUILD_DIR)/transform-$(PERL_VERSION)-results
121 # Normalize perl test results.
122 COMPONENT_TEST_TRANSFORMS += '-e "0,/test_harness/d"' # delete any lines up through test_harness
123 COMPONENT_TEST_TRANSFORMS += '-e "s/, *[0-9]* wallclock.*//"' # delete timings
124 COMPONENT_TEST_TRANSFORMS += '-e "/^\#/d"' # delete comments
125 COMPONENT_TEST_TRANSFORMS += '-e "/^make\[/d"' # delete make logs
127 # Add the expected 'test_harness' line if it is missing in the test results.
128 COMPONENT_POST_TEST_ACTION += \
129 $(GNU_GREP) -q test_harness $(COMPONENT_TEST_OUTPUT) \
130 || $(GSED) -i -e '1i\test_harness' $(COMPONENT_TEST_OUTPUT) ;
132 COMPONENT_TEST_TARGETS = test
133 COMPONENT_TEST_ENV += $(COMMON_PERL_ENV)
135 # determine the type of tests we want to run.
136 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),)
137 TEST_32 = $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested)
138 TEST_64 = $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested)
139 TEST_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
140 else
141 TEST_32 = $(PERL_32_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared)
142 TEST_64 = $(PERL_64_ONLY_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared)
143 TEST_NO_ARCH = $(PERL_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested-and-compared)
144 endif
146 # test the built source
147 $(BUILD_DIR)/%/.tested-and-compared: $(COMPONENT_TEST_DEP)
148 $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
149 $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
150 $(COMPONENT_PRE_TEST_ACTION)
151 -(cd $(COMPONENT_TEST_DIR) ; \
152 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
153 $(COMPONENT_TEST_CMD) \
154 $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
155 &> $(COMPONENT_TEST_OUTPUT)
156 $(COMPONENT_POST_TEST_ACTION)
157 $(COMPONENT_TEST_CREATE_TRANSFORMS)
158 $(COMPONENT_TEST_PERFORM_TRANSFORM)
159 $(COMPONENT_TEST_COMPARE)
160 $(COMPONENT_TEST_CLEANUP)
161 $(TOUCH) $@
163 $(BUILD_DIR)/%/.tested: SHELLOPTS=pipefail
164 $(BUILD_DIR)/%/.tested: $(COMPONENT_TEST_DEP)
165 $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
166 $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
167 $(COMPONENT_PRE_TEST_ACTION)
168 (cd $(COMPONENT_TEST_DIR) ; \
169 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
170 $(COMPONENT_TEST_CMD) \
171 $(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
172 |& $(TEE) $(COMPONENT_TEST_OUTPUT)
173 $(COMPONENT_POST_TEST_ACTION)
174 $(COMPONENT_TEST_CREATE_TRANSFORMS)
175 $(COMPONENT_TEST_PERFORM_TRANSFORM)
176 $(COMPONENT_TEST_CLEANUP)
177 $(TOUCH) $@
180 # We need to add -$(PLV) to package fmri and add runtime dependencies from metadata to generated manifest
181 GENERATE_EXTRA_DEPS += $(BUILD_DIR)/META.depend-runtime.res
182 GENERATE_EXTRA_CMD += | \
183 $(GSED) -e 's/^\(set name=pkg.fmri [^@]*\)\(.*\)$$/\1-$$(PLV)\2/' | \
184 $(CAT) - <( \
185 echo "" ; \
186 echo "\# perl modules are unusable without perl runtime binary" ; \
187 echo "depend type=require fmri=__TBD pkg.debug.depend.file=perl \\" ; \
188 echo " pkg.debug.depend.path=usr/perl5/\$$(PERLVER)/bin" ; \
189 echo "" ; \
190 echo "\# Automatically generated dependencies based on distribution metadata" ; \
191 $(CAT) $(BUILD_DIR)/META.depend-runtime.res $(MANGLE_DEPEND_RUNTIME) | $(PKGFMT) \
194 # Add build dependencies from metadata to REQUIRED_PACKAGES.
195 REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend-build.res
197 # Generate list of TEST_REQUIRED_PACKAGES entries
198 REQUIRED_PACKAGES_EXTRA_DEPS += $(BUILD_DIR)/META.depend-test.required
199 $(BUILD_DIR)/META.depend-test.required: $(BUILD_DIR)/META.depend-test.res
200 $(GSED) -e 's|^depend.*pkg:/\(library/perl-5/.*\)-\$$(PLV).*$$|TEST_REQUIRED_PACKAGES.perl += \1|' \
201 -e '/^TEST_REQUIRED_PACKAGES\.perl/!s/.*/\# TODO: &/' < $< > $@
203 # Add META.depend-test.required to the generated list of REQUIRED_PACKAGES
204 REQUIRED_PACKAGES_TRANSFORM += -e '$$r $(BUILD_DIR)/META.depend-test.required'
207 # The configure target should create the MYMETA.json file. If it does not we
208 # need a fallback to use either META.json or META.yml. We probably (and
209 # hopefully) currently have no component requiring such fallback.
210 $(BUILD_DIR)/%/MYMETA.json: $(BUILD_DIR)/%/.configured
211 if [ ! -f $@ ] ; then \
212 if [ -e $(@D)/META.json ] ; then \
213 $(CAT) $(@D)/META.json ; \
214 elif [ -e $(@D)/META.yml ] ; then \
215 $(CAT) $(@D)/META.yml \
216 | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
217 | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
218 fi > $@ ; \
219 fi ; \
220 $(TOUCH) $@
222 $(BUILD_DIR)/%/.depend-build: $(BUILD_DIR)/%/MYMETA.json
223 $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure build $(PERL_VERSION) < $< > $@
224 # Get configure requirements from META.json/META.yml too
225 if [ -e $(@D)/META.json ] ; then \
226 $(CAT) $(@D)/META.json ; \
227 elif [ -e $(@D)/META.yml ] ; then \
228 $(CAT) $(@D)/META.yml \
229 | $(PYTHON) -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' \
230 | $(JQ) '{prereqs:{configure:{requires:.configure_requires},build:{requires:.build_requires},runtime:{requires}}}' ; \
231 fi | $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) configure $(PERL_VERSION) >> $@ ; \
232 $(TOUCH) $@
233 $(BUILD_DIR)/%/.depend-runtime: $(BUILD_DIR)/%/MYMETA.json
234 $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) runtime $(PERL_VERSION) < $< > $@
235 $(BUILD_DIR)/%/.depend-test: $(BUILD_DIR)/%/MYMETA.json
236 $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) test $(PERL_VERSION) < $< > $@
237 $(WS_TOOLS)/perl-meta-deps $(WS_MACH) $(BUILD_DIR) test runtime suggests $(PERL_VERSION) < $< >> $@
239 $(BUILD_DIR)/META.depend-build.res: $(BUILD_$(MK_BITS):%.built=%.depend-build)
240 $(CAT) $^ | $(SORT) -u > $@
241 $(BUILD_DIR)/META.depend-runtime.res: $(BUILD_$(MK_BITS):%.built=%.depend-runtime)
242 $(CAT) $^ | $(SORT) -u > $@
243 $(BUILD_DIR)/META.depend-test.res: $(BUILD_$(MK_BITS):%.built=%.depend-test)
244 $(CAT) $^ | $(SORT) -u > $@
246 # jq is needed for perl-meta-deps and to convert META.yml to JSON format
247 USERLAND_REQUIRED_PACKAGES += text/jq
248 # pyyaml is needed to convert META.yml to MYMETA.json
249 USERLAND_REQUIRED_PACKAGES += library/python/pyyaml
252 clean::
253 $(RM) -r $(BUILD_DIR) $(PROTO_DIR)