1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
|
#
# SNOOPY COMMAND LOGGER
#
# File: snoopy.m4
#
# Copyright (c) 2015 Bostjan Skufca <bostjan@a2o.si>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
###
### PROGRAM CHECK Macros
###
#
# GENERAL ENTITY: ./configure output
#
# Args:
# 1: program name to check, exact case
# 2: variable to define, usually upper case (is prefixed with SNOOPY_PROG_ and suffixed with _FOUND)
# 3: additional info if program is not found
#
AC_DEFUN([SNOOPY_PROG_REQUIRE],
[
AC_CHECK_PROG(SNOOPY_PROG_$2_FOUND, $1, yes)
if test x"$SNOOPY_PROG_$2_FOUND" != x"yes" ; then
AC_MSG_ERROR([Program "$1" not found: $3])
fi
])
AC_DEFUN([SNOOPY_PROG_SUGGEST],
[
AC_CHECK_PROG(SNOOPY_PROG_$2_FOUND, $1, yes)
if test x"$SNOOPY_PROG_$2_FOUND" != x"yes" ; then
AC_MSG_WARN([Program "$1" not found: $3])
fi
])
###
### EVERYTHING default value
###
#
# Defines a variable based on if --enable/--disable-everything was specified,
# and if not, the default value provided.
#
# Set default value
#
# Args:
# 1: valuevariable to check
#
AC_DEFUN([SNOOPY_CONFIGURE_ENABLE_EVERYTHING_SET],
[
if test "x$1" == "xyes"; then
everything_enabled="yes"
elif test "x$1" == "xno"; then
everything_enabled="no"
elif test "x$1" == "xunspecified"; then
everything_enabled="unspecified"
else
AC_MSG_ERROR([--enable-everything does not take an argument. Got: $enableval])
fi
])
# Get default value
#
# Args:
# 1: variable name to define
# 2: default value, if no --enable/--disable-everything is specified.
#
AC_DEFUN([SNOOPY_CONFIGURE_ENABLE_EVERYTHING_GET],
[
if test "x$everything_enabled" == "xyes"; then
$1="yes"
elif test "x$everything_enabled" == "xno"; then
$1="no"
else
$1="$2"
fi
])
###
### ENABLE GENERIC
###
#
# Defines a variable based on if --enable/--disable-everything was specified,
# and if not, the default value provided.
#
# ENABLE GENERIC: Set values if SPECIFIED (as ./configure argument)
#
# Args:
# 1: configure flag, without --enable/--disable prefix
# 2: variable name, including "_enabled" suffix
# 3: enableval value
# 4: additional help content, if invalid value is provided
#
AC_DEFUN([SNOOPY_CONFIGURE_ENABLE_GENERIC_SPECIFIED],
[
if test "x$3" == "xyes"; then
$2="yes"
elif test "x$3" == "xno"; then
$2="no"
else
AC_MSG_ERROR([--enable/--disable-$1 does not take an argument. $4 Got: $enableval])
fi
])
# ENABLE GENERIC: Set values if *UN*SPECIFIED (as ./configure argument)
#
# Args:
# 1: configure flag, without --enable/--disable prefix
# 2: variable name, including "_enabled" suffix
# 3: parent default value, used if specified
# 3: default value, used if parent default value is unspecified
#
#
AC_DEFUN([SNOOPY_CONFIGURE_ENABLE_GENERIC_UNSPECIFIED],
[
if test "x$3" == "xyes"; then
$2="yes"
elif test "x$3" == "xno"; then
$2="no"
else
$2="$4"
fi
])
# ENABLE GENERIC: Final macro
#
# Args:
# 1: configure flag, without --enable/--disable prefix
# 2: variable name, including "_enabled" suffix
# 3: default value
#
#
AC_DEFUN([SNOOPY_CONFIGURE_ENABLE_GENERIC_EVALUATE],
[
AS_IF([test "x$1" = "xyes"], [
AC_DEFINE(SNOOPY_CONF_$2, 1, [$3])
])
AM_CONDITIONAL([$2], [test "x$1" == "xyes"])
AC_MSG_NOTICE([Snoopy $3 enabled: $1])
])
###
### GENERAL ENTITY macros
###
#
# GENERAL ENTITY: ./configure output
#
# Args:
# 1: entity type (lower case)
# 2: entity type (upper case)
# 3: entity id
# 4: "yes" if enabled, "no" if disabled, anything else is displayed literally
#
AC_DEFUN([SNOOPY_CONFIGURE_ENTITY_MSG],
[
AS_IF(
[test "x" == "x"],
[
dotLine="..................................................";
whatString="Snoopy $1 enabled: $3 ";
whatStringPadded="$whatString${dotLine:${#whatString}}";
if test "x$4" == "xyes"; then
AC_MSG_NOTICE([$whatStringPadded YES])
elif test "x$4" == "xno"; then
AC_MSG_NOTICE([$whatStringPadded no])
else
AC_MSG_NOTICE([$whatStringPadded $4])
fi
]
)
])
###
### DATASOURCE Macros
###
#
# DATASOURCE: ./configure output
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_MSG],
[
# Do not put newline between last angled and regular closing brace,
# it gets picked up as part of argument.
SNOOPY_CONFIGURE_ENTITY_MSG([datasource], [DATASOURCE], [$1], [$2])
])
# DATASOURCE: actual macro
#
# Args:
# 1: Datasource name
# 2: Datasource description
# 3: Default setting (either "enabled" or "disabled")
# 4: Action that opposes the arg #3 ("disable" or "enable")
# 5: Same as #4, but with capitalized first letter
# 6: Optional variables to set
#
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_ENABLEDISABLE],
[
AC_ARG_ENABLE(datasource-$1,
[AS_HELP_STRING(
[--$4-datasource-$1],
[$5 datasource "$1". This datasource provides $2. [default=$3]]
)],
[
if test "x$enableval" == "xyes"; then
enable_datasource_explicit_$1="yes"
enable_datasource_$1="yes"
elif test "x$enableval" == "xno" ; then
enable_datasource_explicit_$1="no"
enable_datasource_$1="no"
else
AC_MSG_ERROR([--$4-datasource-$1 does not take any arguments, got: $enableval])
fi
],
[
enable_datasource_explicit_$1="undef"
if test "x$enable_all_datasources" == "xyes"; then
enable_datasource_$1="yes"
elif test "x$enable_all_datasources" == "xno" ; then
enable_datasource_$1="no"
else
if test "x$enable_everything" == "xyes"; then
enable_datasource_$1="yes"
elif test "x$enable_everything" == "xno" ; then
enable_datasource_$1="no"
else
if test "x$3" == "xenabled"; then
enable_datasource_$1="yes"
else
enable_datasource_$1="no"
fi
fi
fi
]
)
AS_IF([test "x$enable_datasource_$1" = "xyes"], [
AC_DEFINE(SNOOPY_CONF_DATASOURCE_ENABLED_$1, 1, [Is datasource "$1" available?])
])
AM_CONDITIONAL([DATASOURCE_ENABLED_$1], [test "x$enable_datasource_$1" == "xyes"])
AC_SUBST([enable_datasource_$1])
# Define (optional) additional variables
AM_CONDITIONAL([DATASOURCE_$6], [test "x$6" != "x"])
SNOOPY_CONFIGURE_DATASOURCE_MSG([$1], [$enable_datasource_$1])
])
# DATASOURCE: alias macros
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_ENABLE], [SNOOPY_CONFIGURE_DATASOURCE_ENABLEDISABLE([$1], [$2], [enabled], [disable], [Disable], [$3])])
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_DISABLE], [SNOOPY_CONFIGURE_DATASOURCE_ENABLEDISABLE([$1], [$2], [disabled], [enable], [Enable], [$3])])
# DATASOURCE: force certain datasource to be enabled
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_FORCE],
[
AC_DEFINE(SNOOPY_CONF_DATASOURCE_ENABLED_$1, 1, [Is datasource "$1" available? Forced "Yes".])
AM_CONDITIONAL([DATASOURCE_ENABLED_$1], [test "x" == "x"])
AC_SUBST([enable_datasource_$1], [yes])
SNOOPY_CONFIGURE_DATASOURCE_MSG([$1], [YES (forced)])
])
# DATASOURCE: force certain datasource to be disabled
AC_DEFUN([SNOOPY_CONFIGURE_DATASOURCE_FORCEDISABLE],
[
AM_CONDITIONAL([DATASOURCE_ENABLED_$1], [test "x" == "y"])
AC_SUBST([enable_datasource_$1], [no])
SNOOPY_CONFIGURE_DATASOURCE_MSG([$1], [no (forced)])
])
###
### FILTER Macros
###
#
# FILTER: ./configure output
AC_DEFUN([SNOOPY_CONFIGURE_FILTER_MSG],
[
# Do not put newline between last angled and regular closing brace,
# it gets picked up as part of argument.
SNOOPY_CONFIGURE_ENTITY_MSG([filter], [FILTER], [$1], [$2])
])
# FILTER: actual macro
#
# Args:
# 1: Filter name
# 2: Filter description
# 3: Default setting (either "enabled" or "disabled")
# 4: Action that opposes the arg #3 ("disable" or "enable")
# 5: Same as #4, but with capitalized first letter
#
AC_DEFUN([SNOOPY_CONFIGURE_FILTER_ENABLEDISABLE],
[
AC_ARG_ENABLE(filter-$1,
[AS_HELP_STRING(
[--$4-filter-$1],
[$5 filter "$1". $2 [default=$3]]
)],
[
if test "x$enableval" == "xyes"; then
enable_filter_$1=yes
elif test "x$enableval" == "xno" ; then
enable_filter_$1=no
else
AC_MSG_ERROR([--$4-filter-$1 does not take any arguments, got: $enableval])
fi
],
[
if test "x$enable_all_filters" == "xyes"; then
enable_filter_$1="yes"
elif test "x$enable_all_filters" == "xno" ; then
enable_filter_$1="no"
else
if test "x$enable_filtering" == "xyes"; then
enable_filter_$1="yes"
elif test "x$enable_filtering" == "xno" ; then
enable_filter_$1="no"
else
if test "x$everything_enabled" == "xyes"; then
enable_filter_$1="yes"
elif test "x$everything_enabled" == "xno" ; then
enable_filter_$1="no"
else
if test "x$3" == "xenabled"; then
enable_filter_$1="yes"
else
enable_filter_$1="no"
fi
fi
fi
fi
]
)
AS_IF([test "x$enable_filter_$1" = "xyes"], [
AC_DEFINE(SNOOPY_CONF_FILTER_ENABLED_$1, 1, [Is filter "$1" available?])
])
AM_CONDITIONAL([FILTER_ENABLED_$1], [test "x$enable_filter_$1" == "xyes"])
AC_SUBST([enable_filter_$1])
SNOOPY_CONFIGURE_FILTER_MSG([$1], [$enable_filter_$1])
])
# FILTER: alias macros
AC_DEFUN([SNOOPY_CONFIGURE_FILTER_ENABLE], [SNOOPY_CONFIGURE_FILTER_ENABLEDISABLE([$1], [$2], [enabled], [disable], [Disable])])
AC_DEFUN([SNOOPY_CONFIGURE_FILTER_DISABLE], [SNOOPY_CONFIGURE_FILTER_ENABLEDISABLE([$1], [$2], [disabled], [enable], [Enable] )])
# FILTER: force certain filter to be enabled
AC_DEFUN([SNOOPY_CONFIGURE_FILTER_FORCE],
[
AC_DEFINE(SNOOPY_CONF_FILTER_ENABLED_$1, 1, [Is filter "$1" available? Forced "Yes".])
AM_CONDITIONAL([FILTER_ENABLED_$1], [test "x" == "x"])
AC_SUBST([enable_filter_$1], [yes])
SNOOPY_CONFIGURE_FILTER_MSG([$1], [YES (forced)])
])
###
### OUTPUT Macros
###
#
# OUTPUT: ./configure output
AC_DEFUN([SNOOPY_CONFIGURE_OUTPUT_MSG],
[
# Do not put newline between last angled and regular closing brace,
# it gets picked up as part of argument.
SNOOPY_CONFIGURE_ENTITY_MSG([output], [OUTPUT], [$1], [$2])
])
# OUTPUT: actual macro
#
# Args:
# 1: Output name
# 2: Output description
# 3: Default setting (either "enabled" or "disabled")
# 4: Action that opposes the arg #3 ("disable" or "enable")
# 5: Same as #4, but with capitalized first letter
#
AC_DEFUN([SNOOPY_CONFIGURE_OUTPUT_ENABLEDISABLE],
[
AC_ARG_ENABLE(output-$1,
[AS_HELP_STRING(
[--$4-output-$1],
[$5 output "$1". $2 [default=$3]]
)],
[
if test "x$enableval" == "xyes"; then
enable_output_$1=yes
elif test "x$enableval" == "xno" ; then
enable_output_$1=no
else
AC_MSG_ERROR([--$4-output-$1 does not take any arguments, got: $enableval])
fi
],
[
if test "x$enable_all_outputs" == "xyes"; then
enable_output_$1="yes"
elif test "x$enable_all_outputs" == "xno" ; then
enable_output_$1="no"
else
if test "x$enable_everything" == "xyes"; then
enable_output_$1="yes"
elif test "x$enable_everything" == "xno" ; then
enable_output_$1="no"
else
if test "x$3" == "xenabled"; then
enable_output_$1="yes"
else
enable_output_$1="no"
fi
fi
fi
]
)
AS_IF([test "x$enable_output_$1" = "xyes"], [
AC_DEFINE(SNOOPY_CONF_OUTPUT_ENABLED_$1, 1, [Is output "$1" available?])
])
AM_CONDITIONAL([OUTPUT_ENABLED_$1], [test "x$enable_output_$1" == "xyes"])
AC_SUBST([enable_output_$1])
SNOOPY_CONFIGURE_OUTPUT_MSG([$1], [$enable_output_$1])
])
# OUTPUT: alias macros
AC_DEFUN([SNOOPY_CONFIGURE_OUTPUT_ENABLE], [SNOOPY_CONFIGURE_OUTPUT_ENABLEDISABLE([$1], [$2], [enabled], [disable], [Disable])])
AC_DEFUN([SNOOPY_CONFIGURE_OUTPUT_DISABLE], [SNOOPY_CONFIGURE_OUTPUT_ENABLEDISABLE([$1], [$2], [disabled], [enable], [Enable] )])
# OUTPUT: force certain output to be enabled
AC_DEFUN([SNOOPY_CONFIGURE_OUTPUT_FORCE],
[
AC_DEFINE(SNOOPY_CONF_OUTPUT_ENABLED_$1, 1, [Is output "$1" available? Forced "Yes".])
AM_CONDITIONAL([OUTPUT_ENABLED_$1], [test "x" == "x"])
AC_SUBST([enable_output_$1], [yes])
SNOOPY_CONFIGURE_OUTPUT_MSG([$1], [YES (forced)])
])
|