Skip to contentSkip to conversation

meson: add per package optional compiler/linker flags

PATCH New Peter Seiderer 4 participants 8 messages Apr 23, 2019 – Jun 25, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 meson: add per package optional compiler/linker flags

Add LIBFOO_MESON_CFLAGS, LIBFOO_MESON_LDFLAGS and LIBFOO_MESON_CXXFLAGS variables to allow per package additional compiler/linker flags.

---
Changes v5 -> v6:
- add documentation for the new meson flags variables

Changes v4 -> v5:
- no changes

Changes v4:
- new patch (base on the original '[RFC v3 2/4] meson: change from global to per package cross-compilation.conf', see [1])

[1] http://lists.busybox.net/pipermail/buildroot/2018-July/226313.html

---
 docs/manual/adding-packages-meson.txt   | 12 ++++++++++++
 package/meson/cross-compilation.conf.in |  8 ++++----
 package/meson/meson.mk                  |  3 +++
 package/pkg-meson.mk                    |  7 +++++++
 4 files changed, 26 insertions(+), 4 deletions(-)
docs/manual/adding-packages-meson.txt +12 -0
index 30c338f486..dbc22d3a7f 100644
@@ -97,6 +97,18 @@ will therefore only use a few of them.
 * +FOO_CONF_OPTS+, to specify additional options to pass to +meson+ for the
   configuration step. By default, empty.
 
+* +FOO_MESON_CFLAGS+, to specify additional compiler arguments added to
+  the package specific +cross-compile.conf+ file +c_args+ property.  By
+  default, empty.
+
+* +FOO_MESON_CXXFLAGS+, to specify additional compiler arguments added to
+  the package specific +cross-compile.conf+ file +cpp_args+ property. By
+  default, empty.
+
+* +FOO_MESON_LDFLAGS+, to specify additional compiler arguments added to
+  the package specific +cross-compile.conf+ file +c_link_args+ and
+  +cpp_link_args+ properties.  By default, empty.
+
 * +FOO_NINJA_ENV+, to specify additional environment variables to pass to
   +ninja+, meson companion tool in charge of the build operations. By default,
   empty.
package/meson/cross-compilation.conf.in +4 -4
index fc8e27f7eb..4056c2b2f4 100644
@@ -12,10 +12,10 @@ pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
 needs_exe_wrapper = true
-c_args = [@TARGET_CFLAGS@]
-c_link_args = [@TARGET_LDFLAGS@]
-cpp_args = [@TARGET_CXXFLAGS@]
-cpp_link_args = [@TARGET_LDFLAGS@]
+c_args = [@TARGET_CFLAGS@@PKG_TARGET_CFLAGS@]
+c_link_args = [@TARGET_LDFLAGS@@PKG_TARGET_LDFLAGS@]
+cpp_args = [@TARGET_CXXFLAGS@@PKG_TARGET_CXXFLAGS@]
+cpp_link_args = [@TARGET_LDFLAGS@@PKG_TARGET_LDFLAGS@]
 
 [host_machine]
 system = 'linux'
package/meson/meson.mk +3 -0
index 49e27f5527..70128f6bad 100644
@@ -60,6 +60,9 @@ define HOST_MESON_INSTALL_CROSS_CONF
 	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
 	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
 	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
package/pkg-meson.mk +7 -0
index 886fcf7205..9974b1e513 100644
@@ -57,6 +57,10 @@ $(2)_NINJA_ENV		?=
 ifndef $(2)_CONFIGURE_CMDS
 ifeq ($(4),target)
 
+$(2)_MESON_SED_CFLAGS = $(if $($(2)_MESON_CFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_CFLAGS)`)
+$(2)_MESON_SED_LDFLAGS = $(if $($(2)_MESON_LDFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_LDFLAGS)`)
+$(2)_MESON_SED_CXXFLAGS = $(if $($(2)_MESON_CXXFLAGS),`printf '"%s"$(comma) ' $$($$(2)_MESON_CXXFLAGS)`)
+
 # Configure package for target
 #
 #
@@ -70,6 +74,9 @@ define $(2)_CONFIGURE_CMDS
 	    -e "s%@TARGET_CFLAGS@%$$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CFLAGS@%$$($$(PKG)_MESON_SED_CFLAGS)%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%$$($$(PKG)_MESON_SED_LDFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%$$($$(PKG)_MESON_SED_CXXFLAGS)%g" \
 	    -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
 	    package/meson/cross-compilation.conf.in \
 	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf

--
2.21.0

#1 lore raw

PATCH v6 2/2 libdrm: change to meson build system

- remove legacy patch 0003-configure-Makefile.am-use-pkg-config-to-discover-lib.patch

- add patch to fix meson atomic ops detection 0003-meson.build-fix-intel-atomics-detection.patch

- add patch to enable static build
0004-meson.build-enable-static-build.patch

---
Notes:
- convertion from "LIBDRM_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'" is missing (maybe meson gets it right (?) or use LIBDRM_MESON_CFLAGS to force it)

Changes v5 -> v6:
- no changes

Changes v4 -> v5:
- fix sparc LIBDRM_MESON_CFLAGS, remove extra quotation marks and comma

Changes v3 -> v4:
- rebased on current master (suggested by Thomas Petazzoni)

Changes v2 -> v3:
- fix 0003-meson.build-fix-intel-atomics-detection.patch (linking needs main)
- add 0004-meson.build-enable-static-build.patch to enable static compile

Changes v1 -> v2:
- add 0003-meson.build-fix-intel-atomics-detection.patch to fix sparc compile

---
 ...le.am-use-pkg-config-to-discover-lib.patch | 162 -----------------
 ...on.build-fix-intel-atomics-detection.patch |  35 ++++
 ...0004-meson.build-enable-static-build.patch | 169 ++++++++++++++++++
 package/libdrm/libdrm.mk                      |  71 ++++----
 4 files changed, 236 insertions(+), 201 deletions(-)
 delete mode 100644 package/libdrm/0003-configure-Makefile.am-use-pkg-config-to-discover-lib.patch
 create mode 100644 package/libdrm/0003-meson.build-fix-intel-atomics-detection.patch
 create mode 100644 package/libdrm/0004-meson.build-enable-static-build.patch
package/libdrm/0003-configure-Makefile.am-use-pkg-config-to-discover-lib.patch deleted +0 -162
deleted file mode 100644
index 0fbe77ef7c..0000000000
@@ -1,162 +0,0 @@
-From 57d544ff2f96a26cac07d5be00ff7b67678ae7b8 Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <[email protected]>
-Date: Mon, 18 Dec 2017 13:08:39 +0100
-Subject: [PATCH] configure/Makefile.am: use pkg-config to discover
- libatomic_ops
-
-The configure script currently tests the availability of libatomic_ops
-by checking the presence of atomic_ops.h. While this is good enough as
-an availability test, it is not sufficient as on some platforms,
-libatomic_ops provides an actual shared library against which we
-should be linked to access libatomic_ops functionality.
-
-Therefore, we instead use PKG_CHECK_MODULES() to test the availability
-of libatomic_ops. Besides testing its availability, this also fills in
-the ATOMIC_OPS_LIBS variable with the list of libraries we need to
-link with to use libatomic_ops.
-
-All Mesa drivers that include xf86atomic.h have been updated to link
-against ATOMIC_OPS_LIBS.
-
-Of course, if we're not using libatomic_ops, ATOMIC_OPS_LIBS is empty,
-and we don't link against it.
-
-Signed-off-by: Thomas Petazzoni <[email protected]>
-Signed-off-by: Peter Seiderer <[email protected]>
-[Bernd: PKG_CHECK_MODULES should not fail when libatomic_ops is missing]
-Signed-off-by: Bernd Kuhls <[email protected]>
----
- amdgpu/Makefile.am    | 2 +-
- configure.ac          | 2 +-
- etnaviv/Makefile.am   | 3 ++-
- freedreno/Makefile.am | 3 ++-
- intel/Makefile.am     | 3 ++-
- nouveau/Makefile.am   | 2 +-
- omap/Makefile.am      | 2 +-
- radeon/Makefile.am    | 2 +-
- tegra/Makefile.am     | 2 +-
- 9 files changed, 12 insertions(+), 9 deletions(-)
-
-diff --git a/amdgpu/Makefile.am b/amdgpu/Makefile.am
-index a1b0d05c..b2bcceff 100644
---- a/amdgpu/Makefile.am
-+++ b/amdgpu/Makefile.am
-@@ -36,7 +36,7 @@ AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\"
- libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
- libdrm_amdgpu_ladir = $(libdir)
- libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
--libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-+libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
-
- libdrm_amdgpu_la_SOURCES = $(LIBDRM_AMDGPU_FILES)
- amdgpu_asic_id.lo: $(top_srcdir)/data/amdgpu.ids
-diff --git a/configure.ac b/configure.ac
-index 35378b33..501d0871 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -247,7 +247,7 @@ AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [
- 					  ]],[[]])], [drm_cv_atomic_primitives="Intel"],[])
-
- 	if test "x$drm_cv_atomic_primitives" = "xnone"; then
--		AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops")
-+		PKG_CHECK_MODULES(ATOMIC_OPS, [atomic_ops], drm_cv_atomic_primitives="libatomic-ops", true)
- 	fi
-
- 	# atomic functions defined in <atomic.h> & libc on Solaris
-diff --git a/etnaviv/Makefile.am b/etnaviv/Makefile.am
-index be96ba86..669cf14f 100644
---- a/etnaviv/Makefile.am
-+++ b/etnaviv/Makefile.am
-@@ -12,7 +12,8 @@ libdrm_etnaviv_la_LDFLAGS = -version-number 1:0:0 -no-undefined
- libdrm_etnaviv_la_LIBADD = \
- 	../libdrm.la \
- 	@PTHREADSTUBS_LIBS@ \
--	@CLOCK_LIB@
-+	@CLOCK_LIB@ \
-+	@ATOMIC_OPS_LIBS@
-
- libdrm_etnaviv_la_SOURCES = $(LIBDRM_ETNAVIV_FILES)
-
-diff --git a/freedreno/Makefile.am b/freedreno/Makefile.am
-index cbb0d031..238407e3 100644
---- a/freedreno/Makefile.am
-+++ b/freedreno/Makefile.am
-@@ -14,7 +14,8 @@ libdrm_freedreno_la_LDFLAGS = -version-number 1:0:0 -no-undefined
- libdrm_freedreno_la_LIBADD = \
- 	../libdrm.la \
- 	@PTHREADSTUBS_LIBS@ \
--	@CLOCK_LIB@
-+	@CLOCK_LIB@ \
-+	@ATOMIC_OPS_LIBS@
-
- libdrm_freedreno_la_SOURCES = $(LIBDRM_FREEDRENO_FILES)
- if HAVE_FREEDRENO_KGSL
-diff --git a/intel/Makefile.am b/intel/Makefile.am
-index c52e8c08..f3635a64 100644
---- a/intel/Makefile.am
-+++ b/intel/Makefile.am
-@@ -38,7 +38,8 @@ libdrm_intel_la_LDFLAGS = -version-number 1:0:0 -no-undefined
- libdrm_intel_la_LIBADD = ../libdrm.la \
- 	@PTHREADSTUBS_LIBS@ \
- 	@PCIACCESS_LIBS@ \
--	@CLOCK_LIB@
-+	@CLOCK_LIB@ \
-+	@ATOMIC_OPS_LIBS@
-
- libdrm_intel_la_SOURCES = $(LIBDRM_INTEL_FILES)
-
-diff --git a/nouveau/Makefile.am b/nouveau/Makefile.am
-index 344a8445..a4e6a78b 100644
---- a/nouveau/Makefile.am
-+++ b/nouveau/Makefile.am
-@@ -10,7 +10,7 @@ AM_CFLAGS = \
- libdrm_nouveau_la_LTLIBRARIES = libdrm_nouveau.la
- libdrm_nouveau_ladir = $(libdir)
- libdrm_nouveau_la_LDFLAGS = -version-number 2:0:0 -no-undefined
--libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-+libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
-
- libdrm_nouveau_la_SOURCES = $(LIBDRM_NOUVEAU_FILES)
-
-diff --git a/omap/Makefile.am b/omap/Makefile.am
-index 599bb9de..524afee3 100644
---- a/omap/Makefile.am
-+++ b/omap/Makefile.am
-@@ -7,7 +7,7 @@ AM_CFLAGS = \
- libdrm_omap_la_LTLIBRARIES = libdrm_omap.la
- libdrm_omap_ladir = $(libdir)
- libdrm_omap_la_LDFLAGS = -version-number 1:0:0 -no-undefined
--libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-+libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
-
- libdrm_omap_la_SOURCES = omap_drm.c
-
-diff --git a/radeon/Makefile.am b/radeon/Makefile.am
-index e2415314..c27d3c75 100644
---- a/radeon/Makefile.am
-+++ b/radeon/Makefile.am
-@@ -33,7 +33,7 @@ AM_CFLAGS = \
- libdrm_radeon_la_LTLIBRARIES = libdrm_radeon.la
- libdrm_radeon_ladir = $(libdir)
- libdrm_radeon_la_LDFLAGS = -version-number 1:0:1 -no-undefined
--libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-+libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
-
- libdrm_radeon_la_SOURCES = $(LIBDRM_RADEON_FILES)
-
-diff --git a/tegra/Makefile.am b/tegra/Makefile.am
-index fb40be55..12abe8c4 100644
---- a/tegra/Makefile.am
-+++ b/tegra/Makefile.am
-@@ -9,7 +9,7 @@ AM_CFLAGS = \
- libdrm_tegra_ladir = $(libdir)
- libdrm_tegra_la_LTLIBRARIES = libdrm_tegra.la
- libdrm_tegra_la_LDFLAGS = -version-number 0:0:0 -no-undefined
--libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-+libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
-
- libdrm_tegra_la_SOURCES = \
- 	private.h \
---
-2.14.3
-
package/libdrm/0003-meson.build-fix-intel-atomics-detection.patch new file +35 -0
new file mode 100644
index 0000000000..fe02328f3a
@@ -0,0 +1,35 @@
+From 00f6ac3c24f36fa07fa93f4a89ee873edf125098 Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <[email protected]>
+Date: Mon, 16 Jul 2018 23:01:40 +0200
+Subject: [PATCH] meson.build: fix intel atomics detection
+
+Use the stronger compiler.link() test (instead of the weaker
+compiler.compile()) to fix the intel atomics detection.
+
+Fixes false positive in case of sparc compile (buildroot toolchain).
+
+Upstream suggested: https://lists.freedesktop.org/archives/dri-devel/2018-July/183885.html
+Signed-off-by: Peter Seiderer <[email protected]>
+---
+ meson.build | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 9b443a5..3c8afb6 100644
+--- a/meson.build
++++ b/meson.build
+@@ -49,9 +49,10 @@ intel_atomics = false
+ lib_atomics = false
+
+ dep_atomic_ops = dependency('atomic_ops', required : false)
+-if cc.compiles('''
++if cc.links('''
+     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
+     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
++    int main() { }
+     ''',
+     name : 'Intel Atomics')
+   intel_atomics = true
+--
+2.18.0
+
package/libdrm/0004-meson.build-enable-static-build.patch new file +169 -0

169 lines not on this page · raw message

package/libdrm/libdrm.mk +32 -39

146 lines not on this page · raw message

--
2.21.0

#2 lore raw

PATCH v6 2/2 libdrm: change to meson build system

Peter, All,

On 2019-04-23 22:53 +0200, Peter Seiderer spake thusly:
[--SNIP--]

package/libdrm/libdrm.mk

Quoted 4 lines
package/libdrm/libdrm.mk +0 -0
index cc7350c10e..77e7ad01bd 100644

[--SNIP--]

package/libdrm/libdrm.mk LIBDRM_SITE = https://dri.freedesktop.org/libdrm · line 24

Quoted 5 lines

ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y)
LIBDRM_DEPENDENCIES += libatomic_ops
ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)

package/libdrm/libdrm.mk +1 -1
-LIBDRM_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DAO_NO_SPARC_V9"
+LIBDRM_MESON_CFLAGS += -DAO_NO_SPARC_V9

As discussed in the thread, the variable was renamed.

I've resent a new iteration of the meson-package part as a standalone patch:

    https://patchwork.ozlabs.org/patch/1120719/

As such, I've marked this thread as Changes requested.

Care to resend this libdrm bump+conversion once the meson infra part lands?

Thanks! :-)

Regards,
Yann E. MORIN.

Quoted 127 lines

endif
endif

ifeq ($(BR2_PACKAGE_LIBDRM_INTEL),y)

package/libdrm/libdrm.mk +28 -29
-LIBDRM_CONF_OPTS += --enable-intel
+LIBDRM_CONF_OPTS += -Dintel=true
 LIBDRM_DEPENDENCIES += libpciaccess
 else
-LIBDRM_CONF_OPTS += --disable-intel
+LIBDRM_CONF_OPTS += -Dintel=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_RADEON),y)
-LIBDRM_CONF_OPTS += --enable-radeon
+LIBDRM_CONF_OPTS += -Dradeon=true
 else
-LIBDRM_CONF_OPTS += --disable-radeon
+LIBDRM_CONF_OPTS += -Dradeon=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_AMDGPU),y)
-LIBDRM_CONF_OPTS += --enable-amdgpu
+LIBDRM_CONF_OPTS += -Damdgpu=true
 else
-LIBDRM_CONF_OPTS += --disable-amdgpu
+LIBDRM_CONF_OPTS += -Damdgpu=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_NOUVEAU),y)
-LIBDRM_CONF_OPTS += --enable-nouveau
+LIBDRM_CONF_OPTS += -Dnouveau=true
 else
-LIBDRM_CONF_OPTS += --disable-nouveau
+LIBDRM_CONF_OPTS += -Dnouveau=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_VMWGFX),y)
-LIBDRM_CONF_OPTS += --enable-vmwgfx
+LIBDRM_CONF_OPTS += -Dvmwgfx=true
 else
-LIBDRM_CONF_OPTS += --disable-vmwgfx
+LIBDRM_CONF_OPTS += -Dvmwgfx=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_OMAP),y)
-LIBDRM_CONF_OPTS += --enable-omap-experimental-api
+LIBDRM_CONF_OPTS += -Domap=true
 else
-LIBDRM_CONF_OPTS += --disable-omap-experimental-api
+LIBDRM_CONF_OPTS += -Domap=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_ETNAVIV),y)
-LIBDRM_CONF_OPTS += --enable-etnaviv-experimental-api
+LIBDRM_CONF_OPTS += -Detnaviv=true
 else
-LIBDRM_CONF_OPTS += --disable-etnaviv-experimental-api
+LIBDRM_CONF_OPTS += -Detnaviv=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_EXYNOS),y)
-LIBDRM_CONF_OPTS += --enable-exynos-experimental-api
+LIBDRM_CONF_OPTS += -Dexynos=true
 else
-LIBDRM_CONF_OPTS += --disable-exynos-experimental-api
+LIBDRM_CONF_OPTS += -Dexynos=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_FREEDRENO),y)
-LIBDRM_CONF_OPTS += --enable-freedreno
+LIBDRM_CONF_OPTS += -Dfreedreno=true
 else
-LIBDRM_CONF_OPTS += --disable-freedreno
+LIBDRM_CONF_OPTS += -Dfreedreno=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_TEGRA),y)
-LIBDRM_CONF_OPTS += --enable-tegra-experimental-api
+LIBDRM_CONF_OPTS += -Dtegra=true
 else
-LIBDRM_CONF_OPTS += --disable-tegra-experimental-api
+LIBDRM_CONF_OPTS += -Dtegra=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_VC4),y)
-LIBDRM_CONF_OPTS += --enable-vc4
+LIBDRM_CONF_OPTS += -Dvc4=true
 else
-LIBDRM_CONF_OPTS += --disable-vc4
+LIBDRM_CONF_OPTS += -Dvc4=false
 endif
 
 ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
-LIBDRM_CONF_OPTS += --enable-udev
+LIBDRM_CONF_OPTS += -Dudev=true
 LIBDRM_DEPENDENCIES += udev
 else
-LIBDRM_CONF_OPTS += --disable-udev
+LIBDRM_CONF_OPTS += -Dudev=false
 endif
 
 ifeq ($(BR2_PACKAGE_VALGRIND),y)
-LIBDRM_CONF_OPTS += --enable-valgrind
+LIBDRM_CONF_OPTS += -Dvalgrind=true
 LIBDRM_DEPENDENCIES += valgrind
 else
-LIBDRM_CONF_OPTS += --disable-valgrind
+LIBDRM_CONF_OPTS += -Dvalgrind=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_INSTALL_TESTS),y)
-LIBDRM_CONF_OPTS += --enable-install-test-programs
+LIBDRM_CONF_OPTS += -Dinstall-test-programs=true
 ifeq ($(BR2_PACKAGE_CUNIT),y)
 LIBDRM_DEPENDENCIES += cunit
 endif
 endif
 
-$(eval $(autotools-package))
+$(eval $(meson-package))
--

2.21.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v6 2/2 libdrm: change to meson build system

Hello Yann,

Quoted 17 lines · Yann E. MORIN

Peter, All,

On 2019-04-23 22:53 +0200, Peter Seiderer spake thusly:
[--SNIP--]

package/libdrm/libdrm.mk

Quoted 4 lines
package/libdrm/libdrm.mk +0 -0
index cc7350c10e..77e7ad01bd 100644

[--SNIP--]

package/libdrm/libdrm.mk LIBDRM_SITE = https://dri.freedesktop.org/libdrm · line 24

Quoted 5 lines

ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y)
LIBDRM_DEPENDENCIES += libatomic_ops
ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)

package/libdrm/libdrm.mk +1 -1
-LIBDRM_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DAO_NO_SPARC_V9"
+LIBDRM_MESON_CFLAGS += -DAO_NO_SPARC_V9

As discussed in the thread, the variable was renamed.

Quoted 5 lines

I've resent a new iteration of the meson-package part as a standalone patch:

    https://patchwork.ozlabs.org/patch/1120719/

As such, I've marked this thread as Changes requested.

Thanks for taking care of the patch...

Quoted 3 lines

Care to resend this libdrm bump+conversion once the meson infra part lands?

Yes, will do....

Regards,
Peter

Quoted 134 lines

Thanks! :-)

Regards,
Yann E. MORIN.

Quoted 127 lines

endif
endif

ifeq ($(BR2_PACKAGE_LIBDRM_INTEL),y)

package/libdrm/libdrm.mk +28 -29
-LIBDRM_CONF_OPTS += --enable-intel
+LIBDRM_CONF_OPTS += -Dintel=true
 LIBDRM_DEPENDENCIES += libpciaccess
 else
-LIBDRM_CONF_OPTS += --disable-intel
+LIBDRM_CONF_OPTS += -Dintel=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_RADEON),y)
-LIBDRM_CONF_OPTS += --enable-radeon
+LIBDRM_CONF_OPTS += -Dradeon=true
 else
-LIBDRM_CONF_OPTS += --disable-radeon
+LIBDRM_CONF_OPTS += -Dradeon=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_AMDGPU),y)
-LIBDRM_CONF_OPTS += --enable-amdgpu
+LIBDRM_CONF_OPTS += -Damdgpu=true
 else
-LIBDRM_CONF_OPTS += --disable-amdgpu
+LIBDRM_CONF_OPTS += -Damdgpu=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_NOUVEAU),y)
-LIBDRM_CONF_OPTS += --enable-nouveau
+LIBDRM_CONF_OPTS += -Dnouveau=true
 else
-LIBDRM_CONF_OPTS += --disable-nouveau
+LIBDRM_CONF_OPTS += -Dnouveau=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_VMWGFX),y)
-LIBDRM_CONF_OPTS += --enable-vmwgfx
+LIBDRM_CONF_OPTS += -Dvmwgfx=true
 else
-LIBDRM_CONF_OPTS += --disable-vmwgfx
+LIBDRM_CONF_OPTS += -Dvmwgfx=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_OMAP),y)
-LIBDRM_CONF_OPTS += --enable-omap-experimental-api
+LIBDRM_CONF_OPTS += -Domap=true
 else
-LIBDRM_CONF_OPTS += --disable-omap-experimental-api
+LIBDRM_CONF_OPTS += -Domap=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_ETNAVIV),y)
-LIBDRM_CONF_OPTS += --enable-etnaviv-experimental-api
+LIBDRM_CONF_OPTS += -Detnaviv=true
 else
-LIBDRM_CONF_OPTS += --disable-etnaviv-experimental-api
+LIBDRM_CONF_OPTS += -Detnaviv=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_EXYNOS),y)
-LIBDRM_CONF_OPTS += --enable-exynos-experimental-api
+LIBDRM_CONF_OPTS += -Dexynos=true
 else
-LIBDRM_CONF_OPTS += --disable-exynos-experimental-api
+LIBDRM_CONF_OPTS += -Dexynos=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_FREEDRENO),y)
-LIBDRM_CONF_OPTS += --enable-freedreno
+LIBDRM_CONF_OPTS += -Dfreedreno=true
 else
-LIBDRM_CONF_OPTS += --disable-freedreno
+LIBDRM_CONF_OPTS += -Dfreedreno=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_TEGRA),y)
-LIBDRM_CONF_OPTS += --enable-tegra-experimental-api
+LIBDRM_CONF_OPTS += -Dtegra=true
 else
-LIBDRM_CONF_OPTS += --disable-tegra-experimental-api
+LIBDRM_CONF_OPTS += -Dtegra=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_VC4),y)
-LIBDRM_CONF_OPTS += --enable-vc4
+LIBDRM_CONF_OPTS += -Dvc4=true
 else
-LIBDRM_CONF_OPTS += --disable-vc4
+LIBDRM_CONF_OPTS += -Dvc4=false
 endif
 
 ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
-LIBDRM_CONF_OPTS += --enable-udev
+LIBDRM_CONF_OPTS += -Dudev=true
 LIBDRM_DEPENDENCIES += udev
 else
-LIBDRM_CONF_OPTS += --disable-udev
+LIBDRM_CONF_OPTS += -Dudev=false
 endif
 
 ifeq ($(BR2_PACKAGE_VALGRIND),y)
-LIBDRM_CONF_OPTS += --enable-valgrind
+LIBDRM_CONF_OPTS += -Dvalgrind=true
 LIBDRM_DEPENDENCIES += valgrind
 else
-LIBDRM_CONF_OPTS += --disable-valgrind
+LIBDRM_CONF_OPTS += -Dvalgrind=false
 endif
 
 ifeq ($(BR2_PACKAGE_LIBDRM_INSTALL_TESTS),y)
-LIBDRM_CONF_OPTS += --enable-install-test-programs
+LIBDRM_CONF_OPTS += -Dinstall-test-programs=true
 ifeq ($(BR2_PACKAGE_CUNIT),y)
 LIBDRM_DEPENDENCIES += cunit
 endif
 endif
 
-$(eval $(autotools-package))
+$(eval $(meson-package))
--

2.21.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH v6 1/2 meson: add per package optional compiler/linker flags

In reply to Peter Seiderer

Peter, All,

On 2019-04-23 22:53 +0200, Peter Seiderer spake thusly:

Quoted 2 lines

Add LIBFOO_MESON_CFLAGS, LIBFOO_MESON_LDFLAGS and LIBFOO_MESON_CXXFLAGS variables to allow per package additional compiler/linker flags.

So, this patch (or a variation based on it) is starting to get very much needed to fix the build of libglib2:

    http://autobuild.buildroot.org/?reason=libglib2-2.60.3

I did not know about this patch, so I sent that one instead:

    https://patchwork.ozlabs.org/patch/1114211/

Of course, it looks like yours is better and I successfully used it to fix the above issues. Wee! \o/

However, I have a few comments about it, see below...

Quoted 2 lines

---

[--SNIP--]

package/meson/meson.mk define HOST_MESON_INSTALL_CROSS_CONF · line 65

Quoted 11 lines
package/meson/meson.mk +3 -0
index 49e27f5527..70128f6bad 100644
@@ -60,6 +60,9 @@ define HOST_MESON_INSTALL_CROSS_CONF
 	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \

Actually, if someone wants to use that file outside of Buildroot, and also happend to need to pass special C/LD/CXXFLAGS for their package, how are they expected to do so? Can't we just install it as a template too?

(But given that I don't like meson, I am OK that we don't want to offer this to external users and just decide to leave them out in the cold, where they belong. OK, I'm out in the box for the next 5 minutes! ;-]

Quoted 8 lines
package/meson/meson.mk +0 -0
 	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
 	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
package/pkg-meson.mk +0 -0
index 886fcf7205..9974b1e513 100644

package/pkg-meson.mk $(2)_NINJA_ENV ?= · line 62

Quoted 6 lines
package/pkg-meson.mk +3 -0
@@ -57,6 +57,10 @@ $(2)_NINJA_ENV		?=
 ifndef $(2)_CONFIGURE_CMDS
 ifeq ($(4),target)
 
+$(2)_MESON_SED_CFLAGS = $(if $($(2)_MESON_CFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_CFLAGS)`)
+$(2)_MESON_SED_LDFLAGS = $(if $($(2)_MESON_LDFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_LDFLAGS)`)
+$(2)_MESON_SED_CXXFLAGS = $(if $($(2)_MESON_CXXFLAGS),`printf '"%s"$(comma) ' $$($$(2)_MESON_CXXFLAGS)`)

There are two things I am not too fond about those variables:

1. for the other package infras, when a package wants to pass extra such flags, the package is responsible for carrying the original TARGET_CFLAGS (LD, CXX), and this is not automatic. With your path, this would make it automatic for meson, thus diverging from the usual practice.

It also precludes packages from actualyl overriding the default flags, like we currently have to do to override -ON for some packages under mucroblaze for example.

2. The naming is not nice to me: why do we need to have "MESON" in the variable name at all? Surely, fir the other infras, we just write things like:

    FOO_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
not:
    FOO_AUTOTOOLS_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    FOO_CMAKE_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    etc...

Regards,
Yann E. MORIN.

Quoted 20 lines
package/pkg-meson.mk +3 -1
 # Configure package for target
 #
 #
@@ -70,6 +74,9 @@ define $(2)_CONFIGURE_CMDS
 	    -e "s%@TARGET_CFLAGS@%$$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CFLAGS@%$$($$(PKG)_MESON_SED_CFLAGS)%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%$$($$(PKG)_MESON_SED_LDFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%$$($$(PKG)_MESON_SED_CXXFLAGS)%g" \
 	    -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
 	    package/meson/cross-compilation.conf.in \
 	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
--

2.21.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH v6 1/2 meson: add per package optional compiler/linker flags

All;

Quoted 72 lines · Yann E. MORIN

Peter, All,

On 2019-04-23 22:53 +0200, Peter Seiderer spake thusly:

Quoted 2 lines

Add LIBFOO_MESON_CFLAGS, LIBFOO_MESON_LDFLAGS and LIBFOO_MESON_CXXFLAGS variables to allow per package additional compiler/linker flags.

So, this patch (or a variation based on it) is starting to get very much needed to fix the build of libglib2:

    http://autobuild.buildroot.org/?reason=libglib2-2.60.3

I did not know about this patch, so I sent that one instead:

    https://patchwork.ozlabs.org/patch/1114211/

Of course, it looks like yours is better and I successfully used it to fix the above issues. Wee! \o/

However, I have a few comments about it, see below...

Quoted 2 lines

---

[--SNIP--]

package/meson/meson.mk define HOST_MESON_INSTALL_CROSS_CONF · line 65

Quoted 11 lines
package/meson/meson.mk +3 -0
index 49e27f5527..70128f6bad 100644
@@ -60,6 +60,9 @@ define HOST_MESON_INSTALL_CROSS_CONF
          -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
          -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
          -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
+         -e "s%@PKG_TARGET_CFLAGS@%%g" \
+         -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+         -e "s%@PKG_TARGET_CXXFLAGS@%%g" \

Actually, if someone wants to use that file outside of Buildroot, and also happend to need to pass special C/LD/CXXFLAGS for their package, how are they expected to do so? Can't we just install it as a template too?

(But given that I don't like meson, I am OK that we don't want to offer this to external users and just decide to leave them out in the cold, where they belong. OK, I'm out in the box for the next 5 minutes! ;-]

Quoted 8 lines
package/meson/meson.mk +0 -0
          -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
          $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
          > $(HOST_DIR)/etc/meson/cross-compilation.conf
package/pkg-meson.mk +0 -0
index 886fcf7205..9974b1e513 100644

package/pkg-meson.mk $(2)_NINJA_ENV ?= · line 62

Quoted 6 lines
package/pkg-meson.mk +3 -0
@@ -57,6 +57,10 @@ $(2)_NINJA_ENV             ?=
 ifndef $(2)_CONFIGURE_CMDS
 ifeq ($(4),target)
 
+$(2)_MESON_SED_CFLAGS = $(if $($(2)_MESON_CFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_CFLAGS)`)
+$(2)_MESON_SED_LDFLAGS = $(if $($(2)_MESON_LDFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_LDFLAGS)`)
+$(2)_MESON_SED_CXXFLAGS = $(if $($(2)_MESON_CXXFLAGS),`printf '"%s"$(comma) ' $$($$(2)_MESON_CXXFLAGS)`)

There are two things I am not too fond about those variables:

1. for the other package infras, when a package wants to pass extra such flags, the package is responsible for carrying the original TARGET_CFLAGS (LD, CXX), and this is not automatic. With your path, this would make it automatic for meson, thus diverging from the usual practice.

It also precludes packages from actualyl overriding the default flags, like we currently have to do to override -ON for some packages under mucroblaze for example.

2. The naming is not nice to me: why do we need to have "MESON" in the variable name at all? Surely, fir the other infras, we just write things like:

Quoted 9 lines
    FOO_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
not:
    FOO_AUTOTOOLS_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    FOO_CMAKE_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    etc...

Regards,
Yann E. MORIN.

I 100% agree with Yann. We should maintain consistency, and there is no real reason that I can find that would make
the _MESON_ prefix work better than without.

Quoted 32 lines
Quoted 16 lines
package/pkg-meson.mk +3 -1
 # Configure package for target
 #
 #
@@ -70,6 +74,9 @@ define $(2)_CONFIGURE_CMDS
          -e "s%@TARGET_CFLAGS@%$$(HOST_MESON_SED_CFLAGS)%g" \
          -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
          -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%g" \
+         -e "s%@PKG_TARGET_CFLAGS@%$$($$(PKG)_MESON_SED_CFLAGS)%g" \
+         -e "s%@PKG_TARGET_LDFLAGS@%$$($$(PKG)_MESON_SED_LDFLAGS)%g" \
+         -e "s%@PKG_TARGET_CXXFLAGS@%$$($$(PKG)_MESON_SED_CXXFLAGS)%g" \
          -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
          package/meson/cross-compilation.conf.in \
          > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
--

2.21.0

Quoted 4 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#6 lore raw

PATCH v6 1/2 meson: add per package optional compiler/linker flags

In reply to Yann E. MORIN
Quoted 8 lines · On Wed, 12 Jun 2019 18:37:10 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 8 lines
package/meson/meson.mk +0 -0
index 49e27f5527..70128f6bad 100644
@@ -60,6 +60,9 @@ define HOST_MESON_INSTALL_CROSS_CONF
 	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
Quoted 8 lines

package/meson/meson.mk define HOST_MESON_INSTALL_CROSS_CONF · line 65

Quoted 3 lines
package/meson/meson.mk +3 -0
+	    -e "s%@PKG_TARGET_CFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \  

Actually, if someone wants to use that file outside of Buildroot, and also happend to need to pass special C/LD/CXXFLAGS for their package, how are they expected to do so? Can't we just install it as a template too?

If we keep @PKG_TARGET_CFLAGS@, @PKG_TARGET_LDFLAGS@, etc. in the cross-compilation.conf, then it is no longer usable as-is: users will _have_ to fixup those @PKG_TARGET_foo@, even if they don't need to pass additional CFLAGS to their package.

I think what Peter S. did here is the best we can do. A better solution would be for Meson to support command line provided cflags/ldflags, but that's not supported, and if it was supported, this whole patch wouldn't be necessary.

Quoted 10 lines

package/meson/meson.mk define HOST_MESON_INSTALL_CROSS_CONF · line 68

Quoted 3 lines
package/meson/meson.mk +3 -0
+$(2)_MESON_SED_CFLAGS = $(if $($(2)_MESON_CFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_CFLAGS)`)
+$(2)_MESON_SED_LDFLAGS = $(if $($(2)_MESON_LDFLAGS),`printf '"%s"$(comma) ' $($(2)_MESON_LDFLAGS)`)
+$(2)_MESON_SED_CXXFLAGS = $(if $($(2)_MESON_CXXFLAGS),`printf '"%s"$(comma) ' $$($$(2)_MESON_CXXFLAGS)`)  

There are two things I am not too fond about those variables:

1. for the other package infras, when a package wants to pass extra such flags, the package is responsible for carrying the original TARGET_CFLAGS (LD, CXX), and this is not automatic. With your path, this would make it automatic for meson, thus diverging from the usual practice.

I agree.

Quoted 3 lines

It also precludes packages from actualyl overriding the default flags, like we currently have to do to override -ON for some packages under mucroblaze for example.

However, this example is not really great: for Microblaze we override with -O0 by passing it after $(TARGET_CFLAGS), i.e we don't need to tweak what's in $(TARGET_CFLAGS)

But even if your example is not the best, I agree with you, as it's more consistent with what we do elsewhere, and potentially also dropping/tweaking what's inside TARGET_CFLAGS for a given package, which we do in a few places.

Quoted 8 lines

2. The naming is not nice to me: why do we need to have "MESON" in the variable name at all? Surely, fir the other infras, we just write things like:

    FOO_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
not:
    FOO_AUTOTOOLS_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    FOO_CMAKE_CFLAGS = $(TARGET_CFLAGS) -DMY_STUFF
    etc...

That's true but in fact no other infra has <pkg>_CFLAGS or <pkg>_LDFLAGS variables. These are entirely "internal" to each package, which takes care to propagate them to <pkg>_CONF_ENV for autotools packages, to some -DCMAKE_CFLAGS for cmake packages, etc.

So Meson would anyway stand out from the point of view that it will be the only package infra that takes care of passing <pkg>_CFLAGS / <pkg>_LDFLAGS.

But like the point above: despite this, I still agree with you that <pkg>_CFLAGS is better. Maybe one day we'll make the autotools/cmake infras also take care of passing <pkg>_CFLAGS/LDFLAGS.

So all in all, I agree with your review, except the very first point on keeping the @PKG_TARGET_*@ templates.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

PATCH v6 1/2 meson: add per package optional compiler/linker flags

Thomas, All,

On 2019-06-22 21:13 +0200, Thomas Petazzoni spake thusly:

Quoted 18 lines
Quoted 7 lines · On Wed, 12 Jun 2019 18:37:10 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 7 lines
package/meson/meson.mk +0 -0
index 49e27f5527..70128f6bad 100644
@@ -60,6 +60,9 @@ define HOST_MESON_INSTALL_CROSS_CONF
 	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
 	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
Quoted 8 lines

package/meson/meson.mk define HOST_MESON_INSTALL_CROSS_CONF · line 65

Quoted 4 lines
package/meson/meson.mk +3 -0
 	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
+	    -e "s%@PKG_TARGET_CFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \  

Actually, if someone wants to use that file outside of Buildroot, and also happend to need to pass special C/LD/CXXFLAGS for their package, how are they expected to do so? Can't we just install it as a template

                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line
Quoted 1 line

too?

    ^^^^
Quoted 10 lines

If we keep @PKG_TARGET_CFLAGS@, @PKG_TARGET_LDFLAGS@, etc. in the cross-compilation.conf, then it is no longer usable as-is: users will _have_ to fixup those @PKG_TARGET_foo@, even if they don't need to pass additional CFLAGS to their package.

I think what Peter S. did here is the best we can do. A better solution would be for Meson to support command line provided cflags/ldflags, but that's not supported, and if it was supported, this whole patch wouldn't be necessary.

As I explained on IRC: we would install the file like Peter does, but also install the template as well, so that:

- packages that don't need extra flags can be built as-is

- while for packages that do require extra flag, the user can use the template to generate a custom file

and thus we have the best of both worlds.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'