AC-Archive
Autoconf Macro Archive

ac-archive.sf.net: - Project CVS - Download
Macro Index
- AM Support
- C++ Support
- C Support
- Fortran Support
- Java Support
- Cross Compilation
- Installed Packages
- Miscellaneous
- LaTeX Support
- Uncategorized
- archive macros
- adl's macros
- bkorb's macros
- guidod's macros
- latex's macros
- other's macros
- rleigh's macros
- obsoleted macros
- released macros
- search index

Documentation
- Contribute!
- History
- acincludedir m4
- acinclude (tool)
- macro howto
- ax tricks
- maintainers
- License
- Topics

generated...
2007-08-05

(C) 2007 guidod
Download the M4 Source.

ac_create_generic_config

Back to the Main Page.

Synopsis
AC_CREATE_GENERIC_CONFIG [(PACKAGEnlibs [, VERSION])]
, 
Version

2003-01-25

Author

Guido U. Draheim <guidod@gmx.de>

License

GPLWithACException
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. As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts

Category

guidod's Miscellaneous (released)

Documentation

Creates a generic PACKAGE-config file that has all the things that you want, hmm, well, atleast it has --cflags, --version, --libs. Ahhm, did you see ac_path_generic in the autoconf-archive? ;-)

this macros saves you all the typing for a pkg-config.in script, you don't even need to distribute one along. Place this macro in your configure.ac, et voila, you got one that you want to install.

oh, btw, if the first arg looks like "mylib -lwhat' then it will go to be added to the --libs, and mylib is extracted.

the defaults: $1 = $PACKAGE $LIBS $2 = $VERSION there is also an AC_SUBST(GENERIC_CONFIG) that will be set to the name of the file that we did output in this macro. Use as:

install-exec-local:    install-generic-config

install-generic-config:
   $(mkinstalldirs) $(DESTDIR)$(bindir)
   $(INSTALL_SCRIPT) @GENERIC_CONFIG@ $(DESTDIR)$(bindir)

M4 Source Code
AC_DEFUN([AC_CREATE_GENERIC_CONFIG],[# create a generic PACKAGE-config file
L=`echo ifelse($1, , $PACKAGE $LIBS, $1)`
P=`echo $L | sed -e 's/ -.*//'`
P=`echo $P`
V=`echo ifelse($2, , $VERSION, $2)`
F=`echo $P-config`
L=`echo -l$L | sed -e 's/^-llib/-l/'`
AC_MSG_RESULT(creating $F - generic $V for $L)
test "x$prefix" = xNONE &amp;&amp; prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE &amp;&amp; exec_prefix='${prefix}'
echo '#! /bin/sh' &gt;$F
echo ' ' &gt;&gt;$F
echo 'package="'$P'"' &gt;&gt;$F
echo 'version="'$V'"' &gt;&gt;$F
echo 'libs="'$L'"' &gt;&gt;$F
echo ' ' &gt;&gt;$F
# in the order of occurence a standard automake Makefile
echo 'prefix="'$prefix'"' &gt;&gt;$F
echo 'exec_prefix="'$exec_prefix'"' &gt;&gt;$F
echo 'bindir="'$bindir'"' &gt;&gt;$F
echo 'sbindir="'$sbindir'"' &gt;&gt;$F
echo 'libexecdir="'$libexecdir'"' &gt;&gt;$F
echo 'datadir="'$datadir'"' &gt;&gt;$F
echo 'sysconfdir="'$sysconfdir'"' &gt;&gt;$F
echo 'sharedstatedir="'$sharedstatedir'"' &gt;&gt;$F
echo 'localstatedir="'$localstatedir'"' &gt;&gt;$F
echo 'libdir="'$libdir'"' &gt;&gt;$F
echo 'infodir="'$infodir'"' &gt;&gt;$F
echo 'mandir="'$mandir'"' &gt;&gt;$F
echo 'includedir="'$includedir'"' &gt;&gt;$F
echo 'target="'$target'"' &gt;&gt;$F
echo 'host="'$host'"' &gt;&gt;$F
echo 'build="'$build'"' &gt;&gt;$F
echo ' ' &gt;&gt;$F
echo 'if test "'"\$""#"'" -eq 0; then' &gt;&gt;$F
echo '   cat &lt;&lt;EOF' &gt;&gt;$F
echo 'Usage: $package-config [OPTIONS]' &gt;&gt;$F
echo 'Options:' &gt;&gt;$F
echo '  --prefix[=DIR]) : \$prefix' &gt;&gt;$F
echo '  --package) : \$package' &gt;&gt;$F
echo '  --version) : \$version' &gt;&gt;$F
echo '  --cflags) : -I\$includedir' &gt;&gt;$F
echo '  --libs) : -L\$libdir -l\$package' &gt;&gt;$F
echo '  --help) print all the options (not just these)' &gt;&gt;$F
echo 'EOF' &gt;&gt;$F
echo 'fi' &gt;&gt;$F
echo ' ' &gt;&gt;$F
echo 'o=""' &gt;&gt;$F
echo 'h=""' &gt;&gt;$F
echo 'for i in "[$]@"; do' &gt;&gt;$F
echo '  case $i in' &gt;&gt;$F
echo '  --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' &gt;&gt;$F
echo '  --prefix)    o="$o $prefix" ;;' &gt;&gt;$F
echo '  --package)   o="$o $package" ;;' &gt;&gt;$F
echo '  --version)   o="$o $version" ;;' &gt;&gt;$F
echo '  --cflags) if test "_$includedir" != "_/usr/include"' &gt;&gt;$F
echo '          then o="$o -I$includedir" ; fi' &gt;&gt;$F
echo '  ;;' &gt;&gt;$F
echo '  --libs)      o="$o -L$libdir $libs" ;;' &gt;&gt;$F
echo '  --exec_prefix|--eprefix) o="$o $exec_prefix" ;;' &gt;&gt;$F
echo '  --bindir)                o="$o $bindir" ;;' &gt;&gt;$F
echo '  --sbindir)               o="$o $sbindir" ;;' &gt;&gt;$F
echo '  --libexecdir)            o="$o $libexecdir" ;;' &gt;&gt;$F
echo '  --datadir)               o="$o $datadir" ;;' &gt;&gt;$F
echo '  --datainc)               o="$o -I$datadir" ;;' &gt;&gt;$F
echo '  --datalib)               o="$o -L$datadir" ;;' &gt;&gt;$F
echo '  --sysconfdir)            o="$o $sysconfdir" ;;' &gt;&gt;$F
echo '  --sharedstatedir)        o="$o $sharedstatedir" ;;' &gt;&gt;$F
echo '  --localstatedir)         o="$o $localstatedir" ;;' &gt;&gt;$F
echo '  --libdir)                o="$o $libdir" ;;' &gt;&gt;$F
echo '  --libadd)                o="$o -L$libdir" ;;' &gt;&gt;$F
echo '  --infodir)               o="$o $infodir" ;;' &gt;&gt;$F
echo '  --mandir)                o="$o $mandir" ;;' &gt;&gt;$F
echo '  --target)                o="$o $target" ;;' &gt;&gt;$F
echo '  --host)                  o="$o $host" ;;' &gt;&gt;$F
echo '  --build)                 o="$o $build" ;;' &gt;&gt;$F
echo '  --data)                  o="$o -I$datadir/$package" ;;' &gt;&gt;$F
echo '  --pkgdatadir)            o="$o $datadir/$package" ;;' &gt;&gt;$F
echo '  --pkgdatainc)            o="$o -I$datadir/$package" ;;' &gt;&gt;$F
echo '  --pkgdatalib)            o="$o -L$datadir/$package" ;;' &gt;&gt;$F
echo '  --pkglibdir)             o="$o $libdir/$package" ;;' &gt;&gt;$F
echo '  --pkglibinc)             o="$o -I$libinc/$package" ;;' &gt;&gt;$F
echo '  --pkglibadd)             o="$o -L$libadd/$package" ;;' &gt;&gt;$F
echo '  --pkgincludedir)         o="$o $includedir/$package" ;;' &gt;&gt;$F
echo '  --help) h="1" ;;' &gt;&gt;$F
echo '  -?//*|-?/*//*|-?./*//*|//*|/*//*|./*//*) ' &gt;&gt;$F
echo '       v=`echo $i | sed -e s://:\$:g`' &gt;&gt;$F
echo '       v=`eval "echo $v"` ' &gt;&gt;$F
echo '       o="$o $v" ;; ' &gt;&gt;$F
echo '  esac' &gt;&gt;$F
echo 'done' &gt;&gt;$F
echo ' ' &gt;&gt;$F
echo 'o=`eval "echo $o"`' &gt;&gt;$F
echo 'o=`eval "echo $o"`' &gt;&gt;$F
echo 'eval "echo $o"' &gt;&gt;$F
echo ' ' &gt;&gt;$F
echo 'if test ! -z "$h" ; then ' &gt;&gt;$F
echo 'cat &lt;&lt;EOF' &gt;&gt;$F
echo '  --prefix=xxx)      (what is that for anyway?)' &gt;&gt;$F
echo '  --prefix)         \$prefix        $prefix' &gt;&gt;$F
echo '  --package)        \$package       $package' &gt;&gt;$F
echo '  --version)        \$version       $version' &gt;&gt;$F
echo '  --cflags)         -I\$includedir    unless it is /usr/include' &gt;&gt;$F
echo '  --libs)           -L\$libdir -l\$PACKAGE \$LIBS' &gt;&gt;$F
echo '  --exec_prefix) or... ' &gt;&gt;$F
echo '  --eprefix)        \$exec_prefix   $exec_prefix' &gt;&gt;$F
echo '  --bindir)         \$bindir        $bindir' &gt;&gt;$F
echo '  --sbindir)        \$sbindir       $sbindir' &gt;&gt;$F
echo '  --libexecdir)     \$libexecdir    $libexecdir' &gt;&gt;$F
echo '  --datadir)        \$datadir       $datadir' &gt;&gt;$F
echo '  --sysconfdir)     \$sysconfdir    $sysconfdir' &gt;&gt;$F
echo '  --sharedstatedir) \$sharedstatedir$sharedstatedir' &gt;&gt;$F
echo '  --localstatedir)  \$localstatedir $localstatedir' &gt;&gt;$F
echo '  --libdir)         \$libdir        $libdir' &gt;&gt;$F
echo '  --infodir)        \$infodir       $infodir' &gt;&gt;$F
echo '  --mandir)         \$mandir        $mandir' &gt;&gt;$F
echo '  --target)         \$target        $target' &gt;&gt;$F
echo '  --host)           \$host          $host' &gt;&gt;$F
echo '  --build)          \$build         $build' &gt;&gt;$F
echo '  --data)           -I\$datadir/\$package' &gt;&gt;$F
echo '  --pkgdatadir)     \$datadir/\$package' &gt;&gt;$F
echo '  --pkglibdir)      \$libdir/\$package' &gt;&gt;$F
echo '  --pkgincludedir)  \$includedir/\$package' &gt;&gt;$F
echo '  --help)           generated by ac_create_generic_config.m4' &gt;&gt;$F
echo '  -I//varname and other inc-targets like --pkgdatainc supported' &gt;&gt;$F
echo '  -L//varname and other lib-targets, e.g. --pkgdatalib or --libadd' &gt;&gt;$F
echo 'EOF' &gt;&gt;$F
echo 'fi' &gt;&gt;$F
GENERIC_CONFIG="$F"
AC_SUBST(GENERIC_CONFIG)
])