ax_with_prog.m4 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_with_prog.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Locates an installed program binary, placing the result in the precious
  12. # variable VARIABLE. Accepts a present VARIABLE, then --with-program, and
  13. # failing that searches for program in the given path (which defaults to
  14. # the system path). If program is found, VARIABLE is set to the full path
  15. # of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND
  16. # if provided, unchanged otherwise.
  17. #
  18. # A typical example could be the following one:
  19. #
  20. # AX_WITH_PROG(PERL,perl)
  21. #
  22. # NOTE: This macro is based upon the original AX_WITH_PYTHON macro from
  23. # Dustin J. Mitchell <dustin@cs.uchicago.edu>.
  24. #
  25. # LICENSE
  26. #
  27. # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
  28. # Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu>
  29. #
  30. # Copying and distribution of this file, with or without modification, are
  31. # permitted in any medium without royalty provided the copyright notice
  32. # and this notice are preserved. This file is offered as-is, without any
  33. # warranty.
  34. #serial 16
  35. AC_DEFUN([AX_WITH_PROG],[
  36. AC_PREREQ([2.61])
  37. pushdef([VARIABLE],$1)
  38. pushdef([EXECUTABLE],$2)
  39. pushdef([VALUE_IF_NOT_FOUND],$3)
  40. pushdef([PATH_PROG],$4)
  41. AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable)
  42. AS_IF(test -z "$VARIABLE",[
  43. AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided)
  44. AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[PATH]]]],absolute path to EXECUTABLE executable), [
  45. AS_IF([test "$withval" != yes && test "$withval" != no],[
  46. VARIABLE="$withval"
  47. AC_MSG_RESULT($VARIABLE)
  48. ],[
  49. VARIABLE=""
  50. AC_MSG_RESULT([no])
  51. AS_IF([test "$withval" != no], [
  52. AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[])
  53. ])
  54. ])
  55. ],[
  56. AC_MSG_RESULT([no])
  57. AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[])
  58. ])
  59. ])
  60. popdef([PATH_PROG])
  61. popdef([VALUE_IF_NOT_FOUND])
  62. popdef([EXECUTABLE])
  63. popdef([VARIABLE])
  64. ])