1
0

ax_create_generic_config.m4 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # ============================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_create_generic_config.html
  3. # ============================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CREATE_GENERIC_CONFIG [(PACKAGEnlibs [, VERSION])]
  8. #
  9. # DESCRIPTION
  10. #
  11. # Creates a generic PACKAGE-config file that has all the things that you
  12. # want, hmm, well, atleast it has --cflags, --version, --libs. Ahhm, did
  13. # you see ax_path_generic in the autoconf-archive? ;-)
  14. #
  15. # this macros saves you all the typing for a pkg-config.in script, you
  16. # don't even need to distribute one along. Place this macro in your
  17. # configure.ac, et voila, you got one that you want to install.
  18. #
  19. # oh, btw, if the first arg looks like "mylib -lwhat' then it will go to
  20. # be added to the --libs, and mylib is extracted.
  21. #
  22. # the defaults: $1 = $PACKAGE $LIBS $2 = $VERSION there is also an
  23. # AC_SUBST(GENERIC_CONFIG) that will be set to the name of the file that
  24. # we did output in this macro. Use as:
  25. #
  26. # install-exec-local: install-generic-config
  27. #
  28. # install-generic-config:
  29. # $(mkinstalldirs) $(DESTDIR)$(bindir)
  30. # $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir)
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  35. #
  36. # This program is free software; you can redistribute it and/or modify it
  37. # under the terms of the GNU General Public License as published by the
  38. # Free Software Foundation; either version 3 of the License, or (at your
  39. # option) any later version.
  40. #
  41. # This program is distributed in the hope that it will be useful, but
  42. # WITHOUT ANY WARRANTY; without even the implied warranty of
  43. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  44. # Public License for more details.
  45. #
  46. # You should have received a copy of the GNU General Public License along
  47. # with this program. If not, see <http://www.gnu.org/licenses/>.
  48. #
  49. # As a special exception, the respective Autoconf Macro's copyright owner
  50. # gives unlimited permission to copy, distribute and modify the configure
  51. # scripts that are the output of Autoconf when processing the Macro. You
  52. # need not follow the terms of the GNU General Public License when using
  53. # or distributing such scripts, even though portions of the text of the
  54. # Macro appear in them. The GNU General Public License (GPL) does govern
  55. # all other use of the material that constitutes the Autoconf Macro.
  56. #
  57. # This special exception to the GPL applies to versions of the Autoconf
  58. # Macro released by the Autoconf Archive. When you make and distribute a
  59. # modified version of the Autoconf Macro, you may extend this special
  60. # exception to the GPL to apply to your modified version as well.
  61. #serial 6
  62. AU_ALIAS([AC_CREATE_GENERIC_CONFIG], [AX_CREATE_GENERIC_CONFIG])
  63. AC_DEFUN([AX_CREATE_GENERIC_CONFIG],[# create a generic PACKAGE-config file
  64. L=`echo ifelse($1, , $PACKAGE $LIBS, $1)`
  65. P=`echo $L | sed -e 's/ -.*//'`
  66. P=`echo $P`
  67. V=`echo ifelse($2, , $VERSION, $2)`
  68. F=`echo $P-config`
  69. L=`echo -l$L | sed -e 's/^-llib/-l/'`
  70. AC_MSG_RESULT(creating $F - generic $V for $L)
  71. test "x$prefix" = xNONE && prefix="$ac_default_prefix"
  72. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
  73. echo '#! /bin/sh' >$F
  74. echo ' ' >>$F
  75. echo 'package="'$P'"' >>$F
  76. echo 'version="'$V'"' >>$F
  77. echo 'libs="'$L'"' >>$F
  78. echo ' ' >>$F
  79. # in the order of occurence a standard automake Makefile
  80. echo 'prefix="'$prefix'"' >>$F
  81. echo 'exec_prefix="'$exec_prefix'"' >>$F
  82. echo 'bindir="'$bindir'"' >>$F
  83. echo 'sbindir="'$sbindir'"' >>$F
  84. echo 'libexecdir="'$libexecdir'"' >>$F
  85. echo 'datadir="'$datadir'"' >>$F
  86. echo 'sysconfdir="'$sysconfdir'"' >>$F
  87. echo 'sharedstatedir="'$sharedstatedir'"' >>$F
  88. echo 'localstatedir="'$localstatedir'"' >>$F
  89. echo 'libdir="'$libdir'"' >>$F
  90. echo 'infodir="'$infodir'"' >>$F
  91. echo 'mandir="'$mandir'"' >>$F
  92. echo 'includedir="'$includedir'"' >>$F
  93. echo 'target="'$target'"' >>$F
  94. echo 'host="'$host'"' >>$F
  95. echo 'build="'$build'"' >>$F
  96. echo ' ' >>$F
  97. echo 'if test "'"\$""#"'" -eq 0; then' >>$F
  98. echo ' cat <<EOF' >>$F
  99. echo 'Usage: $package-config [OPTIONS]' >>$F
  100. echo 'Options:' >>$F
  101. echo ' --prefix[=DIR]) : \$prefix' >>$F
  102. echo ' --package) : \$package' >>$F
  103. echo ' --version) : \$version' >>$F
  104. echo ' --cflags) : -I\$includedir' >>$F
  105. echo ' --libs) : -L\$libdir -l\$package' >>$F
  106. echo ' --help) print all the options (not just these)' >>$F
  107. echo 'EOF' >>$F
  108. echo 'fi' >>$F
  109. echo ' ' >>$F
  110. echo 'o=""' >>$F
  111. echo 'h=""' >>$F
  112. echo 'for i in "[$]@"; do' >>$F
  113. echo ' case $i in' >>$F
  114. echo ' --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' >>$F
  115. echo ' --prefix) o="$o $prefix" ;;' >>$F
  116. echo ' --package) o="$o $package" ;;' >>$F
  117. echo ' --version) o="$o $version" ;;' >>$F
  118. echo ' --cflags) if test "_$includedir" != "_/usr/include"' >>$F
  119. echo ' then o="$o -I$includedir" ; fi' >>$F
  120. echo ' ;;' >>$F
  121. echo ' --libs) o="$o -L$libdir $libs" ;;' >>$F
  122. echo ' --exec_prefix|--eprefix) o="$o $exec_prefix" ;;' >>$F
  123. echo ' --bindir) o="$o $bindir" ;;' >>$F
  124. echo ' --sbindir) o="$o $sbindir" ;;' >>$F
  125. echo ' --libexecdir) o="$o $libexecdir" ;;' >>$F
  126. echo ' --datadir) o="$o $datadir" ;;' >>$F
  127. echo ' --datainc) o="$o -I$datadir" ;;' >>$F
  128. echo ' --datalib) o="$o -L$datadir" ;;' >>$F
  129. echo ' --sysconfdir) o="$o $sysconfdir" ;;' >>$F
  130. echo ' --sharedstatedir) o="$o $sharedstatedir" ;;' >>$F
  131. echo ' --localstatedir) o="$o $localstatedir" ;;' >>$F
  132. echo ' --libdir) o="$o $libdir" ;;' >>$F
  133. echo ' --libadd) o="$o -L$libdir" ;;' >>$F
  134. echo ' --infodir) o="$o $infodir" ;;' >>$F
  135. echo ' --mandir) o="$o $mandir" ;;' >>$F
  136. echo ' --target) o="$o $target" ;;' >>$F
  137. echo ' --host) o="$o $host" ;;' >>$F
  138. echo ' --build) o="$o $build" ;;' >>$F
  139. echo ' --data) o="$o -I$datadir/$package" ;;' >>$F
  140. echo ' --pkgdatadir) o="$o $datadir/$package" ;;' >>$F
  141. echo ' --pkgdatainc) o="$o -I$datadir/$package" ;;' >>$F
  142. echo ' --pkgdatalib) o="$o -L$datadir/$package" ;;' >>$F
  143. echo ' --pkglibdir) o="$o $libdir/$package" ;;' >>$F
  144. echo ' --pkglibinc) o="$o -I$libinc/$package" ;;' >>$F
  145. echo ' --pkglibadd) o="$o -L$libadd/$package" ;;' >>$F
  146. echo ' --pkgincludedir) o="$o $includedir/$package" ;;' >>$F
  147. echo ' --help) h="1" ;;' >>$F
  148. echo ' -?//*|-?/*//*|-?./*//*|//*|/*//*|./*//*) ' >>$F
  149. echo ' v=`echo $i | sed -e s://:\$:g`' >>$F
  150. echo ' v=`eval "echo $v"` ' >>$F
  151. echo ' o="$o $v" ;; ' >>$F
  152. echo ' esac' >>$F
  153. echo 'done' >>$F
  154. echo ' ' >>$F
  155. echo 'o=`eval "echo $o"`' >>$F
  156. echo 'o=`eval "echo $o"`' >>$F
  157. echo 'eval "echo $o"' >>$F
  158. echo ' ' >>$F
  159. echo 'if test ! -z "$h" ; then ' >>$F
  160. echo 'cat <<EOF' >>$F
  161. echo ' --prefix=xxx) (what is that for anyway?)' >>$F
  162. echo ' --prefix) \$prefix $prefix' >>$F
  163. echo ' --package) \$package $package' >>$F
  164. echo ' --version) \$version $version' >>$F
  165. echo ' --cflags) -I\$includedir unless it is /usr/include' >>$F
  166. echo ' --libs) -L\$libdir -l\$PACKAGE \$LIBS' >>$F
  167. echo ' --exec_prefix) or... ' >>$F
  168. echo ' --eprefix) \$exec_prefix $exec_prefix' >>$F
  169. echo ' --bindir) \$bindir $bindir' >>$F
  170. echo ' --sbindir) \$sbindir $sbindir' >>$F
  171. echo ' --libexecdir) \$libexecdir $libexecdir' >>$F
  172. echo ' --datadir) \$datadir $datadir' >>$F
  173. echo ' --sysconfdir) \$sysconfdir $sysconfdir' >>$F
  174. echo ' --sharedstatedir) \$sharedstatedir$sharedstatedir' >>$F
  175. echo ' --localstatedir) \$localstatedir $localstatedir' >>$F
  176. echo ' --libdir) \$libdir $libdir' >>$F
  177. echo ' --infodir) \$infodir $infodir' >>$F
  178. echo ' --mandir) \$mandir $mandir' >>$F
  179. echo ' --target) \$target $target' >>$F
  180. echo ' --host) \$host $host' >>$F
  181. echo ' --build) \$build $build' >>$F
  182. echo ' --data) -I\$datadir/\$package' >>$F
  183. echo ' --pkgdatadir) \$datadir/\$package' >>$F
  184. echo ' --pkglibdir) \$libdir/\$package' >>$F
  185. echo ' --pkgincludedir) \$includedir/\$package' >>$F
  186. echo ' --help) generated by ax_create_generic_config.m4' >>$F
  187. echo ' -I//varname and other inc-targets like --pkgdatainc supported' >>$F
  188. echo ' -L//varname and other lib-targets, e.g. --pkgdatalib or --libadd' >>$F
  189. echo 'EOF' >>$F
  190. echo 'fi' >>$F
  191. GENERIC_CONFIG="$F"
  192. AC_SUBST(GENERIC_CONFIG)
  193. ])