summaryrefslogtreecommitdiff
path: root/m4/efl.m4
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-18 13:48:14 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-18 13:48:14 +0000
commitdb38bdd6de782b880ab03c1c4217823d30d5eae0 (patch)
tree1df90ff44139e1f1528f8d9af4ad8dc48cfddec1 /m4/efl.m4
parentac4df627f71e4dfc331ef48027fc48b52227a6f1 (diff)
cosmetic: simplify and colorize features.
EFL_ADD_FEATURE(PKG, NAME, [VALUE]) will do an amazing work to produce colored output in a standard way. if value == yes, it's green and shows "+name" if value == no, it's red and shows "-name" else it shows cyan and shows "name=value" if not provided, will use ${have_name:-${want_name}} SVN revision: 82976
Diffstat (limited to 'm4/efl.m4')
-rw-r--r--m4/efl.m469
1 files changed, 69 insertions, 0 deletions
diff --git a/m4/efl.m4 b/m4/efl.m4
index 896eac3862..8db34ba042 100644
--- a/m4/efl.m4
+++ b/m4/efl.m4
@@ -33,6 +33,43 @@ m4_define([def_build_profile], m4_if($4, dev, [dev], [release]))dnl
33m4_define([efl_version], m4_if($4, dev, [v_maj.v_min.v_mic.v_rev], [v_maj.v_min.v_mic]))dnl 33m4_define([efl_version], m4_if($4, dev, [v_maj.v_min.v_mic.v_rev], [v_maj.v_min.v_mic]))dnl
34]) 34])
35 35
36dnl EFL_COLOR
37dnl will check if terminal supports color and if color is wanted by user.
38dnl
39dnl Used Variables:
40dnl WANT_COLOR: if no, forces no color output.
41dnl TERM: used to check if color should be enabled.
42dnl
43dnl Defined Variables:
44dnl COLOR_YES: to be used in positive/yes conditions
45dnl COLOR_NO: to be used in negative/no conditions
46dnl COLOR_OTHER: to be used to highlight some other condition
47dnl COLOR_RESET: to reset color
48dnl want_color: yes or no
49AC_DEFUN([EFL_COLOR],
50[dnl
51case "$TERM" in
52 xterm|xterm-color|Eterm|aterm|kterm|rxvt*|screen|gnome|interix)
53 want_color="${WANT_COLOR:-yes}"
54 ;;
55 *)
56 want_color="no"
57 ;;
58esac
59
60if test "${want_color}" = "yes"; then
61 COLOR_YES=`echo -e "\033@<:@1;32m"`
62 COLOR_NO=`echo -e "\033@<:@1;31m"`
63 COLOR_OTHER=`echo -e "\033@<:@1;36m"`
64 COLOR_RESET=`echo -e "\033@<:@0m"`
65else
66 COLOR_YES=""
67 COLOR_NO=""
68 COLOR_OTHER=""
69 COLOR_RESET=""
70fi
71])
72
36dnl EFL_INIT() 73dnl EFL_INIT()
37dnl Will AC_DEFINE() the following: 74dnl Will AC_DEFINE() the following:
38dnl VMAJ = v_maj 75dnl VMAJ = v_maj
@@ -51,6 +88,7 @@ dnl lt_rev = libtool 'revision' field of libtool's -version-info
51dnl lt_age = libtool 'age' field of libtool's -version-info 88dnl lt_age = libtool 'age' field of libtool's -version-info
52AC_DEFUN([EFL_INIT], 89AC_DEFUN([EFL_INIT],
53[dnl 90[dnl
91AC_REQUIRE([EFL_COLOR])dnl
54AC_DEFINE_UNQUOTED([VMAJ], [v_maj], [Major version])dnl 92AC_DEFINE_UNQUOTED([VMAJ], [v_maj], [Major version])dnl
55AC_DEFINE_UNQUOTED([VMIN], [v_min], [Minor version])dnl 93AC_DEFINE_UNQUOTED([VMIN], [v_min], [Minor version])dnl
56AC_DEFINE_UNQUOTED([VMIC], [v_mic], [Micro version])dnl 94AC_DEFINE_UNQUOTED([VMIC], [v_mic], [Micro version])dnl
@@ -378,3 +416,34 @@ AM_CONDITIONAL([HAVE_]m4_defn([UP]), [test "$efl_lib_optional_[]m4_defn([DOWN])"
378m4_popdef([UP])dnl 416m4_popdef([UP])dnl
379m4_popdef([DOWN])dnl 417m4_popdef([DOWN])dnl
380]) 418])
419
420dnl EFL_ADD_FEATURE(PKG, NAME, [VALUE])
421dnl if VALUE is not specified, will use ${have_name} instead.
422dnl
423dnl Defined Variables:
424dnl features_pkg
425AC_DEFUN([EFL_ADD_FEATURE],
426[dnl
427m4_pushdef([DOWNPKG], m4_translit([$1], [-A-Z], [_a-z]))dnl
428m4_pushdef([DOWNNAME], m4_translit([$2], [-A-Z], [_a-z]))dnl
429
430value="m4_if($3, , [${have_]m4_defn([DOWNNAME])[:-${want_]m4_defn([DOWNNAME])[}}], [$3])"
431case "${value}" in
432 yes)
433 tmp="${COLOR_YES}+$2${COLOR_RESET}"
434 ;;
435 no)
436 tmp="${COLOR_NO}-$2${COLOR_RESET}"
437 ;;
438 *)
439 tmp="${COLOR_OTHER}$2=${value}${COLOR_RESET}"
440 ;;
441esac
442if test -z "${features_[]m4_defn([DOWNPKG])}"; then
443 features_[]m4_defn([DOWNPKG])="${tmp}"
444else
445 features_[]m4_defn([DOWNPKG])="${features_[]m4_defn([DOWNPKG])} ${tmp}"
446fi
447m4_popdef([DOWNNAME])dnl
448m4_popdef([DOWNPKG])dnl
449])