start building userland with gcc-6
[unleashed-userland.git] / make-rules / shared-macros.mk
blob03ecdf25181db04e77b98fc24df1d2da380066c3
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) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
24 PATH=/usr/bin:/usr/gnu/bin
26 # The location of an internal mirror of community source archives that we build
27 # in this gate. This mirror has been seeded to include "custom" source archives
28 # for a few components where the communities either no longer provide matching
29 # source archives or we have changes that aren't reflected in their archives or
30 # anywhere else.
31 #INTERNAL_ARCHIVE_MIRROR = http://userland.us.oracle.com/source-archives
33 # The location of an external mirror of community source archives that we build
34 # in this gate. The external mirror is a replica of the internal mirror.
35 #EXTERNAL_ARCHIVE_MIRROR = \
36 # http://static.opensolaris.org/action/browse/userland/tarball/userland
38 DLC_ARCHIVE_MIRROR = http://dlc.openindiana.org/oi-userland/source-archives
40 # Default to looking for source archives on the internal mirror and the external
41 # mirror before we hammer on the community source archive repositories.
42 #export DOWNLOAD_SEARCH_PATH += $(INTERNAL_ARCHIVE_MIRROR)
43 #export DOWNLOAD_SEARCH_PATH += $(EXTERNAL_ARCHIVE_MIRROR)
45 # Look for file at DLC server as last resort
46 export DOWNLOAD_FALLBACK_PATH = $(DLC_ARCHIVE_MIRROR)
48 # The workspace starts at the mercurial root
49 ifeq ($(origin WS_TOP), undefined)
50 export WS_TOP := \
51 $(shell hg root 2>/dev/null || git rev-parse --show-toplevel)
52 endif
54 USERLAND_ARCHIVES ?= $(WS_TOP)/archives/
55 WS_MACH = $(WS_TOP)/$(MACH)
56 WS_LOGS = $(WS_MACH)/logs
57 WS_REPO = $(WS_MACH)/repo
58 WS_TOOLS = $(WS_TOP)/tools
59 WS_MAKE_RULES = $(WS_TOP)/make-rules
60 WS_COMPONENTS = $(WS_TOP)/components
61 WS_LICENSES = $(WS_TOP)/licenses
62 WS_INCORPORATIONS = $(WS_TOP)/incorporations
63 WS_LINT_CACHE = $(WS_MACH)/pkglint-cache
65 # we want our pkg piplines to fail if there is an error
66 # (like if pkgdepend fails in the middle of a pipe), but
67 # we don't want the builds or ./configure's failing as well.
68 # so we only set pipefail for the publish target and have
69 # to reset it for the others since they might be invoked
70 # as dependencies of publish.
71 export SHELLOPTS
72 build: SHELLOPTS=
73 test: SHELLOPTS=
74 install: SHELLOPTS=
75 publish: SHELLOPTS=pipefail
77 SHELL= /bin/bash
79 # This can be overridden to avoid rebuilding when you touch a Makefile
80 MAKEFILE_PREREQ = Makefile
82 CONSOLIDATION = userland
83 PUBLISHER ?= $(CONSOLIDATION)
84 PUBLISHER_LOCALIZABLE ?= $(CONSOLIDATION)-localizable
86 # Defines $(space) as a single blank space, so we can use it to convert
87 # space-separated paths to colon-separated paths in variables with
88 # $(subst $(space),:,$(strip $(SPATHS)))
89 empty :=
90 space := $(empty) $(empty)
92 ROOT = /
94 # Native OS version
95 OS_VERSION := $(shell uname -r)
96 SOLARIS_VERSION = 2.11
97 # Target OS version
98 PKG_SOLARIS_VERSION ?= 5.11
100 include $(WS_MAKE_RULES)/ips-buildinfo.mk
102 COMPILER = gcc
103 LINKER = gcc
104 BITS = 32
105 PYTHON_VERSION = 2.7
106 PYTHON_VERSIONS = 2.7
108 BASS_O_MATIC = $(WS_TOOLS)/bass-o-matic
110 CLONEY = $(WS_TOOLS)/cloney
112 CONFIG_SHELL = /bin/sh
114 PUNAME = /usr/bin/puname
116 PKG_REPO = file:$(WS_REPO)
118 COMPONENT_SRC_NAME = $(COMPONENT_NAME)
120 COMPONENT_LICENSE_FILE ?= $(COMPONENT_NAME).license
122 COMPONENT_DIR := $(shell pwd)
123 SOURCE_DIR = $(COMPONENT_DIR)/$(COMPONENT_SRC)
124 BUILD_DIR = $(COMPONENT_DIR)/build
125 PROTO_DIR = $(BUILD_DIR)/prototype/$(MACH)
127 ARCHLIBSUBDIR32 =
128 ARCHLIBSUBDIR64 = $(MACH64)
129 ARCHLIBSUBDIR = $(ARCHLIBSUBDIR$(BITS))
131 ETCDIR = /etc
132 USRDIR = /usr
133 BINDIR = /bin
134 SBINDIR = /sbin
135 LIBDIR = /lib
136 VARDIR = /var
137 KERNELDRVDIR = /kernel/drv
138 KERNELDRVDIR32 =/kernel/drv
139 KERNELDRVDIR64 =/kernel/drv/$(MACH64)
140 USRBINDIR = $(USRDIR)/bin
141 USRBINDIR32 = $(USRDIR)/bin/$(MACH32)
142 USRBINDIR64 = $(USRDIR)/bin/$(MACH64)
143 USRSBINDIR = $(USRDIR)/sbin
144 USRSBINDIR32 = $(USRDIR)/sbin/$(MACH32)
145 USRSBINDIR64 = $(USRDIR)/sbin/$(MACH64)
146 USRLIBDIR = $(USRDIR)/lib
147 USRLIBDIR32 = $(USRDIR)/lib
148 USRLIBDIR64 = $(USRDIR)/lib/$(MACH64)
149 USRSHAREDIR = $(USRDIR)/share
150 USRINCDIR = $(USRDIR)/include
151 USRSHARELOCALEDIR = $(USRSHAREDIR)/locale
152 USRSHAREMANDIR = $(USRSHAREDIR)/man
153 USRSHAREDOCDIR = $(USRSHAREDIR)/doc
154 USRSHARELIBDIR = $(USRSHAREDIR)/lib
155 USRSHAREMAN1DIR = $(USRSHAREMANDIR)/man1
156 USRSHAREMAN1MDIR = $(USRSHAREMANDIR)/man1m
157 USRSHAREMAN3DIR = $(USRSHAREMANDIR)/man3
158 USRSHAREMAN4DIR = $(USRSHAREMANDIR)/man4
159 USRSHAREMAN5DIR = $(USRSHAREMANDIR)/man5
160 USRSHAREMAN8DIR = $(USRSHAREMANDIR)/man8
161 USRKERNELDRVDIR = $(USRDIR)/kernel/drv
162 USRKERNELDRVDIR32 = $(USRDIR)/kernel/drv
163 USRKERNELDRVDIR64 = $(USRDIR)/kernel/drv/$(MACH64)
165 # The *.$(BITS) variables are different from those above (better suited for
166 # isaexec wrapper), and allow for default 32-bit vs. nondefault 64-bit setups
167 USRBINDIR.32 = $(USRBINDIR)
168 USRBINDIR.64 = $(USRBINDIR64)
169 USRSBINDIR.32 = $(USRSBINDIR)
170 USRSBINDIR.64 = $(USRSBINDIR64)
171 USRLIBDIR.32 = $(USRLIBDIR)
172 USRLIBDIR.64 = $(USRLIBDIR64)
174 PROTOETCDIR = $(PROTO_DIR)/$(ETCDIR)
175 PROTOETCSECDIR = $(PROTO_DIR)/$(ETCDIR)/security
176 PROTOUSRDIR = $(PROTO_DIR)/$(USRDIR)
177 PROTOBINDIR = $(PROTO_DIR)/$(BINDIR)
178 PROTOSBINDIR = $(PROTO_DIR)/$(SBINDIR)
179 PROTOLIBDIR = $(PROTO_DIR)/$(LIBDIR)
180 PROTOVARDIR = $(PROTO_DIR)/$(VARDIR)
181 PROTOKERNELDRVDIR = $(PROTO_DIR)/$(KERNELDRVDIR)
182 PROTOKERNELDRVDIR32 = $(PROTO_DIR)/$(KERNELDRVDIR32)
183 PROTOKERNELDRVDIR64 = $(PROTO_DIR)/$(KERNELDRVDIR64)
184 PROTOUSRBINDIR = $(PROTO_DIR)/$(USRBINDIR)
185 PROTOUSRBINDIR32 = $(PROTO_DIR)/$(USRBINDIR32)
186 PROTOUSRBINDIR64 = $(PROTO_DIR)/$(USRBINDIR64)
187 PROTOUSRSBINDIR = $(PROTO_DIR)/$(USRSBINDIR)
188 PROTOUSRSBINDIR32 = $(PROTO_DIR)/$(USRSBINDIR32)
189 PROTOUSRSBINDIR64 = $(PROTO_DIR)/$(USRSBINDIR64)
190 PROTOUSRLIBDIR = $(PROTO_DIR)/$(USRLIBDIR)
191 PROTOUSRLIBDIR32 = $(PROTO_DIR)/$(USRLIBDIR32)
192 PROTOUSRLIBDIR64 = $(PROTO_DIR)/$(USRLIBDIR64)
193 PROTOUSRINCDIR = $(PROTO_DIR)/$(USRINCDIR)
194 PROTOUSRSHAREDIR = $(PROTO_DIR)/$(USRSHAREDIR)
195 PROTOUSRSHARELIBDIR = $(PROTO_DIR)/$(USRSHARELIBDIR)
196 PROTOUSRSHAREMANDIR = $(PROTO_DIR)/$(USRSHAREMANDIR)
197 PROTOUSRSHAREDOCDIR = $(PROTO_DIR)/$(USRSHAREDOCDIR)
198 PROTOUSRSHAREMAN1DIR = $(PROTO_DIR)/$(USRSHAREMAN1DIR)
199 PROTOUSRSHAREMAN1MDIR = $(PROTO_DIR)/$(USRSHAREMAN1MDIR)
200 PROTOUSRSHAREMAN3DIR = $(PROTO_DIR)/$(USRSHAREMAN3DIR)
201 PROTOUSRSHAREMAN4DIR = $(PROTO_DIR)/$(USRSHAREMAN4DIR)
202 PROTOUSRSHAREMAN5DIR = $(PROTO_DIR)/$(USRSHAREMAN5DIR)
203 PROTOUSRSHAREMAN8DIR = $(PROTO_DIR)/$(USRSHAREMAN8DIR)
204 PROTOUSRSHARELOCALEDIR = $(PROTO_DIR)/$(USRSHARELOCALEDIR)
205 PROTOUSRKERNELDRVDIR = $(PROTO_DIR)/$(USRKERNELDRVDIR)
206 PROTOUSRKERNELDRVDIR32 = $(PROTO_DIR)/$(USRKERNELDRVDIR32)
207 PROTOUSRKERNELDRVDIR64 = $(PROTO_DIR)/$(USRKERNELDRVDIR64)
209 PROTOUSRBINDIR.32 = $(PROTOUSRBINDIR)
210 PROTOUSRBINDIR.64 = $(PROTOUSRBINDIR64)
211 PROTOUSRSBINDIR.32 = $(PROTOUSRSBINDIR)
212 PROTOUSRSBINDIR.64 = $(PROTOUSRSBINDIR64)
213 PROTOUSRLIBDIR.32 = $(PROTOUSRLIBDIR)
214 PROTOUSRLIBDIR.64 = $(PROTOUSRLIBDIR64)
216 # NOTE: We do not build SFW contents
217 # /usr/sfw/bin is just a historic artefact, containing symlinks
218 SFWBIN = /usr/sfw/bin
219 SFWBIN32 = $(SFWBIN)
220 SFWBIN64 = $(SFWBIN)/$(MACH64)
221 SFWSBIN = /usr/sfw/sbin
222 SFWSBIN32 = $(SFWSBIN)
223 SFWSBIN64 = $(SFWSBIN)/$(MACH64)
224 SFWINCLUDE = /usr/sfw/include
225 SFWLIB = /usr/sfw/lib
226 SFWLIB32 = $(SFWLIB)
227 SFWLIB64 = $(SFWLIB)/$(MACH64)
228 SFWSHARE = /usr/sfw/share
229 SFWSHAREMAN = $(SFWSHARE)/man
230 SFWSHAREMAN1 = $(SFWSHAREMAN)/man1
231 PROTOSFWBIN = $(PROTO_DIR)/$(SFWBIN)
232 PROTOSFWBIN32 = $(PROTO_DIR)/$(SFWBIN32)
233 PROTOSFWBIN64 = $(PROTO_DIR)/$(SFWBIN64)
234 PROTOSFWSBIN = $(PROTO_DIR)/$(SFWSBIN)
235 PROTOSFWSBIN32 = $(PROTO_DIR)/$(SFWSBIN32)
236 PROTOSFWSBIN64 = $(PROTO_DIR)/$(SFWSBIN64)
237 PROTOSFWLIB = $(PROTO_DIR)/$(SFWLIB)
238 PROTOSFWLIB32 = $(PROTO_DIR)/$(SFWLIB32)
239 PROTOSFWLIB64 = $(PROTO_DIR)/$(SFWLIB64)
240 PROTOSFWSHARE = $(PROTO_DIR)/$(SFWSHARE)
241 PROTOSFWSHAREMAN = $(PROTO_DIR)/$(SFWSHAREMAN)
242 PROTOSFWSHAREMAN1 = $(PROTO_DIR)/$(SFWSHAREMAN1)
243 PROTOSFWINCLUDE = $(PROTO_DIR)/$(SFWINCLUDE)
245 # The *.$(BITS) variables are different from those above (better suited for
246 # isaexec wrapper), and allow for default 32-bit vs. nondefault 64-bit setups
247 SFWBIN.32 = $(SFWBIN)
248 SFWBIN.64 = $(SFWBIN64)
249 SFWSBIN.32 = $(SFWSBIN)
250 SFWSBIN.64 = $(SFWSBIN64)
251 SFWLIB.32 = $(SFWLIB)
252 SFWLIB.64 = $(SFWLIB64)
253 PROTOSFWBIN.32 = $(PROTOSFWBIN)
254 PROTOSFWBIN.64 = $(PROTOSFWBIN64)
255 PROTOSFWSBIN.32 = $(PROTOSFWSBIN)
256 PROTOSFWSBIN.64 = $(PROTOSFWSBIN64)
257 PROTOSFWLIB.32 = $(PROTOSFWLIB)
258 PROTOSFWLIB.64 = $(PROTOSFWLIB64)
260 CLDIR = /usr/share/common-lisp
261 PROTOCLDIR = $(PROTO_DIR)/$(CLDIR)
263 GNUDIR = /usr/gnu
264 GNUBIN = $(GNUDIR)/bin
265 GNUBIN32 = $(GNUBIN)/$(MACH32)
266 GNUBIN64 = $(GNUBIN)/$(MACH64)
267 GNUSBIN = $(GNUDIR)/sbin
268 GNUSBIN32 = $(GNUSBIN)/$(MACH32)
269 GNUSBIN64 = $(GNUSBIN)/$(MACH64)
270 GNULIB = $(GNUDIR)/lib
271 GNULIB32 = $(GNULIB)
272 GNULIB64 = $(GNULIB)/$(MACH64)
273 GNUSHARE = $(GNUDIR)/share
274 GNUSHAREMAN = $(GNUSHARE)/man
275 GNUSHAREMAN1 = $(GNUSHAREMAN)/man1
276 PROTOGNUBIN = $(PROTO_DIR)/$(GNUBIN)
277 PROTOGNUBIN32 = $(PROTO_DIR)/$(GNUBIN32)
278 PROTOGNUBIN64 = $(PROTO_DIR)/$(GNUBIN64)
279 PROTOGNUSBIN = $(PROTO_DIR)/$(GNUSBIN)
280 PROTOGNUSBIN32 = $(PROTO_DIR)/$(GNUSBIN32)
281 PROTOGNUSBIN64 = $(PROTO_DIR)/$(GNUSBIN64)
282 PROTOGNULIB = $(PROTO_DIR)/$(GNULIB)
283 PROTOGNULIB32 = $(PROTO_DIR)/$(GNULIB32)
284 PROTOGNULIB64 = $(PROTO_DIR)/$(GNULIB64)
285 PROTOGNUSHARE = $(PROTO_DIR)/$(GNUSHARE)
286 PROTOGNUSHAREMAN = $(PROTO_DIR)/$(GNUSHAREMAN)
287 PROTOGNUSHAREMAN1 = $(PROTO_DIR)/$(GNUSHAREMAN1)
289 # The *.$(BITS) variables are different from those above (better suited for
290 # isaexec wrapper), and allow for default 32-bit vs. nondefault 64-bit setups
291 GNUBIN.32 = $(GNUBIN)
292 GNUBIN.64 = $(GNUBIN64)
293 GNUSBIN.32 = $(GNUSBIN)
294 GNUSBIN.64 = $(GNUSBIN64)
295 GNULIB.32 = $(GNULIB)
296 GNULIB.64 = $(GNULIB64)
297 PROTOGNUBIN.32 = $(PROTOGNUBIN)
298 PROTOGNUBIN.64 = $(PROTOGNUBIN64)
299 PROTOGNUSBIN.32 = $(PROTOGNUSBIN)
300 PROTOGNUSBIN.64 = $(PROTOGNUSBIN64)
301 PROTOGNULIB.32 = $(PROTOGNULIB)
302 PROTOGNULIB.64 = $(PROTOGNULIB64)
304 # work around _TIME, _DATE, embedded date chatter in component builds
305 # to use, set TIME_CONSTANT in the component Makefile and add $(CONSTANT_TIME)
306 # to the appropriate {CONFIGURE|BUILD|INSTALL}_ENV
307 CONSTANT_TIME = LD_PRELOAD_32=$(WS_TOOLS)/time-$(MACH32).so
308 CONSTANT_TIME += LD_PRELOAD_64=$(WS_TOOLS)/time-$(MACH64).so
309 CONSTANT_TIME += TIME_CONSTANT=$(TIME_CONSTANT)
311 # set MACH from uname -p to either sparc or i386
312 MACH := $(shell uname -p)
314 # set MACH32 from MACH to either sparcv7 or i86
315 MACH32_1 = $(MACH:sparc=sparcv7)
316 MACH32 = $(MACH32_1:i386=i86)
318 # set MACH64 from MACH to either sparcv9 or amd64
319 MACH64_1 = $(MACH:sparc=sparcv9)
320 MACH64 = $(MACH64_1:i386=amd64)
322 CONFIGURE_32 = $(BUILD_DIR_32)/.configured
323 CONFIGURE_64 = $(BUILD_DIR_64)/.configured
325 BUILD_DIR_32 = $(BUILD_DIR)/$(MACH32)
326 BUILD_DIR_64 = $(BUILD_DIR)/$(MACH64)
328 BUILD_32 = $(BUILD_DIR_32)/.built
329 BUILD_64 = $(BUILD_DIR_64)/.built
330 BUILD_32_and_64 = $(BUILD_32) $(BUILD_64)
331 $(BUILD_DIR_32)/.built: BITS=32
332 $(BUILD_DIR_64)/.built: BITS=64
334 INSTALL_32 = $(BUILD_DIR_32)/.installed
335 INSTALL_64 = $(BUILD_DIR_64)/.installed
336 INSTALL_32_and_64 = $(INSTALL_32) $(INSTALL_64)
337 $(BUILD_DIR_32)/.installed: BITS=32
338 $(BUILD_DIR_64)/.installed: BITS=64
340 # set the default target for installation of the component
341 COMPONENT_INSTALL_TARGETS = install
343 # set the default build test results directory
344 COMPONENT_TEST_BUILD_DIR = $(BUILD_DIR)/test/$(MACH$(BITS))
346 # set the default master test results directory
347 COMPONENT_TEST_RESULTS_DIR = $(COMPONENT_DIR)/test
349 # set the default master test results file
350 COMPONENT_TEST_MASTER = $(COMPONENT_TEST_RESULTS_DIR)/results-$(BITS).master
352 # set the default test results output file
353 COMPONENT_TEST_OUTPUT = $(COMPONENT_TEST_BUILD_DIR)/test-$(BITS)-results
355 # set the default test results comparison diffs file
356 COMPONENT_TEST_DIFFS = $(COMPONENT_TEST_BUILD_DIR)/test-$(BITS)-diffs
358 # set the default test snapshot file
359 COMPONENT_TEST_SNAPSHOT = $(COMPONENT_TEST_BUILD_DIR)/results-$(BITS).snapshot
361 # Normally $(GSED) is simplest, but some results files need more power.
362 COMPONENT_TEST_TRANSFORMER = $(GSED)
364 # The set of default transforms to be applied to the test results to try
365 # to normalize them.
366 COMPONENT_TEST_TRANSFORMS = \
367 '-e "s|$(@D)|\\$$(@D)|g" ' \
368 '-e "s|$(PERL)|\\$$(PERL)|g" ' \
369 '-e "s|$(SOURCE_DIR)|\\$$(SOURCE_DIR)|g" '
371 # set the default commands used to generate the file containing the set
372 # of transforms to be applied to the test results to try to normalize them.
373 COMPONENT_TEST_CREATE_TRANSFORMS = \
374 if [ -e $(COMPONENT_TEST_MASTER) ]; \
375 then \
376 print "\#!/bin/sh" > $(COMPONENT_TEST_TRANSFORM_CMD); \
377 print '$(COMPONENT_TEST_TRANSFORMER) ' \
378 $(COMPONENT_TEST_TRANSFORMS) \
379 ' \\' >> $(COMPONENT_TEST_TRANSFORM_CMD); \
380 print '$(COMPONENT_TEST_OUTPUT) \\' \
381 >> $(COMPONENT_TEST_TRANSFORM_CMD); \
382 print '> $(COMPONENT_TEST_SNAPSHOT)' \
383 >> $(COMPONENT_TEST_TRANSFORM_CMD); \
386 # set the default command for performing any test result munging
387 COMPONENT_TEST_TRANSFORM_CMD = $(COMPONENT_TEST_BUILD_DIR)/transform-$(BITS)-results
389 # set the default operation to run to perform test result normalization
390 COMPONENT_TEST_PERFORM_TRANSFORM = \
391 if [ -e $(COMPONENT_TEST_MASTER) ]; \
392 then \
393 $(SHELL) $(COMPONENT_TEST_TRANSFORM_CMD); \
396 # set the default command used to compare the master results with the snapshot
397 COMPONENT_TEST_COMPARE_CMD = $(GDIFF) -uN
399 # set the default way that master and snapshot test results are compared
400 COMPONENT_TEST_COMPARE = \
401 if [ -e $(COMPONENT_TEST_MASTER) ]; \
402 then \
403 $(COMPONENT_TEST_COMPARE_CMD) \
404 $(COMPONENT_TEST_MASTER) $(COMPONENT_TEST_SNAPSHOT) \
405 > $(COMPONENT_TEST_DIFFS); \
406 print "Test results in $(COMPONENT_TEST_OUTPUT)"; \
407 if [ -s $(COMPONENT_TEST_DIFFS) ]; \
408 then \
409 print "Differences found."; \
410 $(CAT) $(COMPONENT_TEST_DIFFS); \
411 exit 2; \
412 else \
413 print "No differences found."; \
414 fi \
417 # set the default env command to use for test of the component
418 COMPONENT_TEST_ENV_CMD = $(ENV)
420 # set the default command to use for test of the component
421 COMPONENT_TEST_CMD = $(GMAKE)
423 # set the default target for test of the component
424 COMPONENT_TEST_TARGETS = check
426 # set the default directory for test of the component
427 COMPONENT_TEST_DIR = $(@D)
429 # determine the type of tests we want to run.
430 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),)
431 TEST_32 = $(BUILD_DIR_32)/.tested
432 TEST_64 = $(BUILD_DIR_64)/.tested
433 else
434 TEST_32 = $(BUILD_DIR_32)/.tested-and-compared
435 TEST_64 = $(BUILD_DIR_64)/.tested-and-compared
436 endif
437 TEST_32_and_64 = $(TEST_32) $(TEST_64)
438 $(BUILD_DIR_32)/.tested: BITS=32
439 $(BUILD_DIR_64)/.tested: BITS=64
440 $(BUILD_DIR_32)/.tested-and-compared: BITS=32
441 $(BUILD_DIR_64)/.tested-and-compared: BITS=64
443 # BUILD_TOOLS is the root of all tools not normally installed on the system.
444 BUILD_TOOLS ?= /opt
446 SPRO_VERSION = 12.1
447 SPRO_ROOT = $(BUILD_TOOLS)/sunstudio$(SPRO_VERSION)
448 SPRO_VROOT = $(SPRO_ROOT)
450 PARFAIT_ROOT = $(BUILD_TOOLS)/parfait/parfait-tools-1.0.1/
451 PARFAIT= $(PARFAIT_ROOT)/bin/parfait
452 export PARFAIT_NATIVESUNCC=$(SPRO_VROOT)/bin/cc
453 export PARFAIT_NATIVESUNCXX=$(SPRO_VROOT)/bin/CC
454 export PARFAIT_NATIVEGCC=$(GCC_ROOT)/bin/gcc
455 export PARFAIT_NATIVEGXX=$(GCC_ROOT)/bin/g++
458 # The CCACHE makefile variable should evaluate to empty string or a pathname
459 # like /usr/bin/ccache depending on your PATH value and "which" implementation.
460 # The assignment via ":=" is important, to only do this once in a Makefile,
461 # and not on every reference to the value as "=" assignment would result in.
462 # Review `man ccache` for optional configuration tuning, like cache size etc.
464 # For production builds or suspected errors you can disable this feature by
465 # setting ENABLE_CCACHE=false (as makefile or environment variable, which
466 # is currently the default) to not even define the usage of wrapper in the
467 # userland-building makefile system.
468 # If you want to speed up your re-builds, you must set ENABLE_CCACHE=true.
469 # For legacy reasons, the CCACHE_DISABLE and CCACHE_NODISABLE variables (from
470 # configuration of the "ccache" program itself) are also supported, but direct
471 # use is discouraged, since their syntax and usage are counter-intuitive.
473 # Still, absence of ccache in PATH is not considered a fatal error since the
474 # build would just proceed well with original compiler.
475 # Note: In code below we fast-track if the makefile CCACHE variable is defined
476 # but fall back to shell executability tests if just envvar CCACHE is passed.
478 export CCACHE := $(shell \
479 if test -n "$(CCACHE)" ; then \
480 echo "$(CCACHE)"; \
481 else \
482 if test x"$${CCACHE_DISABLE-}" != x -o x"$(CCACHE_DISABLE)" != x \
483 -o x"$${ENABLE_CCACHE-}" = xfalse -o x"$(ENABLE_CCACHE)" = xfalse \
484 ; then \
485 echo "NOT USING CCACHE FOR OI-USERLAND because explicitly disabled" >&2 ; \
486 else \
487 if test x"$${CCACHE_NODISABLE-}" != x -o x"$(CCACHE_NODISABLE)" != x \
488 -o x"$${ENABLE_CCACHE-}" = xtrue -o x"$(ENABLE_CCACHE)" = xtrue \
489 ; then \
490 for F in \
491 "$$CCACHE" \
492 `which ccache 2>/dev/null | egrep '^/'` \
493 /usr/bin/ccache \
494 ; do if test -n "$$F" && test -x "$$F" ; then \
495 echo "$$F" ; \
496 echo "USING CCACHE FOR OI-USERLAND: $$F" >&2 ; \
497 if test x"$${CCACHE_DISABLE-}" != x ; then \
498 echo "WARNING: envvar CCACHE_DISABLE is set, so effectively ccache will not act!" >&2 ; \
499 fi; \
500 exit 0; \
501 fi; \
502 done; \
503 echo "NOT USING CCACHE FOR OI-USERLAND because not found" >&2 ; \
504 fi; \
505 fi; \
508 GCC_VERSION = 6
509 GCC_ROOT = /usr/gcc/$(GCC_VERSION)
511 CC.studio.32 = $(SPRO_VROOT)/bin/cc
512 CXX.studio.32 = $(SPRO_VROOT)/bin/CC
513 F77.studio.32 = $(SPRO_VROOT)/bin/f77
514 FC.studio.32 = $(SPRO_VROOT)/bin/f90
516 CC.studio.64 = $(SPRO_VROOT)/bin/cc
517 CXX.studio.64 = $(SPRO_VROOT)/bin/CC
518 F77.studio.64 = $(SPRO_VROOT)/bin/f77
519 FC.studio.64 = $(SPRO_VROOT)/bin/f90
521 CC.gcc.32 = $(GCC_ROOT)/bin/gcc
522 CXX.gcc.32 = $(GCC_ROOT)/bin/g++
523 F77.gcc.32 = $(GCC_ROOT)/bin/gfortran
524 FC.gcc.32 = $(GCC_ROOT)/bin/gfortran
526 CC.gcc.64 = $(GCC_ROOT)/bin/gcc
527 CXX.gcc.64 = $(GCC_ROOT)/bin/g++
528 F77.gcc.64 = $(GCC_ROOT)/bin/gfortran
529 FC.gcc.64 = $(GCC_ROOT)/bin/gfortran
531 ifneq ($(strip $(CCACHE)),)
533 CCACHE_WRAP_ROOT = $(WS_TOOLS)/ccache-wrap
534 export CC_gcc_32 := $(CC.gcc.32)
535 export CC_gcc_64 := $(CC.gcc.64)
536 export CXX_gcc_32 := $(CXX.gcc.32)
537 export CXX_gcc_64 := $(CXX.gcc.64)
538 CC.gcc.32 := $(CCACHE_WRAP_ROOT)/CC.gcc.32
539 CC.gcc.64 := $(CCACHE_WRAP_ROOT)/CC.gcc.64
540 CXX.gcc.32 := $(CCACHE_WRAP_ROOT)/CXX.gcc.32
541 CXX.gcc.64 := $(CCACHE_WRAP_ROOT)/CXX.gcc.64
543 ifneq ($(strip $(CCACHE_DIR)),)
544 export CCACHE_DIR := $(CCACHE_DIR)
545 endif
547 ifneq ($(strip $(CCACHE_LOGFILE)),)
548 export CCACHE_LOGFILE := $(CCACHE_LOGFILE)
549 endif
551 endif
553 lint.32 = $(SPRO_VROOT)/bin/lint -m32
554 lint.64 = $(SPRO_VROOT)/bin/lint -m64
556 LINT = $(lint.$(BITS))
558 LD = /usr/bin/ld
560 PYTHON.2.7.VENDOR_PACKAGES.32 = /usr/lib/python2.7/vendor-packages
561 PYTHON.2.7.VENDOR_PACKAGES.64 = /usr/lib/python2.7/vendor-packages/64
562 PYTHON.2.7.VENDOR_PACKAGES = $(PYTHON.2.7.VENDOR_PACKAGES.$(BITS))
564 PYTHON.3.4.VENDOR_PACKAGES.32 = /usr/lib/python3.4/vendor-packages
565 PYTHON.3.4.VENDOR_PACKAGES.64 = /usr/lib/python3.4/vendor-packages/64
566 PYTHON.3.4.VENDOR_PACKAGES = $(PYTHON.3.4.VENDOR_PACKAGES.$(BITS))
568 ifeq ($(strip $(PARFAIT_BUILD)),yes)
569 CC.studio.32 = $(WS_TOOLS)/parfait/cc
570 CXX.studio.32 = $(WS_TOOLS)/parfait/CC
571 CC.studio.64 = $(WS_TOOLS)/parfait/cc
572 CXX.studio.64 = $(WS_TOOLS)/parfait/CC
573 CC.gcc.32 = $(WS_TOOLS)/parfait/gcc
574 CXX.gcc.32 = $(WS_TOOLS)/parfait/g++
575 CC.gcc.64 = $(WS_TOOLS)/parfait/gcc
576 CXX.gcc.64 = $(WS_TOOLS)/parfait/g++
577 LD = $(WS_TOOLS)/parfait/ld
578 endif
580 CC = $(CC.$(COMPILER).$(BITS))
581 CXX = $(CXX.$(COMPILER).$(BITS))
582 F77 = $(F77.$(COMPILER).$(BITS))
583 FC = $(FC.$(COMPILER).$(BITS))
585 RUBY_VERSION = 2.3
586 RUBY_LIB_VERSION.2.2 = 2.2.0
587 RUBY_LIB_VERSION.2.3 = 2.3.0
588 RUBY.2.2 = /usr/ruby/2.2/bin/ruby
589 RUBY.2.3 = /usr/ruby/2.3/bin/ruby
590 RUBY = $(RUBY.$(RUBY_VERSION))
591 RUBY_LIB_VERSION = $(RUBY_LIB_VERSION.$(RUBY_VERSION))
593 # Transform Ruby scripts to call the supported
594 # version-specific ruby; used in multiple *.mk files
595 RUBY_SCRIPT_FIX_FUNC = \
596 $(GNU_GREP) -Rl '^\#! */usr/bin/env ruby' | \
597 /usr/bin/xargs -I\{\} $(GSED) -i -e \
598 '1s%^\#! */usr/bin/env ruby%\#!/usr/ruby/$(RUBY_VERSION)/bin/ruby%' \
599 \{\}
601 # Use the ruby lib versions to represent the RUBY_VERSIONS that
602 # need to get built. This is done because during package transformations
603 # both the ruby version and the ruby library version are needed.
604 RUBY_VERSIONS = $(RUBY_LIB_VERSION)
606 PYTHON_VENDOR_PACKAGES.32 = /usr/lib/python$(PYTHON_VERSION)/vendor-packages
607 PYTHON_VENDOR_PACKAGES.64 = /usr/lib/python$(PYTHON_VERSION)/vendor-packages/64
608 PYTHON_VENDOR_PACKAGES = $(PYTHON_VENDOR_PACKAGES.$(BITS))
610 PYTHON.2.7.32 = /usr/bin/python2.7
611 PYTHON.2.7.64 = /usr/bin/$(MACH64)/python2.7
613 PYTHON.3.4.32 = /usr/bin/python3.4
614 PYTHON.3.4.64 = /usr/bin/$(MACH64)/python3.4
616 PYTHON.32 = $(PYTHON.$(PYTHON_VERSION).32)
617 PYTHON.64 = $(PYTHON.$(PYTHON_VERSION).64)
618 PYTHON = $(PYTHON.$(PYTHON_VERSION).$(BITS))
620 # The default is site-packages, but that directory belongs to the end-user.
621 # Modules which are shipped by the OS but not with the core Python distribution
622 # belong in vendor-packages.
623 PYTHON_LIB= /usr/lib/python$(PYTHON_VERSION)/vendor-packages
624 PYTHON_DATA= $(PYTHON_LIB)
626 JAVA7_HOME = /usr/jdk/instances/openjdk1.7.0
627 JAVA8_HOME = /usr/jdk/instances/openjdk1.8.0
628 JAVA_HOME = $(JAVA8_HOME)
630 # This is the default BUILD version of perl
631 # Not necessarily the system's default version, i.e. /usr/bin/perl
632 PERL_VERSION = 5.22
634 PERL_VERSIONS = 5.22
636 PERL.5.22 = /usr/perl5/5.22/bin/perl
637 PERL.5.24 = /usr/perl5/5.24/bin/perl
639 POD2MAN.5.22 = /usr/perl5/5.22/bin/pod2man
640 POD2MAN.5.24 = /usr/perl5/5.24/bin/pod2man
642 PERL = $(PERL.$(PERL_VERSION))
643 POD2MAN = $(POD2MAN.$(PERL_VERSION))
645 PERL_ARCH := $(shell $(PERL) -e 'use Config; print $$Config{archname}')
646 PERL_ARCH_FUNC= $(shell $(1) -e 'use Config; print $$Config{archname}')
647 # Optimally we should ask perl which C compiler was used but it doesn't
648 # result in a full path name. Only "c" is being recorded
649 # inside perl builds while we actually need a full path to
650 # the studio compiler.
651 #PERL_CC := $(shell $(PERL) -e 'use Config; print $$Config{cc}')
653 PKG_MACROS += PERL_ARCH=$(PERL_ARCH)
654 PKG_MACROS += PERL_VERSION=$(PERL_VERSION)
656 # Config magic for Postgres/EnterpriseDB/...
657 # Default DB version is the oldest one, for hopefully best built complatibility
658 PG_VERSION ?= 9.3
659 PG_IMPLEM ?= postgres
660 PG_VERNUM = $(subst .,,$(PG_VERSION))
661 # For dependencies, including REQUIRED_PACKAGES if needed
662 PG_BASEPKG = database/$(PG_IMPLEM)-$(PG_VERNUM)
664 PG_HOME = $(USRDIR)/$(PG_IMPLEM)/$(PG_VERSION)
665 PG_BINDIR.32 = $(PG_HOME)/bin
666 PG_BINDIR.64 = $(PG_HOME)/bin/$(MACH64)
667 PG_BINDIR = $(PG_BINDIR.$(BITS))
668 PG_INCDIR = $(PG_HOME)/include
669 PG_MANDIR = $(PG_HOME)/man
670 PG_SHAREDIR = $(PG_HOME)/share
671 PG_DOCDIR = $(PG_HOME)/doc
672 PG_LIBDIR.32 = $(PG_HOME)/lib
673 PG_LIBDIR.64 = $(PG_HOME)/lib/$(MACH64)
674 PG_LIBDIR = $(PG_LIBDIR.$(BITS))
675 PG_CONFIG.32 = $(PG_BINDIR.32)/pg_config
676 PG_CONFIG.64 = $(PG_BINDIR.64)/pg_config
677 PG_CONFIG = $(PG_CONFIG.$(BITS))
679 PKG_MACROS += PG_VERSION=$(PG_VERSION)
680 PKG_MACROS += PG_VERNUM=$(PG_VERNUM)
681 PKG_MACROS += PG_BASEPKG=$(PG_BASEPKG)
683 # Config magic for MySQL/MariaDB/Percona/...
684 # Default DB version is the oldest one, for hopefully best built compatibility
685 # NOTE: At this time the gate does not provide a recipe for actual "mysql"
686 # The "/usr/mysql/*" trees are mediated to preferred MariaDB or Percona variant
687 MYSQL_VERSION ?= 5.5
688 MYSQL_IMPLEM ?= mariadb
689 MYSQL_VERNUM = $(subst .,,$(MYSQL_VERSION))
690 # For dependencies, including REQUIRED_PACKAGES if needed
691 MYSQL_BASEPKG = database/$(MYSQL_IMPLEM)-$(MYSQL_VERNUM)
693 MYSQL_HOME = $(USRDIR)/$(MYSQL_IMPLEM)/$(MYSQL_VERSION)
694 MYSQL_BINDIR.32 = $(MYSQL_HOME)/bin
695 MYSQL_BINDIR.64 = $(MYSQL_HOME)/bin/$(MACH64)
696 MYSQL_BINDIR = $(MYSQL_BINDIR.$(BITS))
697 MYSQL_INCDIR = $(MYSQL_HOME)/include
698 MYSQL_MANDIR = $(MYSQL_HOME)/man
699 MYSQL_SHAREDIR = $(MYSQL_HOME)/share
700 MYSQL_DOCDIR = $(MYSQL_HOME)/doc
701 MYSQL_LIBDIR.32 = $(MYSQL_HOME)/lib
702 MYSQL_LIBDIR.64 = $(MYSQL_HOME)/lib/$(MACH64)
703 MYSQL_LIBDIR = $(MYSQL_LIBDIR.$(BITS))
704 MYSQL_CONFIG.32 = $(MYSQL_BINDIR.32)/mysql_config
705 MYSQL_CONFIG.64 = $(MYSQL_BINDIR.64)/mysql_config
706 MYSQL_CONFIG = $(MYSQL_CONFIG.$(BITS))
708 PKG_MACROS += MYSQL_VERSION=$(MYSQL_VERSION)
709 PKG_MACROS += MYSQL_VERNUM=$(MYSQL_VERNUM)
710 PKG_MACROS += MYSQL_BASEPKG=$(MYSQL_BASEPKG)
712 # Default libjpeg implementation layout
713 JPEG_IMPLEM ?= libjpeg8-turbo
714 JPEG_HOME = $(USRLIBDIR)/$(JPEG_IMPLEM)
715 JPEG_BINDIR.32 = $(JPEG_HOME)/bin
716 JPEG_BINDIR.64 = $(JPEG_HOME)/bin/$(MACH64)
717 JPEG_BINDIR = $(JPEG_BINDIR.$(BITS))
718 JPEG_INCDIR = $(USRINCDIR)/$(JPEG_IMPLEM)
719 JPEG_LIBDIR.32 = $(JPEG_HOME)/lib
720 JPEG_LIBDIR.64 = $(JPEG_HOME)/lib/$(MACH64)
721 JPEG_LIBDIR = $(JPEG_LIBDIR.$(BITS))
722 JPEG_CPPFLAGS = -I$(JPEG_INCDIR)
723 JPEG_CFLAGS.32 = -Wl,-L$(JPEG_LIBDIR.32) -Wl,-R$(JPEG_LIBDIR.32)
724 JPEG_CFLAGS.64 = -Wl,-L$(JPEG_LIBDIR.64) -Wl,-R$(JPEG_LIBDIR.64)
725 JPEG_CFLAGS = $(JPEG_CFLAGS.$(BITS))
726 JPEG_CXXFLAGS.32 = -Wl,-L$(JPEG_LIBDIR.32) -Wl,-R$(JPEG_LIBDIR.32)
727 JPEG_CXXFLAGS.64 = -Wl,-L$(JPEG_LIBDIR.64) -Wl,-R$(JPEG_LIBDIR.64)
728 JPEG_CXXFLAGS = $(JPEG_CXXFLAGS.$(BITS))
729 JPEG_LDFLAGS.32 = -L$(JPEG_LIBDIR.32) -R$(JPEG_LIBDIR.32)
730 JPEG_LDFLAGS.64 = -L$(JPEG_LIBDIR.64) -R$(JPEG_LIBDIR.64)
731 JPEG_LDFLAGS = $(JPEG_LDFLAGS.$(BITS))
733 # This is the default BUILD version of tcl
734 # Not necessarily the system's default version, i.e. /usr/bin/tclsh
735 TCL_VERSION = 8.5
736 TCLSH.8.5.i386.32 = /usr/bin/i86/tclsh8.5
737 TCLSH.8.5.i386.64 = /usr/bin/amd64/tclsh8.5
738 TCLSH.8.5.sparc.32 = /usr/bin/sparcv7/tclsh8.5
739 TCLSH.8.5.sparc.64 = /usr/bin/sparcv9/tclsh8.5
740 TCLSH = $(TCLSH.$(TCL_VERSION).$(MACH).$(BITS))
742 CCSMAKE = /usr/bin/dmake
743 GMAKE = /usr/gnu/bin/make
744 GPATCH = /usr/gnu/bin/patch
745 PATCH_LEVEL = 1
746 GPATCH_BACKUP = --backup --version-control=numbered
747 GPATCH_FLAGS = -p$(PATCH_LEVEL) $(GPATCH_BACKUP)
748 GSED = /usr/bin/sed
749 GDIFF = /usr/gnu/bin/diff
750 GSORT = /usr/gnu/bin/sort
751 GUNZIP = /usr/bin/gunzip
753 PKGREPO = /usr/bin/pkgrepo
754 PKGSEND = /usr/bin/pkgsend
755 ifeq ($(strip $(PKGLINT_COMPONENT)),)
756 PKGLINT = /usr/bin/pkglint
757 else
758 PKGLINT = ${WS_TOOLS}/pkglint
759 endif
761 ACLOCAL = /usr/bin/aclocal-1.10
762 AUTOMAKE = /usr/bin/automake-1.10
763 AUTORECONF = /usr/bin/autoreconf
765 KSH93 = /usr/bin/ksh93
766 TOUCH = /usr/bin/touch
767 MKDIR = /bin/mkdir -p
768 RM = /bin/rm -f
769 CP = /bin/cp -f
770 MV = /bin/mv -f
771 LN = /bin/ln
772 CAT = /bin/cat
773 SYMLINK = /bin/ln -s
774 ENV = /usr/bin/env
775 FIND = /usr/bin/find
776 INSTALL = /usr/bin/install
777 GNU_GREP = /usr/gnu/bin/grep
778 CHMOD = /usr/bin/chmod
779 NAWK = /usr/bin/nawk
780 TEE = /usr/bin/tee
781 GAS = /usr/gnu/bin/as
782 GTAR = /usr/gnu/bin/tar
783 STRIP = /usr/bin/strip
784 IPS2TGZ = $(WS_TOOLS)/ips2tgz
786 INS.dir= $(INSTALL) -d $@
787 INS.file= $(INSTALL) -m 444 $< $(@D)
789 PKG_CONFIG_PATH.32 = /usr/lib/pkgconfig
790 PKG_CONFIG_PATH.64 = /usr/lib/$(MACH64)/pkgconfig
791 PKG_CONFIG_PATH = $(PKG_CONFIG_PATH.$(BITS))
793 # Set default path for environment modules
794 MODULE_VERSION = 3.2.10
795 MODULE_PATH = /usr/share/Modules/modulefiles
796 MODULE_VERSIONS_PATH = /usr/share/Modules/versions
798 # Path to bash completions
799 BASH_COMPLETIONS_PATH = /usr/share/bash-completion/completions
802 # C preprocessor flag sets to ease feature selection. Add the required
803 # feature to your Makefile with CPPFLAGS += $(FEATURE_MACRO) and add to
804 # the component build with CONFIGURE_OPTIONS += CPPFLAGS="$(CPPFLAGS)" or
805 # similiar.
808 # Enables visibility of some c99 math functions that aren't visible by default.
809 # What other side-effects are there?
810 CPP_C99_EXTENDED_MATH = -D_STDC_99
812 # Enables large file support for components that have no other means of doing
813 # so. Use CPP_LARGEFILES and not the .32/.64 variety directly
814 CPP_LARGEFILES.32 := $(shell getconf LFS_CFLAGS)
815 CPP_LARGEFILES.64 := $(shell getconf LFS64_CFLAGS)
816 CPP_LARGEFILES = $(CPP_LARGEFILES.$(BITS))
818 # Enables some #pragma redefine_extname to POSIX-compliant Standard C Library
819 # functions. Also avoids the component's #define _POSIX_C_SOURCE to some value
820 # we currently do not support.
821 CPP_POSIX = -D_POSIX_C_SOURCE=200112L -D_POSIX_PTHREAD_SEMANTICS
823 # XPG6 mode. This option enables XPG6 conformance, plus extensions.
824 # Amongst other things, this option will cause system calls like
825 # popen (3C) and system (3C) to invoke the standards-conforming
826 # shell, /usr/xpg4/bin/sh, instead of /usr/bin/sh. Add studio_XPG6MODE to
827 # CFLAGS instead of using this directly
828 CPP_XPG6MODE= -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1 -D_XPG6
830 # XPG5 mode. These options are specific for C++, where _XPG6,
831 # _XOPEN_SOURCE=600 and C99 are illegal. -D__EXTENSIONS__=1 is legal in C++.
832 CPP_XPG5MODE= -D_XOPEN_SOURCE=500 -D__EXTENSIONS__=1 -D_XPG5
835 # Studio C compiler flag sets to ease feature selection. Add the required
836 # feature to your Makefile with CFLAGS += $(FEATURE_MACRO) and add to the
837 # component build with CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)" or similiar.
840 # Generate 32/64 bit objects
841 CC_BITS = -m$(BITS)
843 # Code generation instruction set and optimization 'hints'. Use studio_XBITS
844 # and not the .arch.bits variety directly.
845 studio_XBITS.sparc.32 = -xtarget=ultra2 -xarch=sparcvis -xchip=ultra2
846 studio_XBITS.sparc.64 =
847 ifneq ($(strip $(PARFAIT_BUILD)),yes)
848 studio_XBITS.sparc.64 += -xtarget=ultra2
849 endif
850 studio_XBITS.sparc.64 += -xarch=sparcvis -xchip=ultra2
851 studio_XBITS.i386.32 = -xchip=pentium
852 studio_XBITS.i386.64 = -xchip=generic -Ui386 -U__i386
853 studio_XBITS = $(studio_XBITS.$(MACH).$(BITS))
855 # Turn on recognition of supported C99 language features and enable the 1999 C
856 # standard library semantics of routines that appear in both the 1990 and
857 # 1999 C standard. To use set studio_C99MODE=$(studio_99_ENABLE) in your
858 # component Makefile.
859 studio_C99_ENABLE = -xc99=all
861 # Turn off recognition of C99 language features, and do not enable the 1999 C
862 # standard library semantics of routines that appeared in both the 1990 and
863 # 1999 C standard. To use set studio_C99MODE=$(studio_99_DISABLE) in your
864 # component Makefile.
865 studio_C99_DISABLE = -xc99=none
867 # Use the compiler default 'xc99=all,no_lib'
868 studio_C99MODE =
870 # For C++, compatibility with C99 (which is technically illegal) is
871 # enabled in a different way. So, we must use a different macro for it.
872 studio_cplusplus_C99_ENABLE = -xlang=c99
874 # Turn it off.
875 studio_cplusplus_C99_DISABLE =
877 # And this is the macro you should actually use
878 studio_cplusplus_C99MODE =
880 # Turn on C99 for gcc
881 gcc_C99_ENABLE = -std=c99
883 # Allow zero-sized struct/union declarations and void functions with return
884 # statements.
885 studio_FEATURES_EXTENSIONS = -features=extensions
887 # Control the Studio optimization level.
888 studio_OPT.sparc.32 = -xO4
889 studio_OPT.sparc.64 = -xO4
890 studio_OPT.i386.32 = -xO4
891 studio_OPT.i386.64 = -xO4
892 studio_OPT = $(studio_OPT.$(MACH).$(BITS))
894 # Studio PIC code generation. Use CC_PIC instead to select PIC code generation.
895 studio_PIC = -KPIC -DPIC
897 # The Sun Studio 11 compiler has changed the behaviour of integer
898 # wrap arounds and so a flag is needed to use the legacy behaviour
899 # (without this flag panics/hangs could be exposed within the source).
900 # This is used through studio_IROPTS, not the 'sparc' variety.
901 studio_IROPTS.sparc = -W2,-xwrap_int
902 studio_IROPTS = $(studio_IROPTS.$(MACH))
904 # Control register usage for generated code. SPARC ABI requires system
905 # libraries not to use application registers. x86 requires 'no%frameptr' at
906 # x04 or higher.
908 # We should just use -xregs but we need to workaround 7030022. Note
909 # that we can't use the (documented) -Wc,-xregs workaround because
910 # libtool really hates -Wc and thinks it should be -Wl. Instead
911 # we use an (undocumented) option which actually happens to be what
912 # CC would use.
913 studio_XREGS.sparc = -Qoption cg -xregs=no%appl
914 studio_XREGS.i386 = -xregs=no%frameptr
915 studio_XREGS = $(studio_XREGS.$(MACH))
917 gcc_XREGS.sparc = -mno-app-regs
918 gcc_XREGS.i386 =
919 gcc_XREGS = $(gcc_XREGS.$(MACH))
921 # Set data alignment on sparc to reasonable values, 8 byte alignment for 32 bit
922 # objects and 16 byte alignment for 64 bit objects. This is added to CFLAGS by
923 # default.
924 studio_ALIGN.sparc.32 = -xmemalign=8s
925 studio_ALIGN.sparc.64 = -xmemalign=16s
926 studio_ALIGN = $(studio_ALIGN.$(MACH).$(BITS))
928 # Studio shorthand for building multi-threaded code, enables -D_REENTRANT and
929 # linking with threadin support. This is added to CFLAGS by default, override
930 # studio_MT to turn this off.
931 studio_MT = -mt
933 # See CPP_XPG6MODE comment above.
934 studio_XPG6MODE = $(studio_C99MODE) $(CPP_XPG6MODE)
935 XPG6MODE = $(studio_XPG6MODE)
937 # See CPP_XPG5MODE comment above. You can only use this in C++, not in C99.
938 studio_XPG5MODE = $(studio_cplusplus_C99MODE) $(CPP_XPG5MODE)
939 XPG5MODE = $(studio_XPG5MODE)
941 # Default Studio C compiler flags. Add the required feature to your Makefile
942 # with CFLAGS += $(FEATURE_MACRO) and add to the component build with
943 # CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)" or similiar. In most cases, it
944 # should not be necessary to add CFLAGS to any environment other than the
945 # configure environment.
946 CFLAGS.studio += $(studio_OPT) $(studio_XBITS) $(studio_XREGS) \
947 $(studio_IROPTS) $(studio_C99MODE) $(studio_ALIGN) \
948 $(studio_MT)
951 # GNU C compiler flag sets to ease feature selection. Add the required
952 # feature to your Makefile with CFLAGS += $(FEATURE_MACRO) and add to the
953 # component build with CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)" or similiar.
956 # GCC Compiler optimization flag
957 gcc_OPT = -O3
959 # GCC PIC code generation. Use CC_PIC instead to select PIC code generation.
960 gcc_PIC = -fPIC -DPIC
962 # Generic macro for PIC code generation. Use this macro instead of the
963 # compiler specific variant.
964 CC_PIC = $($(COMPILER)_PIC)
967 # Default GNU C compiler flags. Add the required feature to your Makefile
968 # with CFLAGS += $(FEATURE_MACRO) and add to the component build with
969 # CONFIGURE_OPTIONS += CFLAGS="$(CFLAGS)" or similiar. In most cases, it
970 # should not be necessary to add CFLAGS to any environment other than the
971 # configure environment.
972 CFLAGS.gcc += $(gcc_OPT)
973 CFLAGS.gcc += $(gcc_XREGS)
976 # Build 32 or 64 bit objects.
977 CFLAGS += $(CC_BITS)
979 # Add compiler specific 'default' features
980 CFLAGS += $(CFLAGS.$(COMPILER))
983 # Studio C++ requires -norunpath to avoid adding its location into the RUNPATH
984 # to C++ applications.
985 studio_NORUNPATH = -norunpath
987 # To link in standard mode (the default mode) without any C++ libraries
988 # (except libCrun), use studio_LIBRARY_NONE in your component Makefile.
989 studio_LIBRARY_NONE = -library=%none
991 # Don't link C++ with any C++ Runtime or Standard C++ library
992 studio_CXXLIB_NONE = -xnolib
994 # Link C++ with the Studio C++ Runtime and Standard C++ library. This is the
995 # default for "standard" mode.
996 studio_CXXLIB_CSTD = -library=Cstd,Crun
998 # link C++ with the Studio C++ Runtime and Apache Standard C++ library
999 studio_CXXLIB_APACHE = -library=stdcxx4,Crun
1001 # Add the C++ ABI compatibility flags for older ABI compatibility. The default
1002 # is "standard mode" (-compat=5)
1003 studio_COMPAT_VERSION_4 = -compat=4
1005 # Tell the compiler that we don't want the studio runpath added to the
1006 # linker flags. We never want the Studio location added to the RUNPATH.
1007 CXXFLAGS += $($(COMPILER)_NORUNPATH)
1009 # Build 32 or 64 bit objects in C++ as well.
1010 CXXFLAGS += $(CC_BITS)
1012 # Build 32 or 64 bit objects in FORTRAN as well.
1013 F77FLAGS += $(CC_BITS)
1014 FCFLAGS += $(CC_BITS)
1018 # Solaris linker flag sets to ease feature selection. Add the required
1019 # feature to your Makefile with LDFLAGS += $(FEATURE_MACRO) and add to the
1020 # component build with CONFIGURE_OPTIONS += LDFLAGS="$(LDFLAGS)" or similiar.
1023 # set the bittedness that we want to link
1024 ccs.ld.64 = -64
1025 gcc.ld.32 = -m32
1026 gcc.ld.64 = -m64
1027 LD_BITS = $($(LINKER).ld.$(BITS))
1028 LDFLAGS = $(LD_BITS)
1030 # Reduce the symbol table size, effectively conflicting with -g. We should
1031 # get linker guidance here.
1032 LD_Z_REDLOCSYM = -z redlocsym
1034 # Cause the linker to rescan archive libraries and resolve remaining unresolved
1035 # symbols recursively until all symbols are resolved. Components should be
1036 # linking in the libraries they need, in the required order. This should
1037 # only be required if the component's native build is horribly broken.
1038 LD_Z_RESCAN_NOW = -z rescan-now
1040 LD_Z_TEXT = -z direct
1042 # make sure that -lc is always present when building shared objects.
1043 LD_DEF_LIBS += -lc
1045 # make sure all symbols are defined.
1046 LD_Z_DEFS = -z defs
1048 # eliminate unreferenced dynamic dependencies
1049 LD_Z_IGNORE = -z ignore
1051 # use direct binding
1052 LD_B_DIRECT = -Bdirect
1054 # use generic macro names for enabling/disabling ASLR
1055 ASLR_ENABLE = -z aslr=enable
1056 ASLR_DISABLE = -z aslr=disable
1057 ASLR_MODE = $(ASLR_DISABLE)
1059 # by default, turn off Address Space Layout Randomization for ELF executables;
1060 # to explicitly enable ASLR, set ASLR_MODE = $(ASLR_ENABLE)
1061 # in that component's Makefile
1062 LD_Z_ASLR = $(ASLR_MODE)
1065 # More Solaris linker flags that we want to be sure that everyone gets. This
1066 # is automatically added to the calling environment during the 'build' and
1067 # 'install' phases of the component build. Each individual feature can be
1068 # turned off by adding FEATURE_MACRO= to the component Makefile.
1071 # Create a non-executable bss segment when linking.
1072 LD_MAP_NOEXBSS = -M /usr/lib/ld/map.noexbss
1074 # Page alignment
1075 LD_MAP_PAGEALIGN = -M /usr/lib/ld/map.pagealign
1077 # Linker options to add when only building libraries
1078 LD_OPTIONS_SO += $(LD_Z_TEXT) $(LD_Z_DEFS) $(LD_DEF_LIBS)
1080 # Default linker options that everyone should get. Do not add additional
1081 # libraries to this macro, as it will apply to everything linked during the
1082 # component build.
1083 LD_OPTIONS += $(LD_MAP_PAGEALIGN) $(LD_B_DIRECT) $(LD_Z_IGNORE)
1085 # only used on executables
1086 LD_EXEC_OPTIONS = $(LD_Z_ASLR)
1088 # Environment variables and arguments passed into the build and install
1089 # environment(s). These are the initial settings.
1090 COMPONENT_BUILD_ENV= \
1091 LD_OPTIONS="$(LD_OPTIONS)" \
1092 LD_EXEC_OPTIONS="$(LD_EXEC_OPTIONS)"
1093 COMPONENT_INSTALL_ENV= \
1094 LD_OPTIONS="$(LD_OPTIONS)" \
1095 LD_EXEC_OPTIONS="$(LD_EXEC_OPTIONS)"
1097 # PERL options which depend on C options should be placed here
1098 # Don't trust Perl $Config{optimize}, we can get Studio flags
1099 PERL_OPTIMIZE =$(gcc_OPT)
1101 # We need this to overwrite options of perl used to compile illumos-gate
1102 PERL_STUDIO_OVERWRITE = cc="$(CC)" cccdlflags="$(CC_PIC)" ld="$(CC)" ccname="$(shell basename $(CC))" optimize="$(gcc_OPT)"
1104 # Allow user to override default maximum number of archives
1105 NUM_EXTRA_ARCHIVES= 1 2 3 4 5 6 7 8 9 10
1107 # Rewrite absolute source-code paths into relative for ccache, so that any
1108 # workspace with a shared CCACHE_DIR can benefit when compiling a component
1109 ifneq ($(strip $(CCACHE)),)
1110 export CCACHE_BASEDIR = $(BUILD_DIR_$(BITS))
1111 COMPONENT_BUILD_ENV += CCACHE="$(CCACHE)"
1112 COMPONENT_INSTALL_ENV += CCACHE="$(CCACHE)"
1113 COMPONENT_TEST_ENV += CCACHE="$(CCACHE)"
1114 COMPONENT_BUILD_ENV += CC_gcc_32="$(CC_gcc_32)"
1115 COMPONENT_BUILD_ENV += CC_gcc_64="$(CC_gcc_32)"
1116 COMPONENT_BUILD_ENV += CXX_gcc_32="$(CXX_gcc_64)"
1117 COMPONENT_BUILD_ENV += CXX_gcc_64="$(CXX_gcc_64)"
1118 COMPONENT_INSTALL_ENV += CC_gcc_32="$(CC_gcc_32)"
1119 COMPONENT_INSTALL_ENV += CC_gcc_64="$(CC_gcc_32)"
1120 COMPONENT_INSTALL_ENV += CXX_gcc_32="$(CXX_gcc_64)"
1121 COMPONENT_INSTALL_ENV += CXX_gcc_64="$(CXX_gcc_64)"
1122 COMPONENT_TEST_ENV += CC_gcc_32="$(CC_gcc_32)"
1123 COMPONENT_TEST_ENV += CC_gcc_64="$(CC_gcc_32)"
1124 COMPONENT_TEST_ENV += CXX_gcc_32="$(CXX_gcc_64)"
1125 COMPONENT_TEST_ENV += CXX_gcc_64="$(CXX_gcc_64)"
1126 COMPONENT_BUILD_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
1127 COMPONENT_INSTALL_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
1128 COMPONENT_TEST_ENV.$(BITS) += CCACHE_BASEDIR="$(BUILD_DIR_$(BITS))"
1130 ifneq ($(strip $(CCACHE_DIR)),)
1131 COMPONENT_BUILD_ENV += CCACHE_DIR="$(CCACHE_DIR)"
1132 COMPONENT_INSTALL_ENV += CCACHE_DIR="$(CCACHE_DIR)"
1133 COMPONENT_TEST_ENV += CCACHE_DIR="$(CCACHE_DIR)"
1134 endif
1136 ifneq ($(strip $(CCACHE_LOGFILE)),)
1137 COMPONENT_BUILD_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
1138 COMPONENT_INSTALL_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
1139 COMPONENT_TEST_ENV += CCACHE_LOGFILE="$(CCACHE_LOGFILE)"
1140 endif
1142 endif
1144 # Add any bit-specific settings
1145 COMPONENT_BUILD_ENV += $(COMPONENT_BUILD_ENV.$(BITS))
1146 COMPONENT_BUILD_ARGS += $(COMPONENT_BUILD_ARGS.$(BITS))
1147 COMPONENT_INSTALL_ENV += $(COMPONENT_INSTALL_ENV.$(BITS))
1148 COMPONENT_INSTALL_ARGS += $(COMPONENT_INSTALL_ARGS.$(BITS))
1150 # declare these phony so that we avoid filesystem conflicts.
1151 .PHONY: prep build install publish test clean clobber parfait
1153 # If there are no tests to execute
1154 NO_TESTS = test-nothing
1155 test-nothing:
1156 @echo "There are no tests available at this time."
1158 # default behaviour for 'component-hook' target is to echo the component
1159 # name and version information, but more complex behaviour can be implemented
1160 # via command line setting of the COMPONENT_HOOK macro.
1161 COMPONENT_HOOK ?= echo $(COMPONENT_NAME) $(COMPONENT_VERSION)
1163 component-hook:
1164 @$(COMPONENT_HOOK)
1167 # Packages with tools that are required to build Userland components
1169 REQUIRED_PACKAGES += metapackages/build-essential
1171 # Only a default dependency if component being built produces binaries.
1172 ifneq ($(strip $(BUILD_BITS)),NO_ARCH)
1173 REQUIRED_PACKAGES += system/library
1174 endif
1176 include $(WS_MAKE_RULES)/environment.mk
1178 # A simple rule to print the value of any macro. Ex:
1179 # $ gmake print-REQUIRED_PACKAGES
1180 # Note that some macros are set on a per target basis, so what you see
1181 # is not always what you get.
1182 print-%:
1183 @echo '$(subst ','\'',$*=$($*)) (origin: $(origin $*), flavor: $(flavor $*))'