PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Tools/config/ax_path_generic.m4

#
m4 | 164 lines | 81 code | 12 blank | 71 comment | 0 complexity | 069fda26eeee7317daacd1e6b0a3c213 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_path_generic.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and
  12. # LIBRARY_LIBS unless the user had predefined them in the environment.
  13. #
  14. # The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION
  15. # is specified, the script must also support the `--version' arg. If the
  16. # `--with-library-[exec-]prefix' arguments to ./configure are given, it
  17. # must also support `--prefix' and `--exec-prefix'. Prefereable use
  18. # CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and
  19. # LIBS-ARG instead of `--libs`, if given.
  20. #
  21. # The SED-EXPR-EXTRACTOR parameter representes the expression used in sed
  22. # to extract the version number. Use it if your 'foo-config --version'
  23. # dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'.
  24. #
  25. # The macro respects LIBRARY_CONFIG, LIBRARY_CFLAGS and LIBRARY_LIBS
  26. # variables. If the first one is defined, it specifies the name of the
  27. # config script to use. If the latter two are defined, the script is not
  28. # ran at all and their values are used instead (if only one of them is
  29. # defined, the empty value of the remaining one is still used).
  30. #
  31. # Example:
  32. #
  33. # AX_PATH_GENERIC(Foo, 1.0.0)
  34. #
  35. # would run `foo-config --version' and check that it is at least 1.0.0, if
  36. # successful the following variables would be defined and substituted:
  37. #
  38. # FOO_CFLAGS to `foo-config --cflags`
  39. # FOO_LIBS to `foo-config --libs`
  40. #
  41. # Example:
  42. #
  43. # AX_PATH_GENERIC([Bar],,,[
  44. # AC_MSG_ERROR([Cannot find Bar library])
  45. # ])
  46. #
  47. # would check for bar-config program, defining and substituting the
  48. # following variables:
  49. #
  50. # BAR_CFLAGS to `bar-config --cflags`
  51. # BAR_LIBS to `bar-config --libs`
  52. #
  53. # Example:
  54. #
  55. # ./configure BAZ_LIBS=/usr/lib/libbaz.a
  56. #
  57. # would link with a static version of baz library even if `baz-config
  58. # --libs` returns just "-lbaz" that would normally result in using the
  59. # shared library.
  60. #
  61. # This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees.
  62. #
  63. # LICENSE
  64. #
  65. # Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
  66. #
  67. # Copying and distribution of this file, with or without modification, are
  68. # permitted in any medium without royalty provided the copyright notice
  69. # and this notice are preserved. This file is offered as-is, without any
  70. # warranty.
  71. #serial 11
  72. AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC])
  73. AC_DEFUN([AX_PATH_GENERIC],[
  74. AC_REQUIRE([AC_PROG_SED])
  75. dnl we're going to need uppercase and lowercase versions of the
  76. dnl string `LIBRARY'
  77. pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
  78. pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
  79. AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])],
  80. DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
  81. AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])],
  82. DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
  83. AC_ARG_VAR(UP[]_CONFIG, [config script used for $1])
  84. AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1])
  85. AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1])
  86. AS_IF([test x$UP[]_CFLAGS != x -o x$UP[]_LIBS != x],[
  87. dnl Don't run config script at all, use user-provided values instead.
  88. AC_SUBST(UP[]_CFLAGS)
  89. AC_SUBST(UP[]_LIBS)
  90. :
  91. $4
  92. ],[
  93. AS_IF([test x$DOWN[]_config_exec_prefix != x],[
  94. DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
  95. AS_IF([test x${UP[]_CONFIG+set} != xset],[
  96. UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
  97. ])
  98. ])
  99. AS_IF([test x$DOWN[]_config_prefix != x],[
  100. DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
  101. AS_IF([test x${UP[]_CONFIG+set} != xset],[
  102. UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
  103. ])
  104. ])
  105. AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no])
  106. AS_IF([test "$UP[]_CONFIG" == "no"],[
  107. :
  108. $5
  109. ],[
  110. dnl Get the CFLAGS from LIBRARY-config script
  111. AS_IF([test x"$7" == x],[
  112. UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
  113. ],[
  114. UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`"
  115. ])
  116. dnl Get the LIBS from LIBRARY-config script
  117. AS_IF([test x"$8" == x],[
  118. UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
  119. ],[
  120. UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`"
  121. ])
  122. AS_IF([test x"$2" != x],[
  123. dnl Check for provided library version
  124. AS_IF([test x"$3" != x],[
  125. dnl Use provided sed expression
  126. DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`"
  127. ],[
  128. DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`"
  129. ])
  130. AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2])
  131. AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[
  132. AC_MSG_RESULT([yes])
  133. AC_SUBST(UP[]_CFLAGS)
  134. AC_SUBST(UP[]_LIBS)
  135. :
  136. $4
  137. ],[
  138. AC_MSG_RESULT([no])
  139. :
  140. $5
  141. ])
  142. ],[
  143. AC_SUBST(UP[]_CFLAGS)
  144. AC_SUBST(UP[]_LIBS)
  145. :
  146. $4
  147. ])
  148. ])
  149. ])
  150. popdef([UP])
  151. popdef([DOWN])
  152. ])