this patch fixes arts and artsd compilation problems. this is necessary for make...
[platform/upstream/gstreamer.git] / m4 / gst-feature.m4
1 dnl Perform a check for a feature for GStreamer
2 dnl Richard Boulton <richard-alsa@tartarus.org>
3 dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff
4 dnl Last modification: 25/06/2001
5 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
6 dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
7 dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
8 dnl
9 dnl This macro adds a command line argument to enable the user to enable
10 dnl or disable a feature, and if the feature is enabled, performs a supplied
11 dnl test to check if the feature is available.
12 dnl
13 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
14 dnl on whether the feature is available.
15 dnl
16 dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on
17 dnl whether the feature is to be used.
18 dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set
19 dnl to no, then it stays that way.
20 dnl
21 dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
22 dnl the feature to control what is built in Makefile.ams.  If you want
23 dnl additional actions resulting from the test, you can add them with the
24 dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
25 dnl 
26 dnl FEATURE-NAME        is the name of the feature, and should be in
27 dnl                     purely upper case characters.
28 dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
29 dnl                     the command line argument.
30 dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
31 dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
32 dnl                     or "no" depending on whether the feature is
33 dnl                     available.
34 dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
35 dnl                     if any other value, the feature is enabled by default.
36 dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
37 dnl                     used.
38 dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
39 dnl                     be used.
40 dnl
41 dnl
42 dnl thomas :
43 dnl we also added a history.  
44 dnl GST_PLUGINS_YES will contain all plugins to be built
45 dnl                 that were checked through GST_CHECK_FEATURE
46 dnl GST_PLUGINS_NO will contain those that won't be built
47
48 AC_DEFUN(GST_CHECK_FEATURE,
49 [dnl
50 builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
51 dnl if it is set to NO, then don't even consider it for building
52 NOUSE=
53 if test "x$USE_[$1]" = "xno"; then
54   NOUSE="yes"
55 fi
56 AC_ARG_ENABLE(translit([$1], A-Z, a-z),
57   [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
58   [ case "${enableval}" in
59       yes) USE_[$1]=yes;;
60       no) USE_[$1]=no;;
61       *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
62     esac],
63   [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
64
65 dnl *** set it back to no if it was preset to no
66 if test "x$NOUSE" = "xyes"; then
67   USE_[$1]="no"
68   AC_MSG_WARN(*** $3 pre-configured not to be built)
69 fi
70 NOUSE=
71
72 dnl *** If it's enabled
73
74 if test x$USE_[$1] = xyes; then
75   gst_check_save_LIBS=$LIBS
76   gst_check_save_LDFLAGS=$LDFLAGS
77   gst_check_save_CFLAGS=$CFLAGS
78   gst_check_save_CPPFLAGS=$CPPFLAGS
79   gst_check_save_CXXFLAGS=$CXXFLAGS
80   HAVE_[$1]=no
81   $4
82   LIBS=$gst_check_save_LIBS
83   LDFLAGS=$gst_check_save_LDFLAGS
84   CFLAGS=$gst_check_save_CFLAGS
85   CPPFLAGS=$gst_check_save_CPPFLAGS
86   CXXFLAGS=$gst_check_save_CXXFLAGS
87
88   dnl If it isn't found, unset USE_[$1]
89   if test x$HAVE_[$1] = xno; then
90     USE_[$1]=no
91   fi
92 fi
93 dnl *** Warn if it's disabled or not found
94 if test x$USE_[$1] = xyes; then
95   ifelse([$6], , :, [$6])
96   GST_PLUGINS_YES="$GST_PLUGINS_YES \n\t[$3]"
97 else
98   ifelse([$3], , :, [AC_MSG_NOTICE(
99 These plugins will not be built: [$3]
100 )])
101   GST_PLUGINS_NO="$GST_PLUGINS_NO \n\t[$3]"
102   ifelse([$7], , :, [$7])
103 fi
104 dnl *** Define the conditional as appropriate
105 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
106 ])
107
108 dnl Use a -config program which accepts --cflags and --libs parameters
109 dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
110 dnl Richard Boulton <richard-alsa@tartarus.org>
111 dnl Last modification: 26/06/2001
112 dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
113 dnl
114 dnl This check was written for GStreamer: it should be renamed and checked
115 dnl for portability if you decide to use it elsewhere.
116 dnl
117 AC_DEFUN(GST_CHECK_CONFIGPROG,
118 [
119   AC_PATH_PROG([$1]_CONFIG, [$2], no)
120   if test x$[$1]_CONFIG = xno; then
121     [$1]_LIBS=
122     [$1]_CFLAGS=
123     HAVE_[$1]=no
124   else
125     [$1]_LIBS=`[$2] --libs [$3]`
126     [$1]_CFLAGS=`[$2] --cflags [$3]`
127     HAVE_[$1]=yes
128   fi
129   AC_SUBST([$1]_LIBS)
130   AC_SUBST([$1]_CFLAGS)
131 ])
132
133 dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once
134 dnl sets HAVE_module if we have it
135 dnl Richard Boulton <richard-alsa@tartarus.org>
136 dnl Last modification: 26/06/2001
137 dnl GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 
138 dnl                     HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
139 dnl
140 dnl This check was written for GStreamer: it should be renamed and checked
141 dnl for portability if you decide to use it elsewhere.
142 dnl
143 AC_DEFUN(GST_CHECK_LIBHEADER,
144 [
145   AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4])
146   if test "x$HAVE_[$1]" = "xyes"; then
147     AC_CHECK_HEADER([$5], :, HAVE_[$1]=no)
148     if test "x$HAVE_[$1]" = "xyes"; then
149       dnl execute what needs to be
150       ifelse([$6], , :, [$6])
151     else
152       ifelse([$7], , :, [$7])
153     fi
154   else
155     AC_MSG_WARN([$1] not found)
156   fi
157   AC_SUBST(HAVE_[$1])
158 ]
159 )