gst-plugins-nuvdemux/m4/gst-feature.m4
branchtrunk
changeset 123 253b9171a703
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gst-plugins-nuvdemux/m4/gst-feature.m4	Tue Nov 28 00:53:25 2006 +0000
     1.3 @@ -0,0 +1,211 @@
     1.4 +dnl Perform a check for a feature for GStreamer
     1.5 +dnl Richard Boulton <richard-alsa@tartarus.org>
     1.6 +dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
     1.7 +dnl Last modification: 25/06/2001
     1.8 +dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
     1.9 +dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
    1.10 +dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
    1.11 +dnl
    1.12 +dnl This macro adds a command line argument to enable the user to enable
    1.13 +dnl or disable a feature, and if the feature is enabled, performs a supplied
    1.14 +dnl test to check if the feature is available.
    1.15 +dnl
    1.16 +dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
    1.17 +dnl on whether the feature is available.
    1.18 +dnl
    1.19 +dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
    1.20 +dnl whether the feature is to be used.
    1.21 +dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
    1.22 +dnl to no, then it stays that way.
    1.23 +dnl
    1.24 +dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
    1.25 +dnl the feature to control what is built in Makefile.ams.  If you want
    1.26 +dnl additional actions resulting from the test, you can add them with the
    1.27 +dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
    1.28 +dnl 
    1.29 +dnl FEATURE-NAME        is the name of the feature, and should be in
    1.30 +dnl                     purely upper case characters.
    1.31 +dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
    1.32 +dnl                     the command line argument.
    1.33 +dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
    1.34 +dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
    1.35 +dnl                     or "no" depending on whether the feature is
    1.36 +dnl                     available.
    1.37 +dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
    1.38 +dnl                     if any other value, the feature is enabled by default.
    1.39 +dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
    1.40 +dnl                     used.
    1.41 +dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
    1.42 +dnl                     be used.
    1.43 +dnl
    1.44 +dnl
    1.45 +dnl thomas :
    1.46 +dnl we also added a history.  
    1.47 +dnl GST_PLUGINS_YES will contain all plugins to be built
    1.48 +dnl                 that were checked through GST_CHECK_FEATURE
    1.49 +dnl GST_PLUGINS_NO will contain those that won't be built
    1.50 +
    1.51 +AC_DEFUN([GST_CHECK_FEATURE],
    1.52 +AC_MSG_NOTICE(***)
    1.53 +AC_MSG_NOTICE(*** checking plugin: [$3] ***)
    1.54 +AC_MSG_NOTICE(***)
    1.55 +[dnl
    1.56 +builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
    1.57 +dnl if it is set to NO, then don't even consider it for building
    1.58 +NOUSE=
    1.59 +if test "x$USE_[$1]" = "xno"; then
    1.60 +  NOUSE="yes"
    1.61 +fi
    1.62 +AC_ARG_ENABLE(translit([$1], A-Z, a-z),
    1.63 +  [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
    1.64 +  [ case "${enableval}" in
    1.65 +      yes) USE_[$1]=yes;;
    1.66 +      no) USE_[$1]=no;;
    1.67 +      *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
    1.68 +    esac],
    1.69 +  [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
    1.70 +
    1.71 +dnl *** set it back to no if it was preset to no
    1.72 +if test "x$NOUSE" = "xyes"; then
    1.73 +  USE_[$1]="no"
    1.74 +  AC_MSG_WARN(*** $3 pre-configured not to be built)
    1.75 +fi
    1.76 +NOUSE=
    1.77 +
    1.78 +dnl *** If it's enabled
    1.79 +
    1.80 +if test x$USE_[$1] = xyes; then
    1.81 +  dnl save compile variables before the test
    1.82 +
    1.83 +  gst_check_save_LIBS=$LIBS
    1.84 +  gst_check_save_LDFLAGS=$LDFLAGS
    1.85 +  gst_check_save_CFLAGS=$CFLAGS
    1.86 +  gst_check_save_CPPFLAGS=$CPPFLAGS
    1.87 +  gst_check_save_CXXFLAGS=$CXXFLAGS
    1.88 +
    1.89 +  HAVE_[$1]=no
    1.90 +  dnl TEST_FOR_FEATURE
    1.91 +  $4
    1.92 +
    1.93 +  LIBS=$gst_check_save_LIBS
    1.94 +  LDFLAGS=$gst_check_save_LDFLAGS
    1.95 +  CFLAGS=$gst_check_save_CFLAGS
    1.96 +  CPPFLAGS=$gst_check_save_CPPFLAGS
    1.97 +  CXXFLAGS=$gst_check_save_CXXFLAGS
    1.98 +
    1.99 +  dnl If it isn't found, unset USE_[$1]
   1.100 +  if test x$HAVE_[$1] = xno; then
   1.101 +    USE_[$1]=no
   1.102 +  fi
   1.103 +fi
   1.104 +dnl *** Warn if it's disabled or not found
   1.105 +if test x$USE_[$1] = xyes; then
   1.106 +  ifelse([$6], , :, [$6])
   1.107 +  if test "x$3" != "x"; then
   1.108 +    GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES"
   1.109 +  fi
   1.110 +  AC_DEFINE(HAVE_[$1], , [support for features: $3])
   1.111 +else
   1.112 +  ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])])
   1.113 +  if test "x$3" != "x"; then
   1.114 +    GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO"
   1.115 +  fi
   1.116 +  ifelse([$7], , :, [$7])
   1.117 +fi
   1.118 +dnl *** Define the conditional as appropriate
   1.119 +AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
   1.120 +])
   1.121 +
   1.122 +dnl Use a -config program which accepts --cflags and --libs parameters
   1.123 +dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
   1.124 +dnl Richard Boulton <richard-alsa@tartarus.org>
   1.125 +dnl Last modification: 26/06/2001
   1.126 +dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
   1.127 +dnl
   1.128 +dnl This check was written for GStreamer: it should be renamed and checked
   1.129 +dnl for portability if you decide to use it elsewhere.
   1.130 +dnl
   1.131 +AC_DEFUN([GST_CHECK_CONFIGPROG],
   1.132 +[
   1.133 +  AC_PATH_PROG([$1]_CONFIG, [$2], no)
   1.134 +  if test x$[$1]_CONFIG = xno; then
   1.135 +    [$1]_LIBS=
   1.136 +    [$1]_CFLAGS=
   1.137 +    HAVE_[$1]=no
   1.138 +  else
   1.139 +    if [$2] --plugin-libs [$3] &> /dev/null; then
   1.140 +      [$1]_LIBS=`[$2] --plugin-libs [$3]`
   1.141 +    else
   1.142 +      [$1]_LIBS=`[$2] --libs [$3]`
   1.143 +    fi
   1.144 +    [$1]_CFLAGS=`[$2] --cflags [$3]`
   1.145 +    HAVE_[$1]=yes
   1.146 +  fi
   1.147 +  AC_SUBST([$1]_LIBS)
   1.148 +  AC_SUBST([$1]_CFLAGS)
   1.149 +])
   1.150 +
   1.151 +dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
   1.152 +dnl sets HAVE_module if we have it
   1.153 +dnl Richard Boulton <richard-alsa@tartarus.org>
   1.154 +dnl Last modification: 26/06/2001
   1.155 +dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 
   1.156 +dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
   1.157 +dnl
   1.158 +dnl This check was written for GStreamer: it should be renamed and checked
   1.159 +dnl for portability if you decide to use it elsewhere.
   1.160 +dnl
   1.161 +AC_DEFUN([GST_CHECK_LIBHEADER],
   1.162 +[
   1.163 +  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
   1.164 +  if test "x$HAVE_[$1]" = "xyes"; then
   1.165 +    AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
   1.166 +    if test "x$HAVE_[$1]" = "xyes"; then
   1.167 +      dnl execute what needs to be
   1.168 +      ifelse([$6], , :, [$6])
   1.169 +    else
   1.170 +      ifelse([$7], , :, [$7])
   1.171 +    fi
   1.172 +  else
   1.173 +    ifelse([$7], , :, [$7])
   1.174 +  fi
   1.175 +  AC_SUBST(HAVE_[$1])
   1.176 +]
   1.177 +)
   1.178 +
   1.179 +dnl 2004-02-14 Thomas - changed to get set properly and use proper output
   1.180 +dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h
   1.181 +dnl
   1.182 +dnl Add a subsystem --disable flag and all the necessary symbols and substitions
   1.183 +dnl
   1.184 +dnl GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name])
   1.185 +dnl
   1.186 +AC_DEFUN([GST_CHECK_SUBSYSTEM_DISABLE],
   1.187 +[
   1.188 +  dnl this define will replace each literal subsys_def occurrence with
   1.189 +  dnl the lowercase hyphen-separated subsystem
   1.190 +  dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug
   1.191 +  define([subsys_def],translit([$1], _A-Z, -a-z))
   1.192 +
   1.193 +  AC_ARG_ENABLE(subsys_def, 
   1.194 +    AC_HELP_STRING(--disable-subsys_def, [disable $2]),
   1.195 +    [
   1.196 +      case "${enableval}" in
   1.197 +        yes) GST_DISABLE_[$1]=no ;;
   1.198 +        no) GST_DISABLE_[$1]=yes ;;
   1.199 +        *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;;
   1.200 +       esac
   1.201 +    ],
   1.202 +    [GST_DISABLE_[$1]=no]) dnl Default value
   1.203 +
   1.204 +  if test x$GST_DISABLE_[$1] = xyes; then
   1.205 +    AC_MSG_NOTICE([disabled subsystem [$2]])
   1.206 +    GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 
   1.207 +  else
   1.208 +    GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */"
   1.209 +  fi
   1.210 +  AC_SUBST(GST_DISABLE_[$1]_DEFINE)
   1.211 +  undefine([subsys_def])
   1.212 +])
   1.213 +
   1.214 +