thunderbird: update to 128.3.3
[oi-userland.git] / make-rules / meson.mk
blobea7c54f92b8b7063ba91e2324dbef70a03ac2259
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
23 # Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
27 # Rules and Macros for building open source software that uses meson
28 # to configure their build for the system they are on. It then includes
29 # ninja.mk to handle the build/install/test macros
31 # To use these rules in your component Makefile, set BUILD_STYLE=meson and
32 # then include $(WS_MAKE_RULES)/common.mk.
34 # Any additional pre/post configure actions can be specified
35 # in your make file by setting them in one of the following macros:
36 # COMPONENT_PRE_CONFIGURE_ACTION, COMPONENT_POST_CONFIGURE_ACTION
39 CONFIGURE_PREFIX ?= /usr
41 # When debugging a component, override this to be debug or debugoptimized
42 MESON_BUILDTYPE ?= plain
44 ifeq ($(strip $(MESON_BUILDTYPE)), debug)
45 MESON_OPTIMIZATION ?= g
46 else
47 MESON_OPTIMIZATION ?= 3
48 endif
50 MESON_BUILDPIE ?= false
52 # By default do not download any subprojects
53 MESON_WRAPMODE ?= nodownload
55 # If the component prefers 64-bit binaries, then ensure builds deliver 64-bit
56 # binaries to the standard directories and 32-bit binaries to the non-standard
57 # location. This allows simplification of package manifests and makes it
58 # easier to deliver the 64-bit binaries as the default.
59 ifeq ($(strip $(PREFERRED_BITS)),64)
60 CONFIGURE_BINDIR.32 ?= $(CONFIGURE_PREFIX)/bin/$(MACH32)
61 CONFIGURE_SBINDIR.32 ?= $(CONFIGURE_PREFIX)/sbin/$(MACH32)
62 CONFIGURE_LIBEXECDIR.32 ?= $(CONFIGURE_PREFIX)/libexec/$(MACH32)
63 CONFIGURE_BINDIR.64 ?= $(CONFIGURE_PREFIX)/bin
64 CONFIGURE_SBINDIR.64 ?= $(CONFIGURE_PREFIX)/sbin
65 CONFIGURE_LIBEXECDIR.64 ?= $(CONFIGURE_PREFIX)/libexec
66 else
67 CONFIGURE_BINDIR.32 ?= $(CONFIGURE_PREFIX)/bin
68 CONFIGURE_SBINDIR.32 ?= $(CONFIGURE_PREFIX)/sbin
69 CONFIGURE_LIBEXECDIR.32 ?= $(CONFIGURE_PREFIX)/libexec
70 CONFIGURE_BINDIR.64 ?= $(CONFIGURE_PREFIX)/bin/$(MACH64)
71 CONFIGURE_SBINDIR.64 ?= $(CONFIGURE_PREFIX)/sbin/$(MACH64)
72 CONFIGURE_LIBEXECDIR.64 ?= $(CONFIGURE_PREFIX)/libexec/$(MACH64)
73 endif
75 # Regardless of PREFERRED_BITS, 64-bit libraries should always be delivered to
76 # the appropriate subdirectory by default.
77 CONFIGURE_LIBDIR.32 ?= $(CONFIGURE_PREFIX)/lib
78 CONFIGURE_LIBDIR.64 ?= $(CONFIGURE_PREFIX)/lib/$(MACH64)
80 CONFIGURE_MANDIR ?= $(CONFIGURE_PREFIX)/share/man
81 CONFIGURE_LOCALEDIR ?= $(CONFIGURE_PREFIX)/share/locale
82 # all texinfo documentation seems to go to /usr/share/info no matter what
83 CONFIGURE_INFODIR ?= /usr/share/info
84 CONFIGURE_INCLUDEDIR ?= /usr/include
86 # Some components require an architecture-specific directory for their
87 # configuration, so these are specified per-bits.
88 CONFIGURE_ETCDIR.32 ?= $(ETCDIR)
89 CONFIGURE_ETCDIR.64 ?= $(ETCDIR)
91 CONFIGURE_DEFAULT_DIRS?=yes
93 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
94 CONFIGURE_ENV += PATH="$(PATH)"
95 CONFIGURE_ENV += CC="$(CC)"
96 CONFIGURE_ENV += CXX="$(CXX)"
97 CONFIGURE_ENV += F77="$(F77)"
98 CONFIGURE_ENV += FC="$(FC)"
99 ifneq ($(strip $(CFLAGS)),)
100 CONFIGURE_ENV += CFLAGS="$(strip $(CFLAGS))"
101 endif
102 ifneq ($(strip $(CXXFLAGS)),)
103 CONFIGURE_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
104 endif
105 CONFIGURE_CPPFLAGS ?= $(CC_BITS)
106 ifneq ($(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)),)
107 CONFIGURE_ENV += CPPFLAGS="$(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS))"
108 endif
109 CONFIGURE_ENV += LDFLAGS="$(strip $(LDFLAGS))"
110 ifneq ($(strip $(F77FLAGS)),)
111 CONFIGURE_ENV += FFLAGS="$(strip $(F77FLAGS))"
112 endif
113 ifneq ($(strip $(FCFLAGS)),)
114 CONFIGURE_ENV += FCFLAGS="$(strip $(FCFLAGS))"
115 endif
117 # Options here should be limited to the built-in options listed on
118 # https://mesonbuild.com/Builtin-options.html
119 CONFIGURE_OPTIONS += --buildtype=$(MESON_BUILDTYPE)
120 CONFIGURE_OPTIONS += --optimization=$(MESON_OPTIMIZATION)
121 CONFIGURE_OPTIONS += -Ddefault_library=shared
122 CONFIGURE_OPTIONS += -Db_pie=$(MESON_BUILDPIE)
123 CONFIGURE_OPTIONS += --wrap-mode=$(MESON_WRAPMODE)
125 # Install paths
126 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
127 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
128 CONFIGURE_OPTIONS += --bindir="$(CONFIGURE_BINDIR.$(BITS))"
129 CONFIGURE_OPTIONS += --sbindir="$(CONFIGURE_SBINDIR.$(BITS))"
130 CONFIGURE_OPTIONS += --libdir="$(CONFIGURE_LIBDIR.$(BITS))"
131 CONFIGURE_OPTIONS += --libexecdir="$(CONFIGURE_LIBEXECDIR.$(BITS))"
132 CONFIGURE_OPTIONS += --localstatedir="$(VARDIR)"
133 CONFIGURE_OPTIONS += --mandir="$(CONFIGURE_MANDIR)"
134 CONFIGURE_OPTIONS += --sysconfdir="$(CONFIGURE_ETCDIR.$(BITS))"
135 endif
136 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
137 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH))
138 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH).$(BITS))
140 $(BUILD_DIR_32)/.configured: BITS=32
141 $(BUILD_DIR_64)/.configured: BITS=64
143 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
145 # This MUST be set in the build environment so that if pkg-config is executed
146 # during the build process, the correct header files and libraries will be
147 # picked up. In the Linux world, a system is generally only 32-bit or 64-bit
148 # at one time so this isn't an issue that various auto* files account for (they
149 # don't set PKG_CONFIG_PATH when executing pkg-config even if it was specified
150 # during ./configure).
151 COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
153 MESON = /usr/bin/meson
155 # configure the unpacked source for building 32 and 64 bit version
156 # meson insists on separate source & build directories, so no cloney here.
157 $(BUILD_DIR)/%/.configured: $(SOURCE_DIR)/.prep
158 ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
159 $(COMPONENT_PRE_CONFIGURE_ACTION)
160 (cd $(SOURCE_DIR) ; $(ENV) $(CONFIGURE_ENV) $(MESON) setup $(@D) \
161 $(CONFIGURE_OPTIONS))
162 $(COMPONENT_POST_CONFIGURE_ACTION)
163 $(TOUCH) $@
165 # If BUILD_STYLE is set, provide a default configure target.
166 ifeq ($(strip $(BUILD_STYLE)),meson)
167 configure: $(CONFIGURE_$(MK_BITS))
168 endif
170 USERLAND_REQUIRED_PACKAGES += developer/build/meson
172 # Remove the empty line after the 'Summary of Failures:'
173 MESON_TEST_TRANSFORMS += "-e '/^Summary of Failures:/{n; N; D; }' | $(COMPONENT_TEST_TRANSFORMER)"
174 # Remove the list of failed tests so we do not see failed tests twice
175 MESON_TEST_TRANSFORMS += "-e '/^Summary of Failures:/,/^\$$/d'"
176 # By default ignore all lines
177 MESON_TEST_TRANSFORMS += "-n"
178 # Print individual test results with removed test number and timing
179 MESON_TEST_TRANSFORMS += "-e '/^ *[0-9]\{1,\}\/[0-9]\{1,\} /{s///; s/ \{1,\}[0-9]*[0-9]\.[0-9][0-9]s//; p; }'"
180 # Print the test summary too
181 MESON_TEST_TRANSFORMS += "-e '/^Ok:/,/^\$$/p'"
182 # Add back the empty line before the test summary
183 MESON_TEST_TRANSFORMS += "| $(COMPONENT_TEST_TRANSFORMER) -e '/^Ok:/{H; x; }'"
184 # Sort test results
185 MESON_TEST_TRANSFORMS += "| ( \
186 $(GSED) -u -e '/^\$$/Q' | $(SORT) | $(COMPONENT_TEST_TRANSFORMER) -e '\$$G' ; \
187 $(CAT) \
188 ) | $(COMPONENT_TEST_TRANSFORMER) -e ''"
190 USE_DEFAULT_TEST_TRANSFORMS?=no
191 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes)
192 COMPONENT_TEST_TRANSFORMS+= $(MESON_TEST_TRANSFORMS)
193 endif
195 # Meson generates build.ninja files for the ninja build tool to run,
196 # so we include ninja.mk for the build/install/test rules
198 include $(WS_MAKE_RULES)/ninja.mk