1dnl Perform a check for a feature for GStreamer 2dnl Richard Boulton <richard-alsa@tartarus.org> 3dnl Thomas Vander Stichele <thomas@apestaart.org> added useful stuff 4dnl Last modification: 25/06/2001 5dnl 6dnl AG_GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, 7dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE, 8dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE) 9dnl 10dnl This macro adds a command line argument to allow the user to enable 11dnl or disable a feature, and if the feature is enabled, performs a supplied 12dnl test to check if the feature is available. 13dnl 14dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending 15dnl on whether the feature is available. 16dnl 17dnl The macro will set USE_<FEATURE-NAME> to "yes" or "no" depending on 18dnl whether the feature is to be used. 19dnl Thomas changed this, so that when USE_<FEATURE-NAME> was already set 20dnl to no, then it stays that way. 21dnl 22dnl The macro will call AM_CONDITIONAL(USE_<FEATURE-NAME>, ...) to allow 23dnl the feature to control what is built in Makefile.ams. If you want 24dnl additional actions resulting from the test, you can add them with the 25dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters. 26dnl 27dnl FEATURE-NAME is the name of the feature, and should be in 28dnl purely upper case characters. 29dnl FEATURE-DESCRIPTION is used to describe the feature in help text for 30dnl the command line argument. 31dnl DEPENDENT-PLUGINS lists any plug-ins which depend on this feature. 32dnl TEST-FOR-FEATURE is a test which sets HAVE_<FEATURE-NAME> to "yes" 33dnl or "no" depending on whether the feature is 34dnl available. 35dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default, 36dnl if any other value, the feature is enabled by default. 37dnl ACTION-IF-USE any extra actions to perform if the feature is to be 38dnl used. 39dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to 40dnl be used. 41dnl 42dnl 43dnl thomas : 44dnl we also added a history. 45dnl GST_PLUGINS_YES will contain all plugins to be built 46dnl that were checked through AG_GST_CHECK_FEATURE 47dnl GST_PLUGINS_NO will contain those that won't be built 48 49AC_DEFUN([AG_GST_CHECK_FEATURE], 50[echo 51AC_MSG_NOTICE(*** checking feature: [$2] ***) 52if test "x[$3]" != "x" 53then 54 AC_MSG_NOTICE(*** for plug-ins: [$3] ***) 55fi 56dnl 57builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl 58dnl if it is set to NO, then don't even consider it for building 59NOUSE= 60if test "x$USE_[$1]" = "xno"; then 61 NOUSE="yes" 62fi 63AC_ARG_ENABLE(translit([$1], A-Z, a-z), 64 [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])), 65 [ case "${enableval}" in 66 yes) USE_[$1]=yes;; 67 no) USE_[$1]=no;; 68 *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;; 69 esac], 70 [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT 71 72dnl *** set it back to no if it was preset to no 73if test "x$NOUSE" = "xyes"; then 74 USE_[$1]="no" 75 AC_MSG_WARN(*** $3 pre-configured not to be built) 76fi 77NOUSE= 78 79dnl *** Check if it is ported or not 80if echo " [$GST_PLUGINS_NONPORTED] " | tr , ' ' | grep -i " [$1] " > /dev/null; then 81 USE_[$1]="no" 82 AC_MSG_WARN(*** $3 not ported) 83fi 84 85dnl *** If it's enabled 86 87if test x$USE_[$1] = xyes; then 88 dnl save compile variables before the test 89 90 gst_check_save_LIBS=$LIBS 91 gst_check_save_LDFLAGS=$LDFLAGS 92 gst_check_save_CFLAGS=$CFLAGS 93 gst_check_save_CPPFLAGS=$CPPFLAGS 94 gst_check_save_CXXFLAGS=$CXXFLAGS 95 96 HAVE_[$1]=no 97 dnl TEST_FOR_FEATURE 98 $4 99 100 LIBS=$gst_check_save_LIBS 101 LDFLAGS=$gst_check_save_LDFLAGS 102 CFLAGS=$gst_check_save_CFLAGS 103 CPPFLAGS=$gst_check_save_CPPFLAGS 104 CXXFLAGS=$gst_check_save_CXXFLAGS 105 106 dnl If it isn't found, unset USE_[$1] 107 if test x$HAVE_[$1] = xno; then 108 USE_[$1]=no 109 else 110 ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will be built: [$3])]) 111 fi 112fi 113dnl *** Warn if it's disabled or not found 114if test x$USE_[$1] = xyes; then 115 ifelse([$6], , :, [$6]) 116 if test "x$3" != "x"; then 117 GST_PLUGINS_YES="\t[$3]\n$GST_PLUGINS_YES" 118 fi 119 AC_DEFINE(HAVE_[$1], , [Define to enable $2]ifelse($3,,, [ (used by $3)]).) 120else 121 ifelse([$3], , :, [AC_MSG_NOTICE(*** These plugins will not be built: [$3])]) 122 if test "x$3" != "x"; then 123 GST_PLUGINS_NO="\t[$3]\n$GST_PLUGINS_NO" 124 fi 125 ifelse([$7], , :, [$7]) 126fi 127dnl *** Define the conditional as appropriate 128AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes) 129]) 130 131dnl Use AC_CHECK_LIB and AC_CHECK_HEADER to do both tests at once 132dnl sets HAVE_module if we have it 133dnl Richard Boulton <richard-alsa@tartarus.org> 134dnl Last modification: 26/06/2001 135dnl AG_GST_CHECK_LIBHEADER(FEATURE-NAME, LIB NAME, LIB FUNCTION, EXTRA LD FLAGS, 136dnl HEADER NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 137dnl 138dnl This check was written for GStreamer: it should be renamed and checked 139dnl for portability if you decide to use it elsewhere. 140dnl 141AC_DEFUN([AG_GST_CHECK_LIBHEADER], 142[ 143 AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no,[$4]) 144 if test "x$HAVE_[$1]" = "xyes"; then 145 AC_CHECK_HEADER([$5], :, HAVE_[$1]=no) 146 if test "x$HAVE_[$1]" = "xyes"; then 147 dnl execute what needs to be 148 ifelse([$6], , :, [$6]) 149 else 150 ifelse([$7], , :, [$7]) 151 fi 152 else 153 ifelse([$7], , :, [$7]) 154 fi 155 AC_SUBST(HAVE_[$1]) 156] 157) 158 159dnl 2004-02-14 Thomas - changed to get set properly and use proper output 160dnl 2003-06-27 Benjamin Otte - changed to make this work with gstconfig.h 161dnl 162dnl Add a subsystem --disable flag and all the necessary symbols and substitions 163dnl 164dnl AG_GST_CHECK_SUBSYSTEM_DISABLE(SYSNAME, [subsystem name]) 165dnl 166AC_DEFUN([AG_GST_CHECK_SUBSYSTEM_DISABLE], 167[ 168 dnl this define will replace each literal subsys_def occurrence with 169 dnl the lowercase hyphen-separated subsystem 170 dnl e.g. if $1 is GST_DEBUG then subsys_def will be a macro with gst-debug 171 define([subsys_def],translit([$1], _A-Z, -a-z)) 172 173 AC_ARG_ENABLE(subsys_def, 174 AC_HELP_STRING(--disable-subsys_def, [disable $2]), 175 [ 176 case "${enableval}" in 177 yes) GST_DISABLE_[$1]=no ;; 178 no) GST_DISABLE_[$1]=yes ;; 179 *) AC_MSG_ERROR([bad value ${enableval} for --enable-subsys_def]) ;; 180 esac 181 ], 182 [GST_DISABLE_[$1]=no]) dnl Default value 183 184 if test x$GST_DISABLE_[$1] = xyes; then 185 AC_MSG_NOTICE([disabled subsystem [$2]]) 186 GST_DISABLE_[$1]_DEFINE="#define GST_DISABLE_$1 1" 187 else 188 GST_DISABLE_[$1]_DEFINE="/* #undef GST_DISABLE_$1 */" 189 fi 190 AC_SUBST(GST_DISABLE_[$1]_DEFINE) 191 undefine([subsys_def]) 192]) 193 194 195dnl Parse gstconfig.h for feature and defines add the symbols and substitions 196dnl 197dnl AG_GST_PARSE_SUBSYSTEM_DISABLE(GST_CONFIGPATH, FEATURE) 198dnl 199AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLE], 200[ 201 grep >/dev/null "#undef GST_DISABLE_$2" $1 202 if test $? = 0; then 203 GST_DISABLE_[$2]=0 204 else 205 GST_DISABLE_[$2]=1 206 fi 207 AC_SUBST(GST_DISABLE_[$2]) 208]) 209 210dnl Parse gstconfig.h and defines add the symbols and substitions 211dnl 212dnl GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-1.0`"/gst/gstconfig.h" 213dnl AG_GST_PARSE_SUBSYSTEM_DISABLES(GST_CONFIGPATH) 214dnl 215AC_DEFUN([AG_GST_PARSE_SUBSYSTEM_DISABLES], 216[ 217 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,GST_DEBUG) 218 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,LOADSAVE) 219 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PARSE) 220 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,TRACE) 221 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,ALLOC_TRACE) 222 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,REGISTRY) 223 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,PLUGIN) 224 AG_GST_PARSE_SUBSYSTEM_DISABLE($1,XML) 225]) 226 227dnl AG_GST_CHECK_GST_DEBUG_DISABLED(ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED) 228dnl 229dnl Checks if the GStreamer debugging system is disabled in the core version 230dnl we are compiling against (by checking gstconfig.h) 231dnl 232AC_DEFUN([AG_GST_CHECK_GST_DEBUG_DISABLED], 233[ 234 AC_REQUIRE([AG_GST_CHECK_GST]) 235 236 AC_MSG_CHECKING([whether the GStreamer debugging system is enabled]) 237 AC_LANG_PUSH([C]) 238 save_CFLAGS="$CFLAGS" 239 CFLAGS="$GST_CFLAGS $CFLAGS" 240 AC_COMPILE_IFELSE([ 241 AC_LANG_SOURCE([[ 242 #include <gst/gstconfig.h> 243 #ifdef GST_DISABLE_GST_DEBUG 244 #error "debugging disabled, make compiler fail" 245 #endif]])], [ debug_system_enabled=yes], [debug_system_enabled=no]) 246 CFLAGS="$save_CFLAGS" 247 AC_LANG_POP([C]) 248 249 AC_MSG_RESULT([$debug_system_enabled]) 250 251 if test "x$debug_system_enabled" = "xyes" ; then 252 $2 253 true 254 else 255 $1 256 true 257 fi 258]) 259 260dnl relies on GST_PLUGINS_ALL, GST_PLUGINS_SELECTED, GST_PLUGINS_YES, 261dnl GST_PLUGINS_NO, and BUILD_EXTERNAL 262AC_DEFUN([AG_GST_OUTPUT_PLUGINS], [ 263 264printf "configure: *** Plug-ins without external dependencies that will be built:\n" 265( for i in $GST_PLUGINS_SELECTED; do printf '\t'$i'\n'; done ) | sort 266printf "\n" 267 268printf "configure: *** Plug-ins without external dependencies that will NOT be built:\n" 269( for i in $GST_PLUGINS_ALL; do 270 case " $GST_PLUGINS_SELECTED " in 271 *\ $i\ *) 272 ;; 273 *) 274 printf '\t'$i'\n' 275 ;; 276 esac 277 done ) | sort 278printf "\n" 279 280printf "configure: *** Plug-ins that have NOT been ported:\n" 281( for i in $GST_PLUGINS_NONPORTED; do 282 printf '\t'$i'\n' 283 done ) | sort 284printf "\n" 285 286if test "x$BUILD_EXTERNAL" = "xno"; then 287 printf "configure: *** No plug-ins with external dependencies will be built\n" 288else 289 printf "configure: *** Plug-ins with dependencies that will be built:" 290 printf "$GST_PLUGINS_YES\n" | sort 291 printf "\n" 292 printf "configure: *** Plug-ins with dependencies that will NOT be built:" 293 printf "$GST_PLUGINS_NO\n" | sort 294 printf "\n" 295fi 296]) 297 298