Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
7.6KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_pkg_mico.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PKG_MICO([X.X.X optional required])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro searches for a MICO installation on your system. MICO (Mico
  12. # Is COrba) installs the file 'mico-setup.sh' under MICO_INSTALL_BASE/lib,
  13. # where MICO_INSTALL_BASE is probably /usr/local or /usr. If nothing was
  14. # specified when calling configure or just --with-mico, it searches in
  15. # $prefix/lib:/usr/local/lib:/usr/lib The argument of s--with-mico
  16. # specifies the full pathname of the mico-setup.sh file. For instance
  17. # --with-mico=/usr/local/mico-2.2.6/lib/mico-setup.sh.
  18. #
  19. # If the version argument is given (e.g. 2.2.6), AX_PKG_MICO checks that
  20. # the mico package is this version number or higher.
  21. #
  22. # The other optional argument to AX_PKG_MICO are 'optional' and
  23. # 'required'. by default, placing AX_PKG_MICO in your configure.in does
  24. # not enforce using mico, if it is not found on the system. If MICO
  25. # existence is critical for the building of your package, then you
  26. # probably want to specify something like "AX_PKG_MICO(2.2.6 required)".
  27. # Then, even if the --with-mico was not specified on the command line of
  28. # the configure script, an error will be raised if mico was not found.
  29. #
  30. # If the mico package is not found, abort configuration with error
  31. # message.
  32. #
  33. # It defines the symbol MICOSETUP, MICOVERSION, MICOSHAREDDIR
  34. # MICO_INCLUDE, MICO_LIB and MICO_CXX if mico is found. In addition, the
  35. # mico script mico-c++ (set in (MICO_CXX) is scaned for a string match
  36. # "-I.*ministl" and if foundMICO_USE_MINISTL is set to 1, otherwise to 0.
  37. #
  38. # Example of use of these variables in your Makefile.in:
  39. #
  40. # INCLUDES += @MICO_INCLUDE@
  41. # LDFLAGS += @MICO_LIB@
  42. #
  43. # LICENSE
  44. #
  45. # Copyright (c) 2008 Tal Shalif <tal@shalif.com>
  46. #
  47. # Copying and distribution of this file, with or without modification, are
  48. # permitted in any medium without royalty provided the copyright notice
  49. # and this notice are preserved. This file is offered as-is, without any
  50. # warranty.
  51. #serial 9
  52. AU_ALIAS([AC_PKG_MICO], [AX_PKG_MICO])
  53. AC_DEFUN([AX_PKG_MICO],
  54. [
  55. #
  56. # first parse the argument given in configure.in to AX_PKG_MICO
  57. #
  58. MICO_REQUEST_VERSION=
  59. MICO_URGENCY="optional"
  60. changequote(<<, >>)
  61. for a in $1 $2 $3 $4 $5 $6 $7 $8 $9 x; do
  62. case "$a" in
  63. x) break;;
  64. [0-9]*.[0-9]*.[0-9]*) MICO_REQUEST_VERSION="$a";;
  65. optional|required) MICO_URGENCY="$a";;
  66. *) argerror="argument to the PKG_MICO macro must be one of 'X.X.X' 'required' or 'optional'";;
  67. esac
  68. done
  69. changequote([, ])
  70. if test -n "$argerror"; then
  71. AC_MSG_ERROR($argerror)
  72. fi;
  73. AC_MSG_CHECKING(if mico is wanted)
  74. AC_ARG_WITH(mico,
  75. [ --with-mico=PATH absolute path name of mico's configuration file 'mico-setup.sh' (default is to search in \$prefix/lib:/usr/local/lib:/usr/lib),
  76. --without-mico to disable mico detection],
  77. [
  78. #
  79. # Run this if -with or -without was specified
  80. #
  81. case "$withval" in
  82. yes) MICO_URGENCY=required;;
  83. no) if test x$MICO_URGENCY = xrequired; then
  84. AC_MSG_ERROR("PKG_MICO was configured with the 'required' option. You cannot override it from the command line")
  85. fi;
  86. ;;
  87. *) MICO_URGENCY=required; MICOSETUP="$withval" ;;
  88. esac
  89. ],[])
  90. AC_MSG_RESULT($MICO_URGENCY)
  91. #
  92. # Now we know if we want mico or not, only go further if
  93. # it's wanted.
  94. #
  95. if test x$MICO_URGENCY = xrequired -o x$MICO_URGENCY = xoptional; then
  96. #
  97. # If not specified by caller, search in standard places
  98. #
  99. if test -z "$MICOSETUP" ; then
  100. AC_PATH_PROG(MICOSETUP, mico-setup.sh, , $prefix/lib:/usr/local/lib:/usr/lib)
  101. fi
  102. if test -z "$MICOSETUP" ; then
  103. if test x$MICO_URGENCY = xrequired ; then
  104. AC_MSG_ERROR("mico setup file mico-setup.sh not found")
  105. else
  106. AC_MSG_RESULT("mico setup file mico-setup.sh not found")
  107. fi
  108. else
  109. # source mico-setup.sh
  110. # Collect mico version number.
  111. # But be carefull - mico-setup.sh
  112. # unsets prefix and exec_prefix so save them first
  113. sh -c ". $MICOSETUP; echo MICOVERSION=\${MICOVERSION}; echo MICOSHAREDDIR=\${MICOSHAREDDIR}; echo MICODIR=\${MICODIR}" > conftest.mico-setup
  114. eval `cat conftest.mico-setup`
  115. if test -z "$MICOVERSION" ; then
  116. AC_MSG_ERROR("panic: could not read the MICOVERSION variable");
  117. fi
  118. #
  119. # Check that mico version matches requested version or above
  120. #
  121. if test -n "$MICO_REQUEST_VERSION" ; then
  122. changequote(<<, >>)dnl
  123. MICO_MAJOR=`expr $MICOVERSION : '\([0-9]*\)\.[0-9]*\.[0-9]*'`
  124. MICO_MINOR=`expr $MICOVERSION : '[0-9]*\.\([0-9]*\)\.[0-9]*'`
  125. MICO_RELEASE=`expr $MICOVERSION : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
  126. MICO_REQUEST_MAJOR=`expr $MICO_REQUEST_VERSION : '\([0-9]*\)\.[0-9]*\.[0-9]*'`
  127. MICO_REQUEST_MINOR=`expr $MICO_REQUEST_VERSION : '[0-9]*\.\([0-9]*\)\.[0-9]*'`
  128. MICO_REQUEST_RELEASE=`expr $MICO_REQUEST_VERSION : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
  129. changequote([, ])dnl
  130. AC_MSG_CHECKING(mico version >= $MICO_REQUEST_VERSION)
  131. version_ok=yes
  132. for verpair in "$MICO_MAJOR:$MICO_REQUEST_MAJOR" "$MICO_MINOR:$MICO_REQUEST_MINOR" "$MICO_RELEASE:$MICO_REQUEST_RELEASE"; do
  133. if eval "test `echo $verpair | sed 's,:, -gt ,'`"; then
  134. break
  135. fi
  136. if eval "test `echo $verpair | sed 's,:, -lt ,'`"; then
  137. version_ok=no
  138. break
  139. fi
  140. done
  141. if test x$version_ok = xno; then
  142. AC_MSG_RESULT(no)
  143. AC_MSG_ERROR(mico version is $MICOVERSION)
  144. else
  145. AC_MSG_RESULT(yes)
  146. fi
  147. fi
  148. #
  149. # look for mico-c++ and scan it for a string match
  150. # to "-I*ministl"
  151. #
  152. AC_PATH_PROG(MICO_CXX, mico-c++, , ${MICODIR}/bin:${MICOSHAREDDIR}/bin)
  153. if test -z "$MICO_CXX"; then
  154. AC_MSG_ERROR("panic: cannot locate and scan the mico script mico-c++")
  155. fi
  156. AC_MSG_CHECKING(if mico was compiled using ministl)
  157. if test -z "`grep '\-I.*ministl' $MICO_CXX`"; then
  158. MICO_USE_MINISTL=0
  159. AC_MSG_RESULT(no)
  160. else
  161. MICO_USE_MINISTL=1
  162. AC_MSG_RESULT(yes)
  163. fi
  164. #
  165. # look for mico-ld and scan it for -l* libraries
  166. # needed to link with mico
  167. #
  168. AC_PATH_PROG(MICO_LD, mico-ld, , ${MICODIR}/bin:${MICOSHAREDDIR}/bin)
  169. if test -z "$MICO_LD"; then
  170. AC_MSG_ERROR("panic: cannot locate and scan the mico script mico-ld")
  171. fi
  172. AC_MSG_CHECKING(mico dependencies)
  173. micodeps=
  174. for item in `grep -- -l $MICO_LD | tr '"' ' '` ; do
  175. case $item in
  176. -l*) micodeps="$micodeps $item" ;;
  177. esac
  178. done
  179. if test -z "$micodeps" ;then
  180. AC_MSG_RESULT(none)
  181. else
  182. AC_MSG_RESULT($micodeps)
  183. fi
  184. AC_MSG_CHECKING(how to link with the mico library)
  185. MICO_LIB="-L${MICODIR}/lib -lmico${MICOVERSION} $micodeps"
  186. AC_MSG_RESULT($MICO_LIB)
  187. MICO_INCLUDE="-I${MICOSHAREDDIR}/include"
  188. AC_SUBST(MICODIR)
  189. AC_SUBST(MICOVERSION)
  190. AC_SUBST(MICOSHAREDDIR)
  191. AC_SUBST(MICO_INCLUDE)
  192. AC_SUBST(MICO_LIB)
  193. AC_SUBST(MICO_USE_MINISTL)
  194. fi
  195. fi
  196. ])