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