Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] autotools: add with/without and enable/disable helpers
@ 2010-11-19  4:33 Mike Frysinger
  2010-11-19  7:55 ` Thomas Petazzoni
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mike Frysinger @ 2010-11-19  4:33 UTC (permalink / raw)
  To: buildroot

Rather than have to write ugly logic in every package .mk file to check
a config var and then expand into a --{en,dis}able-foo flag, add helpers
so code can cleanly expand things.

A simple example:
- ifeq ($(BR2_PACKAGE_LIBVORBIS),y)
- SDL_MIXER_CONF_OPT += --enable-music-ogg
- else
- SDL_MIXER_CONF_OPT += --disable-music-ogg
- endif
+ SDL_MIXER_CONF_OPT += $(call USE_ENABLE,PACKAGE_LIBVORBIS,music-ogg)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 package/Makefile.autotools.in |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/package/Makefile.autotools.in b/package/Makefile.autotools.in
index 7d04e44..08a190b 100644
--- a/package/Makefile.autotools.in
+++ b/package/Makefile.autotools.in
@@ -279,3 +279,21 @@ else
 $(call AUTOTARGETS_INNER,$(2),$(call UPPERCASE,$(2)),$(call UPPERCASE,$(2)),$(1),target)
 endif
 endef
+
+################################################################################
+# AUTOTOOLS HELPERS
+################################################################################
+
+# $(call _USE_CONF,enable,disable,LIB_FFMPEG,video,blah) -> --enable-video=blah if LIB_FFMPEG
+# $(call _USE_CONF,with,without,LIB_FFMPEG,video)        -> --with-video if LIB_FFMPEG
+_USE_CONF = $(shell \
+	opt="$(5)"; test "$${opt:+set}" = "set" && opt="=$${opt}"; \
+	test "$(BR2_$(3))" = "y" \
+		&& echo "--$(1)-$(4)$${opt}" \
+		|| echo "--$(2)-$(4)")
+
+# $(call USE_ENABLE,LIB_FFMPEG,video) => --enable-video if LIB_FFMPEG is set
+USE_ENABLE = $(call _USE_CONF,enable,disable,$(1),$(2),$(3))
+
+# $(call USE_WITH,LIB_FFMPEG,video) => --with-video if LIB_FFMPEG is set
+USE_WITH = $(call _USE_CONF,with,without,$(1),$(2),$(3))
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [Buildroot] [PATCH] autotools: add with/without and enable/disable helpers
@ 2011-03-28  8:35 Mike Frysinger
  0 siblings, 0 replies; 13+ messages in thread
From: Mike Frysinger @ 2011-03-28  8:35 UTC (permalink / raw)
  To: buildroot

Rather than have to write ugly logic in every package .mk file to check
a config var and then expand into a --{en,dis}able-foo flag, add helpers
so code can cleanly expand things.

A simple example:
- ifeq ($(BR2_PACKAGE_LIBVORBIS),y)
- SDL_MIXER_CONF_OPT += --enable-music-ogg
- else
- SDL_MIXER_CONF_OPT += --disable-music-ogg
- endif
+ SDL_MIXER_CONF_OPT += $(call USE_ENABLE,LIBVORBIS,music-ogg)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 package/Makefile.autotools.in |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/package/Makefile.autotools.in b/package/Makefile.autotools.in
index d445348..e8d1eb0 100644
--- a/package/Makefile.autotools.in
+++ b/package/Makefile.autotools.in
@@ -279,3 +279,17 @@ else
 $(call AUTOTARGETS_INNER,$(2),$(call UPPERCASE,$(2)),$(call UPPERCASE,$(2)),$(1),target)
 endif
 endef
+
+################################################################################
+# AUTOTOOLS HELPERS
+################################################################################
+
+# $(call _USE_CONF,enable,disable,LIB_FFMPEG,video,blah) -> --enable-video=blah if LIB_FFMPEG
+# $(call _USE_CONF,with,without,LIB_FFMPEG,video)        -> --with-video if LIB_FFMPEG
+_USE_CONF = $(if $(BR2_PACKAGE_$(3)), --$(1)-$(4)$(if $(5),=$(5)), --$(2)-$(4))
+
+# $(call USE_ENABLE,LIB_FFMPEG,video) => --enable-video if LIB_FFMPEG is set
+USE_ENABLE = $(call _USE_CONF,enable,disable,$(1),$(2),$(3))
+
+# $(call USE_WITH,LIB_FFMPEG,video) => --with-video if LIB_FFMPEG is set
+USE_WITH = $(call _USE_CONF,with,without,$(1),$(2),$(3))
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-28  8:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19  4:33 [Buildroot] [PATCH] autotools: add with/without and enable/disable helpers Mike Frysinger
2010-11-19  7:55 ` Thomas Petazzoni
2010-11-19  8:20   ` Mike Frysinger
2010-11-19  9:56     ` Thomas Petazzoni
2010-11-19 10:07       ` Mike Frysinger
2010-11-19 10:23 ` [Buildroot] [PATCH v2] " Mike Frysinger
2010-11-19 11:13   ` Thomas Petazzoni
2010-11-19 11:24     ` Mike Frysinger
2010-11-19 12:49       ` Paulius Zaleckas
2010-11-19 23:25         ` Mike Frysinger
2010-11-20  2:37 ` [Buildroot] [PATCH v3] " Mike Frysinger
2010-11-20  3:47   ` Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2011-03-28  8:35 [Buildroot] [PATCH] " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox