gmyth-stream/client/m4/gst-feature.m4
author melunko
Wed Apr 11 19:32:57 2007 +0100 (2007-04-11)
branchtrunk
changeset 524 d8d280de1550
permissions -rwxr-xr-x
[svn r529] Fixed string conversion error at gmyth_scheduler_get_schedule_list()
renatofilho@522
     1
dnl Perform a check for a feature for GStreamer
renatofilho@522
     2
dnl Richard Boulton <richard-alsa@tartarus.org>
renatofilho@522
     3
dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
renatofilho@522
     4
dnl Last modification: 25/06/2001
renatofilho@522
     5
dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
renatofilho@522
     6
dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
renatofilho@522
     7
dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
renatofilho@522
     8
dnl
renatofilho@522
     9
dnl This macro adds a command line argument to enable the user to enable
renatofilho@522
    10
dnl or disable a feature, and if the feature is enabled, performs a supplied
renatofilho@522
    11
dnl test to check if the feature is available.
renatofilho@522
    12
dnl
renatofilho@522
    13
dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
renatofilho@522
    14
dnl on whether the feature is available.
renatofilho@522
    15
dnl
renatofilho@522
    16
dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
renatofilho@522
    17
dnl whether the feature is to be used.
renatofilho@522
    18
dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
renatofilho@522
    19
dnl to no, then it stays that way.
renatofilho@522
    20
dnl
renatofilho@522
    21
dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
renatofilho@522
    22
dnl the feature to control what is built in Makefile.ams.  If you want
renatofilho@522
    23
dnl additional actions resulting from the test, you can add them with the
renatofilho@522
    24
dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
renatofilho@522
    25
dnl 
renatofilho@522
    26
dnl FEATURE-NAME        is the name of the feature, and should be in
renatofilho@522
    27
dnl                     purely upper case characters.
renatofilho@522
    28
dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
renatofilho@522
    29
dnl                     the command line argument.
renatofilho@522
    30
dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
renatofilho@522
    31
dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
renatofilho@522
    32
dnl                     or "no" depending on whether the feature is
renatofilho@522
    33
dnl                     available.
renatofilho@522
    34
dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
renatofilho@522
    35
dnl                     if any other value, the feature is enabled by default.
renatofilho@522
    36
dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
renatofilho@522
    37
dnl                     used.
renatofilho@522
    38
dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
renatofilho@522
    39
dnl                     be used.
renatofilho@522
    40
dnl
renatofilho@522
    41
dnl
renatofilho@522
    42
dnl thomas :
renatofilho@522
    43
dnl we also added a history.  
renatofilho@522
    44
dnl GST_PLUGINS_YES will contain all plugins to be built
renatofilho@522
    45
dnl                 that were checked through GST_CHECK_FEATURE
renatofilho@522
    46
dnl GST_PLUGINS_NO will contain those that won't be built
renatofilho@522
    47
renatofilho@522
    48
AC_DEFUN([GST_CHECK_FEATURE],
renatofilho@522
    49
AC_MSG_NOTICE(***)
renatofilho@522
    50
AC_MSG_NOTICE(*** checking plugin: [$3] ***)
renatofilho@522
    51
AC_MSG_NOTICE(***)
renatofilho@522
    52
[dnl
renatofilho@522
    53
builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
renatofilho@522
    54
dnl if it is set to NO, then don't even consider it for building
renatofilho@522
    55
NOUSE=
renatofilho@522
    56
if test "x$USE_[$1]" = "xno"; then
renatofilho@522
    57
  NOUSE="yes"
renatofilho@522
    58
fi
renatofilho@522
    59
AC_ARG_ENABLE(translit([$1], A-Z, a-z),
renatofilho@522
    60
  [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
renatofilho@522
    61
  [ case "${enableval}" in
renatofilho@522
    62
      yes) USE_[$1]=yes;;
renatofilho@522
    63
      no) USE_[$1]=no;;
renatofilho@522
    64
      *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
renatofilho@522
    65
    esac],
renatofilho@522
    66
  [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
renatofilho@522
    67
renatofilho@522
    68
dnl *** set it back to no if it was preset to no
renatofilho@522
    69
if test "x$NOUSE" = "xyes"; then
renatofilho@522
    70
  USE_[$1]="no"
renatofilho@522
    71
  AC_MSG_WARN(*** $3 pre-configured not to be built)
renatofilho@522
    72
fi
renatofilho@522
    73
NOUSE=
renatofilho@522
    74
renatofilho@522
    75
dnl *** If it's enabled
renatofilho@522
    76
renatofilho@522
    77
if test x$USE_[$1] = xyes; then
renatofilho@522
    78
  dnl save compile variables before the test
renatofilho@522
    79
renatofilho@522
    80
  gst_check_save_LIBS=$LIBS
renatofilho@522
    81
  gst_check_save_LDFLAGS=$LDFLAGS
renatofilho@522
    82
  gst_check_save_CFLAGS=$CFLAGS
renatofilho@522
    83
  gst_check_save_CPPFLAGS=$CPPFLAGS
renatofilho@522
    84
  gst_check_save_CXXFLAGS=$CXXFLAGS
renatofilho@522
    85
renatofilho@522
    86
  HAVE_[$1]=no
renatofilho@522
    87
  dnl TEST_FOR_FEATURE
renatofilho@522
    88
  $4
renatofilho@522
    89
renatofilho@522
    90
  LIBS=$gst_check_save_LIBS
renatofilho@522
    91
  LDFLAGS=$gst_check_save_LDFLAGS
renatofilho@522
    92
  CFLAGS=$gst_check_save_CFLAGS
renatofilho@522
    93
  CPPFLAGS=$gst_check_save_CPPFLAGS
renatofilho@522
    94
  CXXFLAGS=$gst_check_save_CXXFLAGS
renatofilho@522
    95
renatofilho@522
    96
  dnl If it isn't found, unset USE_[$1]
renatofilho@522
    97
  if test x$HAVE_[$1] = xno; then
renatofilho@522
    98
    USE_[$1]=no
renatofilho@522
    99
  fi
renatofilho@522
   100
fi
renatofilho@522
   101
dnl *** Warn if it's disabled or not found
renatofilho@522
   102
if test x$USE_[$1] = xyes; then
renatofilho@522
   103
  ifelse([$6], , :, [$6])
renatofilho@522
   104
  if test "x$3" != "x"; then
renatofilho@522
   105
    GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
renatofilho@522
   106
  fi
renatofilho@522
   107
  AC_DEFINE(HAVE_[$1], , [support for features: $3])
renatofilho@522
   108
else
renatofilho@522
   109
  ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
renatofilho@522
   110
  if test "x$3" != "x"; then
renatofilho@522
   111
    GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
renatofilho@522
   112
  fi
renatofilho@522
   113
  ifelse([$7], , :, [$7])
renatofilho@522
   114
fi
renatofilho@522
   115
dnl *** Define the conditional as appropriate
renatofilho@522
   116
AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
renatofilho@522
   117
])
renatofilho@522
   118
renatofilho@522
   119
dnl Use a -config program which accepts --cflags and --libs parameters
renatofilho@522
   120
dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
renatofilho@522
   121
dnl Richard Boulton <richard-alsa@tartarus.org>
renatofilho@522
   122
dnl Last modification: 26/06/2001
renatofilho@522
   123
dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
renatofilho@522
   124
dnl
renatofilho@522
   125
dnl This check was written for GStreamer: it should be renamed and checked
renatofilho@522
   126
dnl for portability if you decide to use it elsewhere.
renatofilho@522
   127
dnl
renatofilho@522
   128
AC_DEFUN([GST_CHECK_CONFIGPROG],
renatofilho@522
   129
[
renatofilho@522
   130
  AC_PATH_PROG([$1]_CONFIG, [$2], no)
renatofilho@522
   131
  if test x$[$1]_CONFIG = xno; then
renatofilho@522
   132
    [$1]_LIBS=
renatofilho@522
   133
    [$1]_CFLAGS=
renatofilho@522
   134
    HAVE_[$1]=no
renatofilho@522
   135
  else
renatofilho@522
   136
    if [$2] --plugin-libs [$3] &> /dev/null; then
renatofilho@522
   137
      [$1]_LIBS=`[$2] --plugin-libs [$3]`
renatofilho@522
   138
    else
renatofilho@522
   139
      [$1]_LIBS=`[$2] --libs [$3]`
renatofilho@522
   140
    fi
renatofilho@522
   141
    [$1]_CFLAGS=`[$2] --cflags [$3]`
renatofilho@522
   142
    HAVE_[$1]=yes
renatofilho@522
   143
  fi
renatofilho@522
   144
  AC_SUBST([$1]_LIBS)
renatofilho@522
   145
  AC_SUBST([$1]_CFLAGS)
renatofilho@522
   146
])
renatofilho@522
   147
renatofilho@522
   148
dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
renatofilho@522
   149
dnl sets HAVE_module if we have it
renatofilho@522
   150
dnl Richard Boulton <richard-alsa@tartarus.org>
renatofilho@522
   151
dnl Last modification: 26/06/2001
renatofilho@522
   152
dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 
renatofilho@522
   153
dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
renatofilho@522
   154
dnl
renatofilho@522
   155
dnl This check was written for GStreamer: it should be renamed and checked
renatofilho@522
   156
dnl for portability if you decide to use it elsewhere.
renatofilho@522
   157
dnl
renatofilho@522
   158
AC_DEFUN([GST_CHECK_LIBHEADER],
renatofilho@522
   159
[
renatofilho@522
   160
  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
renatofilho@522
   161
  if test "x$HAVE_[$1]" = "xyes"; then
renatofilho@522
   162
    AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
renatofilho@522
   163
    if test "x$HAVE_[$1]" = "xyes"; then
renatofilho@522
   164
      dnl execute what needs to be
renatofilho@522
   165
      ifelse([$6], , :, [$6])
renatofilho@522
   166
    else
renatofilho@522
   167
      ifelse([$7], , :, [$7])
renatofilho@522
   168
    fi
renatofilho@522
   169
  else
renatofilho@522
   170
    ifelse([$7], , :, [$7])
renatofilho@522
   171
  fi
renatofilho@522
   172
  AC_SUBST(HAVE_[$1])
renatofilho@522
   173
]
renatofilho@522
   174
)
renatofilho@522
   175
renatofilho@522
   176
dnl 2004-02-14 Thomas - changed to get set properly and use proper output
renatofilho@522
   177
dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
renatofilho@522
   178
dnl
renatofilho@522
   179
dnl Add a subsystem --disable flag and all the necessary symbols and substitions
renatofilho@522
   180
dnl
renatofilho@522
   181
dnl GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
renatofilho@522
   182
dnl
renatofilho@522
   183
AC_DEFUN([GST_CHECK_SUBSYSTEM_DISABLE],
renatofilho@522
   184
[
renatofilho@522
   185
  dnl this define will replace each literal subsys_def occurrence with
renatofilho@522
   186
  dnl the lowercase hyphen-separated subsystem
renatofilho@522
   187
  dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
renatofilho@522
   188
  define([subsys_def],translit([$1], _A-Z, -a-z))
renatofilho@522
   189
renatofilho@522
   190
  AC_ARG_ENABLE(subsys_def, 
renatofilho@522
   191
    AC_HELP_STRING(--disable-subsys_def, [disable $2]),
renatofilho@522
   192
    [
renatofilho@522
   193
      case "${enableval}" in
renatofilho@522
   194
        yes) GST_DISABLE_[$1]=no ;;
renatofilho@522
   195
        no) GST_DISABLE_[$1]=yes ;;
renatofilho@522
   196
        *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
renatofilho@522
   197
       esac
renatofilho@522
   198
    ],
renatofilho@522
   199
    [GST_DISABLE_[$1]=no]) dnl Default value
renatofilho@522
   200
renatofilho@522
   201
  if test x$GST_DISABLE_[$1] = xyes; then
renatofilho@522
   202
    AC_MSG_NOTICE([disabled subsystem [$2]])
renatofilho@522
   203
    GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 
renatofilho@522
   204
  else
renatofilho@522
   205
    GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
renatofilho@522
   206
  fi
renatofilho@522
   207
  AC_SUBST(GST_DISABLE_[$1]_DEFINE)
renatofilho@522
   208
  undefine([subsys_def])
renatofilho@522
   209
])
renatofilho@522
   210
renatofilho@522
   211