fritzkink
2023-12-15 9329acaef0fff79c242edf766ac84544d6422be8
commit | author | age
41e750 1 #
AP 2 # CDDL HEADER START
3 #
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.
7 #
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.
12 #
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]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
24 #
25
26 #
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
30 #
31 # To use these rules in your component Makefile, set BUILD_STYLE=meson and
32 # then include $(WS_MAKE_RULES)/common.mk. 
33 #
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
37 #
38
39 CONFIGURE_PREFIX ?=    /usr
40
41 # When debugging a component, override this to be debug or debugoptimized
42 MESON_BUILDTYPE ?=    plain
43
44 ifeq ($(strip $(MESON_BUILDTYPE)), debug)
45 MESON_OPTIMIZATION ?=    g
46 else
47 MESON_OPTIMIZATION ?=    3
48 endif
49
f640fc 50 MESON_BUILDPIE ?=    false
41e750 51
AP 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_BINDIR.64 ?=    $(CONFIGURE_PREFIX)/bin
60 CONFIGURE_SBINDIR.64 ?=    $(CONFIGURE_PREFIX)/sbin
61 else
62 CONFIGURE_BINDIR.32 ?=    $(CONFIGURE_PREFIX)/bin
63 CONFIGURE_SBINDIR.32 ?=    $(CONFIGURE_PREFIX)/sbin
64 CONFIGURE_BINDIR.64 ?=    $(CONFIGURE_PREFIX)/bin/$(MACH64)
65 CONFIGURE_SBINDIR.64 ?=    $(CONFIGURE_PREFIX)/sbin/$(MACH64)
66 endif
67
68 # Regardless of PREFERRED_BITS, 64-bit libraries should always be delivered to
69 # the appropriate subdirectory by default.
70 CONFIGURE_LIBDIR.32 ?=    $(CONFIGURE_PREFIX)/lib
71 CONFIGURE_LIBDIR.64 ?=    $(CONFIGURE_PREFIX)/lib/$(MACH64)
72
73 CONFIGURE_MANDIR ?=    $(CONFIGURE_PREFIX)/share/man
74 CONFIGURE_LOCALEDIR ?=    $(CONFIGURE_PREFIX)/share/locale
75 # all texinfo documentation seems to go to /usr/share/info no matter what
76 CONFIGURE_INFODIR ?=    /usr/share/info
77 CONFIGURE_INCLUDEDIR ?=    /usr/include
78
79 # Some components require an architecture-specific directory for their
80 # configuration, so these are specified per-bits.
81 CONFIGURE_ETCDIR.32 ?= $(ETCDIR)
82 CONFIGURE_ETCDIR.64 ?= $(ETCDIR)
83
84 CONFIGURE_DEFAULT_DIRS?=yes
85
86 CONFIGURE_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
c4dd49 87 CONFIGURE_ENV += PATH="$(PATH)"
41e750 88 CONFIGURE_ENV += CC="$(CC)"
AP 89 CONFIGURE_ENV += CXX="$(CXX)"
90 CONFIGURE_ENV += F77="$(F77)"
91 CONFIGURE_ENV += FC="$(FC)"
92 ifneq ($(strip $(CFLAGS)),)
93 CONFIGURE_ENV += CFLAGS="$(strip $(CFLAGS))"
94 endif
95 ifneq ($(strip $(CXXFLAGS)),)
96 CONFIGURE_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
97 endif
98 CONFIGURE_CPPFLAGS ?= $(CC_BITS)
99 ifneq  ($(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)),)
100 CONFIGURE_ENV += CPPFLAGS="$(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS))"
101 endif
102 CONFIGURE_ENV += LDFLAGS="$(strip $(LDFLAGS))"
103 ifneq ($(strip $(F77FLAGS)),)
104 CONFIGURE_ENV += FFLAGS="$(strip $(F77FLAGS))"
105 endif
106 ifneq ($(strip $(FCFLAGS)),)
107 CONFIGURE_ENV += FCFLAGS="$(strip $(FCFLAGS))"
108 endif
109
110 # Options here should be limited to the built-in options listed on
111 # https://mesonbuild.com/Builtin-options.html
112 CONFIGURE_OPTIONS += --buildtype=$(MESON_BUILDTYPE)
113 CONFIGURE_OPTIONS += --optimization=$(MESON_OPTIMIZATION)
114 CONFIGURE_OPTIONS += -Ddefault_library=shared
115 CONFIGURE_OPTIONS += -Db_pie=$(MESON_BUILDPIE)
116
117 # Install paths
118 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
119 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
120 CONFIGURE_OPTIONS += --bindir="$(CONFIGURE_BINDIR.$(BITS))"
121 CONFIGURE_OPTIONS += --sbindir="$(CONFIGURE_SBINDIR.$(BITS))"
122 CONFIGURE_OPTIONS += --libdir="$(CONFIGURE_LIBDIR.$(BITS))"
123 CONFIGURE_OPTIONS += --libexecdir="$(CONFIGURE_LIBDIR.32)"
124 CONFIGURE_OPTIONS += --localstatedir="$(VARDIR)"
125 CONFIGURE_OPTIONS += --mandir="$(CONFIGURE_MANDIR)"
126 CONFIGURE_OPTIONS += --sysconfdir="$(CONFIGURE_ETCDIR.$(BITS))"
127 endif
128 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
129 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH))
130 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH).$(BITS))
131
132 $(BUILD_DIR_32)/.configured:    BITS=32
133 $(BUILD_DIR_64)/.configured:    BITS=64
134
135 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
136
137 # This MUST be set in the build environment so that if pkg-config is executed
138 # during the build process, the correct header files and libraries will be
139 # picked up.  In the Linux world, a system is generally only 32-bit or 64-bit
140 # at one time so this isn't an issue that various auto* files account for (they
141 # don't set PKG_CONFIG_PATH when executing pkg-config even if it was specified
142 # during ./configure).
143 COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
144
145 MESON =     /usr/bin/meson
146
147 # configure the unpacked source for building 32 and 64 bit version
148 # meson insists on separate source & build directories, so no cloney here.
149 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
150     ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
151     $(COMPONENT_PRE_CONFIGURE_ACTION)
152     (cd $(SOURCE_DIR) ; $(ENV) $(CONFIGURE_ENV) $(MESON) setup $(@D) \
153         $(CONFIGURE_OPTIONS))
154     $(COMPONENT_POST_CONFIGURE_ACTION)
155     $(TOUCH) $@
156
157 # If BUILD_STYLE is set, provide a default configure target.
158 ifeq   ($(strip $(BUILD_STYLE)),meson)
159 configure:    $(CONFIGURE_$(MK_BITS))
160 endif
161
8203c7 162 USERLAND_REQUIRED_PACKAGES += developer/build/meson
41e750 163
5dbee7 164 MESON_TEST_TRANSFORMS = \
AW 165     '-n ' \
166     '-e "/Ok:/p" ' \
167     '-e "/Fail:/p" ' \
168     '-e "/Pass:/p" ' \
169     '-e "/Skipped:/p" ' \
170     '-e "/Timeout:/p" '
171
172 USE_DEFAULT_TEST_TRANSFORMS?=no
173 ifeq ($(strip $(USE_DEFAULT_TEST_TRANSFORMS)),yes)
174 COMPONENT_TEST_TRANSFORMS+= $(MESON_TEST_TRANSFORMS)
175 endif
176
41e750 177 # Meson generates build.ninja files for the ninja build tool to run,
AP 178 # so we include ninja.mk for the build/install/test rules
179
180 include $(WS_MAKE_RULES)/ninja.mk