uwimap: switch to openssl 3.1
[oi-userland.git] / make-rules / meson.mk
blob98261592b3902ad4755212d3111c028ce4084afa
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 # If the component prefers 64-bit binaries, then ensure builds deliver 64-bit
53 # binaries to the standard directories and 32-bit binaries to the non-standard
54 # location. This allows simplification of package manifests and makes it
55 # easier to deliver the 64-bit binaries as the default.
56 ifeq ($(strip $(PREFERRED_BITS)),64)
57 CONFIGURE_BINDIR.32 ?= $(CONFIGURE_PREFIX)/bin/$(MACH32)
58 CONFIGURE_SBINDIR.32 ?= $(CONFIGURE_PREFIX)/sbin/$(MACH32)
59 CONFIGURE_LIBEXECDIR.32 ?= $(CONFIGURE_PREFIX)/libexec/$(MACH32)
60 CONFIGURE_BINDIR.64 ?= $(CONFIGURE_PREFIX)/bin
61 CONFIGURE_SBINDIR.64 ?= $(CONFIGURE_PREFIX)/sbin
62 CONFIGURE_LIBEXECDIR.64 ?= $(CONFIGURE_PREFIX)/libexec
63 else
64 CONFIGURE_BINDIR.32 ?= $(CONFIGURE_PREFIX)/bin
65 CONFIGURE_SBINDIR.32 ?= $(CONFIGURE_PREFIX)/sbin
66 CONFIGURE_LIBEXECDIR.32 ?= $(CONFIGURE_PREFIX)/libexec
67 CONFIGURE_BINDIR.64 ?= $(CONFIGURE_PREFIX)/bin/$(MACH64)
68 CONFIGURE_SBINDIR.64 ?= $(CONFIGURE_PREFIX)/sbin/$(MACH64)
69 CONFIGURE_LIBEXECDIR.64 ?= $(CONFIGURE_PREFIX)/libexec/$(MACH64)
70 endif
72 # Regardless of PREFERRED_BITS, 64-bit libraries should always be delivered to
73 # the appropriate subdirectory by default.
74 CONFIGURE_LIBDIR.32 ?= $(CONFIGURE_PREFIX)/lib
75 CONFIGURE_LIBDIR.64 ?= $(CONFIGURE_PREFIX)/lib/$(MACH64)
77 CONFIGURE_MANDIR ?= $(CONFIGURE_PREFIX)/share/man
78 CONFIGURE_LOCALEDIR ?= $(CONFIGURE_PREFIX)/share/locale
79 # all texinfo documentation seems to go to /usr/share/info no matter what
80 CONFIGURE_INFODIR ?= /usr/share/info
81 CONFIGURE_INCLUDEDIR ?= /usr/include
83 # Some components require an architecture-specific directory for their
84 # configuration, so these are specified per-bits.
85 CONFIGURE_ETCDIR.32 ?= $(ETCDIR)
86 CONFIGURE_ETCDIR.64 ?= $(ETCDIR)
88 CONFIGURE_DEFAULT_DIRS?=yes
90 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
91 CONFIGURE_ENV += PATH="$(PATH)"
92 CONFIGURE_ENV += CC="$(CC)"
93 CONFIGURE_ENV += CXX="$(CXX)"
94 CONFIGURE_ENV += F77="$(F77)"
95 CONFIGURE_ENV += FC="$(FC)"
96 ifneq ($(strip $(CFLAGS)),)
97 CONFIGURE_ENV += CFLAGS="$(strip $(CFLAGS))"
98 endif
99 ifneq ($(strip $(CXXFLAGS)),)
100 CONFIGURE_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
101 endif
102 CONFIGURE_CPPFLAGS ?= $(CC_BITS)
103 ifneq ($(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)),)
104 CONFIGURE_ENV += CPPFLAGS="$(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS))"
105 endif
106 CONFIGURE_ENV += LDFLAGS="$(strip $(LDFLAGS))"
107 ifneq ($(strip $(F77FLAGS)),)
108 CONFIGURE_ENV += FFLAGS="$(strip $(F77FLAGS))"
109 endif
110 ifneq ($(strip $(FCFLAGS)),)
111 CONFIGURE_ENV += FCFLAGS="$(strip $(FCFLAGS))"
112 endif
114 # Options here should be limited to the built-in options listed on
115 # https://mesonbuild.com/Builtin-options.html
116 CONFIGURE_OPTIONS += --buildtype=$(MESON_BUILDTYPE)
117 CONFIGURE_OPTIONS += --optimization=$(MESON_OPTIMIZATION)
118 CONFIGURE_OPTIONS += -Ddefault_library=shared
119 CONFIGURE_OPTIONS += -Db_pie=$(MESON_BUILDPIE)
121 # Install paths
122 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
123 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
124 CONFIGURE_OPTIONS += --bindir="$(CONFIGURE_BINDIR.$(BITS))"
125 CONFIGURE_OPTIONS += --sbindir="$(CONFIGURE_SBINDIR.$(BITS))"
126 CONFIGURE_OPTIONS += --libdir="$(CONFIGURE_LIBDIR.$(BITS))"
127 CONFIGURE_OPTIONS += --libexecdir="$(CONFIGURE_LIBEXECDIR.$(BITS))"
128 CONFIGURE_OPTIONS += --localstatedir="$(VARDIR)"
129 CONFIGURE_OPTIONS += --mandir="$(CONFIGURE_MANDIR)"
130 CONFIGURE_OPTIONS += --sysconfdir="$(CONFIGURE_ETCDIR.$(BITS))"
131 endif
132 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
133 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH))
134 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH).$(BITS))
136 $(BUILD_DIR_32)/.configured: BITS=32
137 $(BUILD_DIR_64)/.configured: BITS=64
139 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
141 # This MUST be set in the build environment so that if pkg-config is executed
142 # during the build process, the correct header files and libraries will be
143 # picked up. In the Linux world, a system is generally only 32-bit or 64-bit
144 # at one time so this isn't an issue that various auto* files account for (they
145 # don't set PKG_CONFIG_PATH when executing pkg-config even if it was specified
146 # during ./configure).
147 COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
149 MESON = /usr/bin/meson
151 # configure the unpacked source for building 32 and 64 bit version
152 # meson insists on separate source & build directories, so no cloney here.
153 $(BUILD_DIR)/%/.configured: $(SOURCE_DIR)/.prep
154 ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
155 $(COMPONENT_PRE_CONFIGURE_ACTION)
156 (cd $(SOURCE_DIR) ; $(ENV) $(CONFIGURE_ENV) $(MESON) setup $(@D) \
157 $(CONFIGURE_OPTIONS))
158 $(COMPONENT_POST_CONFIGURE_ACTION)
159 $(TOUCH) $@
161 # If BUILD_STYLE is set, provide a default configure target.
162 ifeq ($(strip $(BUILD_STYLE)),meson)
163 configure: $(CONFIGURE_$(MK_BITS))
164 endif
166 USERLAND_REQUIRED_PACKAGES += developer/build/meson
168 MESON_TEST_TRANSFORMS = \
169 '-n ' \
170 '-e "/Ok:/p" ' \
171 '-e "/Fail:/p" ' \
172 '-e "/Pass:/p" ' \
173 '-e "/Skipped:/p" ' \
174 '-e "/Timeout:/p" '
176 USE_DEFAULT_TEST_TRANSFORMS?=no
177 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes)
178 COMPONENT_TEST_TRANSFORMS+= $(MESON_TEST_TRANSFORMS)
179 endif
181 # Meson generates build.ninja files for the ninja build tool to run,
182 # so we include ninja.mk for the build/install/test rules
184 include $(WS_MAKE_RULES)/ninja.mk