klausz65
2023-02-01 f4cc225e7020d01f93b2d734e295adaa87b9176e
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
f4cc22 50 MESON_BUILDPIE ?=    true
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)"
87 CONFIGURE_ENV += CC="$(CC)"
88 CONFIGURE_ENV += CXX="$(CXX)"
89 CONFIGURE_ENV += F77="$(F77)"
90 CONFIGURE_ENV += FC="$(FC)"
91 ifneq ($(strip $(CFLAGS)),)
92 CONFIGURE_ENV += CFLAGS="$(strip $(CFLAGS))"
93 endif
94 ifneq ($(strip $(CXXFLAGS)),)
95 CONFIGURE_ENV += CXXFLAGS="$(strip $(CXXFLAGS))"
96 endif
97 CONFIGURE_CPPFLAGS ?= $(CC_BITS)
98 ifneq  ($(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)),)
99 CONFIGURE_ENV += CPPFLAGS="$(strip $(CONFIGURE_CPPFLAGS) $(CPPFLAGS))"
100 endif
101 CONFIGURE_ENV += LDFLAGS="$(strip $(LDFLAGS))"
102 ifneq ($(strip $(F77FLAGS)),)
103 CONFIGURE_ENV += FFLAGS="$(strip $(F77FLAGS))"
104 endif
105 ifneq ($(strip $(FCFLAGS)),)
106 CONFIGURE_ENV += FCFLAGS="$(strip $(FCFLAGS))"
107 endif
108
109 # Options here should be limited to the built-in options listed on
110 # https://mesonbuild.com/Builtin-options.html
111 CONFIGURE_OPTIONS += --buildtype=$(MESON_BUILDTYPE)
112 CONFIGURE_OPTIONS += --optimization=$(MESON_OPTIMIZATION)
113 CONFIGURE_OPTIONS += -Ddefault_library=shared
114 CONFIGURE_OPTIONS += -Db_pie=$(MESON_BUILDPIE)
115
116 # Install paths
117 CONFIGURE_OPTIONS += --prefix=$(CONFIGURE_PREFIX)
118 ifeq ($(CONFIGURE_DEFAULT_DIRS),yes)
119 CONFIGURE_OPTIONS += --bindir="$(CONFIGURE_BINDIR.$(BITS))"
120 CONFIGURE_OPTIONS += --sbindir="$(CONFIGURE_SBINDIR.$(BITS))"
121 CONFIGURE_OPTIONS += --libdir="$(CONFIGURE_LIBDIR.$(BITS))"
122 CONFIGURE_OPTIONS += --libexecdir="$(CONFIGURE_LIBDIR.32)"
123 CONFIGURE_OPTIONS += --localstatedir="$(VARDIR)"
124 CONFIGURE_OPTIONS += --mandir="$(CONFIGURE_MANDIR)"
125 CONFIGURE_OPTIONS += --sysconfdir="$(CONFIGURE_ETCDIR.$(BITS))"
126 endif
127 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(BITS))
128 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH))
129 CONFIGURE_OPTIONS += $(CONFIGURE_OPTIONS.$(MACH).$(BITS))
130
131 $(BUILD_DIR_32)/.configured:    BITS=32
132 $(BUILD_DIR_64)/.configured:    BITS=64
133
134 CONFIGURE_ENV += $(CONFIGURE_ENV.$(BITS))
135
136 # This MUST be set in the build environment so that if pkg-config is executed
137 # during the build process, the correct header files and libraries will be
138 # picked up.  In the Linux world, a system is generally only 32-bit or 64-bit
139 # at one time so this isn't an issue that various auto* files account for (they
140 # don't set PKG_CONFIG_PATH when executing pkg-config even if it was specified
141 # during ./configure).
142 COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
143
144 MESON =     /usr/bin/meson
145
146 # configure the unpacked source for building 32 and 64 bit version
147 # meson insists on separate source & build directories, so no cloney here.
148 $(BUILD_DIR)/%/.configured:    $(SOURCE_DIR)/.prep
149     ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
150     $(COMPONENT_PRE_CONFIGURE_ACTION)
151     (cd $(SOURCE_DIR) ; $(ENV) $(CONFIGURE_ENV) $(MESON) setup $(@D) \
152         $(CONFIGURE_OPTIONS))
153     $(COMPONENT_POST_CONFIGURE_ACTION)
154     $(TOUCH) $@
155
156 # If BUILD_STYLE is set, provide a default configure target.
157 ifeq   ($(strip $(BUILD_STYLE)),meson)
158 configure:    $(CONFIGURE_$(MK_BITS))
159 endif
160
161 REQUIRED_PACKAGES += developer/build/meson
162
163 # Meson generates build.ninja files for the ninja build tool to run,
164 # so we include ninja.mk for the build/install/test rules
165
166 include $(WS_MAKE_RULES)/ninja.mk