1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>
Autoconf Macro: ac_config_libconfig_in
</title>
<link rel="stylesheet" type="text/css" href="autoconf-archive.css">
</head>
<body>
<table summary="web navigation" style="width:100%;">
<tbody>
<tr>
<td style="width:25%;" align="center" valign="top">
<a href=
"http://autoconf-archive.cryp.to/ac_config_libconfig_in.m4">Download M4
Source</a>
</td>
<td style="width:25%;" align="center" valign="top">
<a href=
"http://git.cryp.to/?p=autoconf-archive;a=history;f=ac_config_libconfig_in.m4">
Macro History</a>
</td>
<td style="width:25%;" align="center" valign="top">
<a href="macros-by-category.html">Category Index</a>
</td>
<td style="width:25%;" align="center" valign="top">
<form method="get" action="http://www.google.com/search">
<div>
<input name="sitesearch" value="autoconf-archive.cryp.to" type=
"hidden"><a href="http://www.google.com/">Search</a>: <input name="q"
size="10" maxlength="255" type="text">
</div>
</form>
</td>
</tr>
</tbody>
</table>
<hr>
<h1>
ac_config_libconfig_in
</h1>
<h2>
Obsolete Macro
</h2>
<p class="indent">
Deprecated with the advent of pkg-config.
</p>
<h2>
Synopsis
</h2>
<p class="indent" style="white-space:nowrap;">
<code>AC_CONFIG_LIBCONFIG_IN [(LIBRARY [, DESTINATION [, MODULES]])]</code>
</p>
<h2>
Description
</h2>
<div class="indent">
<p>
Creates a custom LIBRARY-config script. The script supports --cflags,
--libs and --version options, as well as all of the standard configure
variables e.g. --libdir and --sysconfdir. --prefix and --exec-prefix may be
specified to override the defaults. --help gives a complete list of
available options. Modules allow multiple sets of --libs, --cflags and
--version options to be used, and combined together.
</p>
<p>
This macro saves you all the typing for a library-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.
</p>
<p>
The options:
</p>
<pre>
$1 = LIBRARY e.g. gtk, ncurses
$2 = DESTINATION Directory path, e.g. src/scripts
$3 = MODULES Additional library modules, not including the
default ($1).
</pre>
<p>
It is suggested that the following CFLAGS and LIBS variables are used in
your configure.in. library_libs is *essential*. library_cflags is
important, but not always needed. If they do not exist, defaults will be
taken from LIBRARY_CFLAGS, LIBRARY_LIBS (should be -llibrary *only*) and
LIBRARY_LIBDEPS (-l options for libraries your library depends upon.
LIBLIBRARY_LIBS is simply $LIBRARY_LIBS $LIBRARY_LIBDEPS. NB. LIBRARY and
library are the name of your library, in upper and lower case repectively
e.g. GTK, gtk.
</p>
<pre>
LIBRARY_CFLAGS: cflags for compiling libraries and example progs
LIBRARY_LIBS: libraries for linking programs
LIBRARY_LIBDEPS*: libraries for linking libraries against (needed
to link -static
library_cflags*: cflags to store in library-config
library_libs*: libs to store in library-config
LIBLIBRARY_LIBS: libs to link programs IN THIS PACKAGE ONLY against
LIBRARY_VERSION*: the version of your library (x.y.z recommended)
*=required if you want sensible output, otherwise they will be
*guessed* (DWIM)
</pre>
<p>
Support for pkg-config is available by default. libs, cflags and version
information will be obtained from the pkg-config metadata file library.pc
if it exists in the pkgconfig data directory. The above information still
needs to be specified, as it will still be used if pkg-config is not found
on the host system at configure time.
</p>
<p>
-I and -L flags will be obtained from *both* pkgconfig and the script.
AC_CONFIG_LIBCONFIG_IN_PKGCONFIG enables pkg-config support (default)
AC_CONFIG_LIBCONFIG_IN_STATIC disables pkg-config support
</p>
<p>
There is also an AC_SUBST(LIBRARY_CONFIG) that will be set to the name of
the file that we output in this macro. Use as:
</p>
<pre>
install-exec-local: install-config
install-config:
$(mkinstalldirs) $(DESTDIR)$(bindir)
$(INSTALL_EXEC) @LIBRARY_CONFIG@ $(DESTDIR)$(bindir)
</pre>
<p>
Or, if using automake:
</p>
<pre>
bin_SCRIPTS = @LIBRARY_CONFIG@
</pre>
<p>
Based upon <a href=
"ac_create_generic_config.html">AC_CREATE_GENERIC_CONFIG</a> by Guido
Draheim <guidod@gmx.de> and gtk-config by Owen Taylor.
</p>
</div>
<h2>
Author
</h2>
<p class="indent">
Roger Leigh <roger@whinlatter.uklinux.net>
</p>
<h2>
Last Modified
</h2>
<p class="indent">
2005-01-23
</p>
<h2>
M4 Source Code
</h2>
<div class="indent">
<pre class="m4source">
# AC_CONFIG_LIBCONFIG_IN(LIBRARY, DESTINATION, MODULES)
# -----------------------------------------------------
# Generate a custom LIBRARY-config script. Create the script in the
# DESTINATION directory, including support for MODULES.
AC_DEFUN([AC_CONFIG_LIBCONFIG_IN],
[# create a custom library-config file ($1-config)
m4_if(AC_CONFIG_LIBCONFIG_IN_USEPKGCONFIG, [true],
[AC_PATH_PROG(PKG_CONFIG, pkg-config)])
pushdef([LIBCONFIG_DIR], [m4_if([$2], , , [$2/])])
LIBCONFIG_FILE="LIBCONFIG_DIR[]$1-config.in"
AC_SUBST(target)dnl
AC_SUBST(host)dnl
AC_SUBST(build)dnl
dnl create directory if it does not preexist
m4_if([$2], , , [AS_MKDIR_P([$2])])
AC_MSG_NOTICE([creating $LIBCONFIG_FILE])
echo '#! /bin/sh' >$LIBCONFIG_FILE
echo "# $1-config library configuration script" >>$LIBCONFIG_FILE
echo '# generated by ac_config_libconfig_in.m4' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
echo 'template_version="1.0.0"' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
echo 'package="@PACKAGE@"' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
echo '# usage instructions if no options given' >>$LIBCONFIG_FILE
echo 'if test "'"\$""#"'" -eq 0; then' >>$LIBCONFIG_FILE
echo ' cat <<EOF' >>$LIBCONFIG_FILE
m4_if($3, ,
[echo 'Usage: $1-config [[OPTIONS]]' >>$LIBCONFIG_FILE],
[echo 'Usage: $1-config [[OPTIONS]] [[LIBRARIES]]' >>$LIBCONFIG_FILE])
echo 'Options:' >>$LIBCONFIG_FILE
echo ' [[--prefix[=DIR]]]' >>$LIBCONFIG_FILE
echo ' [[--exec-prefix[=DIR]]]' >>$LIBCONFIG_FILE
echo ' [[--package]]' >>$LIBCONFIG_FILE
echo ' [[--version]]' >>$LIBCONFIG_FILE
echo ' [[--cflags]]' >>$LIBCONFIG_FILE
echo ' [[--libs]]' >>$LIBCONFIG_FILE
echo ' [[--help]]' >>$LIBCONFIG_FILE
m4_if($3, , ,
[echo 'Libraries:' >>$LIBCONFIG_FILE
for module in $1 $3 ; do
echo " $module" >>$LIBCONFIG_FILE ;
done])
echo 'EOF' >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
echo '# parse options' >>$LIBCONFIG_FILE
echo 'o=""' >>$LIBCONFIG_FILE
echo 'h=""' >>$LIBCONFIG_FILE
echo 'for i ; do' >>$LIBCONFIG_FILE
echo ' case $i in' >>$LIBCONFIG_FILE
options="prefix exec-prefix eprefix package version cflags libs bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir mandir target host build pkgdatadir pkglibdir pkgincludedir template-version help"
echo ' --prefix=*) prefix=`echo $i | sed -e "s/--prefix=//"` ;;' >>$LIBCONFIG_FILE
echo ' --exec-prefix=*) exec_prefix=`echo $i | sed -e "s/--exec-prefix=//"` ;;' >>$LIBCONFIG_FILE
echo ' --eprefix=*) exec_prefix=`echo $i | sed -e "s/--eprefix=//"` ;;' >>$LIBCONFIG_FILE
for option in $options ; do
case $option in
exec-prefix) echo " --$option) echo_exec_prefix=\"yes\" ;;" >>$LIBCONFIG_FILE ;;
template-version) echo " --$option) echo_template_version=\"yes\" ;;" >>$LIBCONFIG_FILE ;;
*) echo " --$option) echo_$option=\"yes\" ;;" >>$LIBCONFIG_FILE ;;
esac
done
m4_if($3, , ,
[for module in $1 $3 ; do
echo " $module) echo_module_$module=\"yes\" ;" >>$LIBCONFIG_FILE ;
echo ' echo_module="yes" ;;' >>$LIBCONFIG_FILE ;
done])
echo ' //*|/*//*|./*//*) echo_extra="yes" ;;' >>$LIBCONFIG_FILE
echo ' *) eval "echo Unknown option: $i" ; exit 1 ;;' >>$LIBCONFIG_FILE
echo ' esac' >>$LIBCONFIG_FILE
echo 'done' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
# in the order of occurence a standard automake Makefile
echo '# defaults from configure; set only if not set previously' >>$LIBCONFIG_FILE
vars="prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir mandir includedir target host build"
for var in $vars ; do
echo "if test -z \"\$$var\" ; then" >>$LIBCONFIG_FILE
echo " $var=\"@$var@\"" >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
done
echo ' ' >>$LIBCONFIG_FILE
echo '# generate output' >>$LIBCONFIG_FILE
echo 'if test x$echo_module != xyes ; then' >>$LIBCONFIG_FILE
echo ' echo_module_$1="yes"' >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
AC_CONFIG_LIBCONFIG_IN_MODULES(m4_if([$3], , [$1], [m4_translit([$1 $3], [ ], [,])]))dnl
for option in $options extra; do
case $option in
exec-prefix) echo "if test x\$echo_exec_prefix = xyes ; then" >>$LIBCONFIG_FILE ;;
template-version) echo "if test x\$echo_template_version = xyes ; then" >>$LIBCONFIG_FILE ;;
*) echo "if test x\$echo_$option = xyes ; then" >>$LIBCONFIG_FILE ;;
esac
case $option in
exec-prefix | eprefix) echo ' o="$o $exec_prefix"' >>$LIBCONFIG_FILE ;;
template-version) echo ' o="$o $template_version"' >>$LIBCONFIG_FILE ;;
cflags)
echo ' i=`eval echo "$includedir"`' >>$LIBCONFIG_FILE ;
echo ' i=`eval echo "$i"`' >>$LIBCONFIG_FILE ;
echo ' if test "_$i" != "_/usr/include" ; then' >>$LIBCONFIG_FILE ;
echo ' o="$o -I$includedir"' >>$LIBCONFIG_FILE ;
echo ' fi' >>$LIBCONFIG_FILE ;
echo ' o="$o $cflags"' >>$LIBCONFIG_FILE ;;
libs) echo ' o="$o -L$libdir $libs"' >>$LIBCONFIG_FILE ;;
help) echo ' h="1"' >>$LIBCONFIG_FILE ;;
pkgdatadir) echo " o=\"$o \${datadir}/\${package}\"" >>$LIBCONFIG_FILE ;;
pkglibdir) echo " o=\"$o \${libdir}/\${package}\"" >>$LIBCONFIG_FILE ;;
pkgincludedir) echo " o=\"$o \${includedir}/\${package}\"" >>$LIBCONFIG_FILE ;;
extra)
echo ' v=`echo $i | sed -e s://:\$:g`' >>$LIBCONFIG_FILE ;
echo ' v=`eval "echo $v"`' >>$LIBCONFIG_FILE ;
echo ' o="$o $v"' >>$LIBCONFIG_FILE ;;
*) echo " o=\"$o \$$option\"" >>$LIBCONFIG_FILE
esac
echo 'fi' >>$LIBCONFIG_FILE
done
echo ' ' >>$LIBCONFIG_FILE
echo '# output data' >>$LIBCONFIG_FILE
echo 'o=`eval "echo $o"`' >>$LIBCONFIG_FILE
echo 'o=`eval "echo $o"`' >>$LIBCONFIG_FILE
echo 'if test -n "$o" ; then ' >>$LIBCONFIG_FILE
echo ' eval "echo $o"' >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
echo ' ' >>$LIBCONFIG_FILE
echo '# help text' >>$LIBCONFIG_FILE
echo 'if test ! -z "$h" ; then ' >>$LIBCONFIG_FILE
echo ' cat <<EOF' >>$LIBCONFIG_FILE
echo 'All available options:' >>$LIBCONFIG_FILE
echo ' --prefix=DIR and change \$prefix and \$exec-prefix' >>$LIBCONFIG_FILE
echo ' --exec-prefix=DIR (affects all other options)' >>$LIBCONFIG_FILE
echo ' --prefix \$prefix $prefix' >>$LIBCONFIG_FILE
echo ' --exec_prefix or... ' >>$LIBCONFIG_FILE
echo ' --eprefix \$exec_prefix $exec_prefix' >>$LIBCONFIG_FILE
echo ' --version \$version $version' >>$LIBCONFIG_FILE
echo ' --cflags -I\$includedir unless it is /usr/include' >>$LIBCONFIG_FILE
echo ' --libs -L\$libdir \$LIBS $libs' >>$LIBCONFIG_FILE
echo ' --package \$package $package' >>$LIBCONFIG_FILE
echo ' --bindir \$bindir $bindir' >>$LIBCONFIG_FILE
echo ' --sbindir \$sbindir $sbindir' >>$LIBCONFIG_FILE
echo ' --libexecdir \$libexecdir $libexecdir' >>$LIBCONFIG_FILE
echo ' --datadir \$datadir $datadir' >>$LIBCONFIG_FILE
echo ' --sysconfdir \$sysconfdir $sysconfdir' >>$LIBCONFIG_FILE
echo ' --sharedstatedir \$sharedstatedir$sharedstatedir' >>$LIBCONFIG_FILE
echo ' --localstatedir \$localstatedir $localstatedir' >>$LIBCONFIG_FILE
echo ' --libdir \$libdir $libdir' >>$LIBCONFIG_FILE
echo ' --infodir \$infodir $infodir' >>$LIBCONFIG_FILE
echo ' --mandir \$mandir $mandir' >>$LIBCONFIG_FILE
echo ' --target \$target $target' >>$LIBCONFIG_FILE
echo ' --host \$host $host' >>$LIBCONFIG_FILE
echo ' --build \$build $build' >>$LIBCONFIG_FILE
echo ' --pkgdatadir \$datadir/\$package ${datadir}/${package}' >>$LIBCONFIG_FILE
echo ' --pkglibdir \$libdir/\$package ${libdir}/${package}' >>$LIBCONFIG_FILE
echo ' --pkgincludedir \$includedir/\$package ${includedir}/${package}' >>$LIBCONFIG_FILE
echo ' --template-version \$template_version $template_version' >>$LIBCONFIG_FILE
echo ' --help' >>$LIBCONFIG_FILE
echo 'EOF' >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
m4_pushdef([LIBCONFIG_UP], [m4_translit([$1], [a-z], [A-Z])])dnl
LIBCONFIG_UP[]_CONFIG="LIBCONFIG_DIR[]$1-config"
AC_SUBST(LIBCONFIG_UP[]_CONFIG)
dnl AC_CONFIG_FILES(LIBCONFIG_DIR[]$1[-config], [chmod +x ]LIBCONFIG_DIR[]$1[-config])
m4_popdef([LIBCONFIG_DIR])
m4_popdef([LIBCONFIG_UP])
])
# AC_CONFIG_LIBCONFIG_IN_MODULES [(MODULE1 [, MODULE2 [, ...]])]
# --------------------------------------------------------------
#Output shell script using custom module variables.
AC_DEFUN([AC_CONFIG_LIBCONFIG_IN_MODULES],
[m4_if([$1], , ,
[# create module definition for $1
dnl we're going to need uppercase, lowercase and user-friendly versions of the
dnl string `MODULE'
m4_pushdef([MODULE_UP], m4_translit([$1], [a-z], [A-Z]))dnl
m4_pushdef([MODULE_DOWN], m4_translit([$1], [A-Z], [a-z]))dnl
if test -z "$MODULE_DOWN[]_cflags" ; then
if test -n "$MODULE_UP[]_CFLAGS" ; then
MODULE_DOWN[]_cflags="$MODULE_UP[]_CFLAGS"
else
dnl AC_MSG_WARN([variable `MODULE_DOWN[]_cflags' undefined])
MODULE_DOWN[]_cflags=''
fi
fi
AC_SUBST(MODULE_DOWN[]_cflags)dnl
if test -z "$MODULE_DOWN[]_libs" ; then
if test -n "$MODULE_UP[]_LIBS" ; then
MODULE_DOWN[]_libs="$MODULE_UP[]_LIBS"
else
AC_MSG_WARN([variable `MODULE_DOWN[]_libs' and `MODULE_UP[]_LIBS' undefined])
MODULE_DOWN[]_libs='-l$1'
fi
if test -n "$MODULE_UP[]_LIBDEPS" ; then
MODULE_DOWN[]_libs="$MODULE_DOWN[]_libs $MODULE_UP[]_LIBDEPS"
fi
fi
AC_SUBST(MODULE_DOWN[]_libs)dnl
if test -z "$MODULE_UP[]_VERSION" ; then
AC_MSG_WARN([variable `MODULE_UP[]_VERSION' undefined])
MODULE_UP[]_VERSION="$VERSION"
fi
AC_SUBST(MODULE_UP[]_VERSION)dnl
echo 'if test x$echo_module_$1 = xyes ; then' >>$LIBCONFIG_FILE
AC_CONFIG_LIBCONFIG_IN_MODULES_VARS([cflags], [MODULE_DOWN[]_cflags], [cflags])
AC_CONFIG_LIBCONFIG_IN_MODULES_VARS([libs], [MODULE_DOWN[]_libs], [libs])
AC_CONFIG_LIBCONFIG_IN_MODULES_VARS([version], [MODULE_UP[]_VERSION], [modversion])
echo 'fi' >>$LIBCONFIG_FILE
m4_popdef([MODULE_UP])dnl
m4_popdef([MODULE_DOWN])dnl
AC_CONFIG_LIBCONFIG_IN_MODULES(m4_shift($@))])dnl
])
# AC_CONFIG_LIBCONFIG_IN_MODULES_VARS [(VAR, SUBSTITUTION,
# PKGCONFIG_ARGS)]
# --------------------------------------------------------
# Output AC_CONFIG_LIBCONFIG_IN_MODULES variables.
# VAR = variable to set
# SUBSTITUTION = set if pkg-config is not available
# PKGCONFIG_ARGS = args for pkg-config
AC_DEFUN([AC_CONFIG_LIBCONFIG_IN_MODULES_VARS],
[m4_if(AC_CONFIG_LIBCONFIG_IN_USEPKGCONFIG, [true],
[
echo 'if test -x "`which pkg-config`" ; then' >>$LIBCONFIG_FILE
echo ' if pkg-config --atleast-pkgconfig-version=0.7 --exists "MODULE_DOWN"; then' >>$LIBCONFIG_FILE
echo ' $1="@S|@$1 `pkg-config --$3 MODULE_DOWN`"' >>$LIBCONFIG_FILE
echo ' fi' >>$LIBCONFIG_FILE
echo 'else' >>$LIBCONFIG_FILE
echo ' $1="@S|@$1 @$2@"' >>$LIBCONFIG_FILE
echo 'fi' >>$LIBCONFIG_FILE
],
[echo ' $1="@S|@$1 @$2@"' >>$LIBCONFIG_FILE
])])
# AC_CONFIG_LIBCONFIG_IN_PKGCONFIG
# --------------------------------
# Enable pkgconfig support in libconfig script (default)
AC_DEFUN([AC_CONFIG_LIBCONFIG_IN_PKGCONFIG],
[m4_define([AC_CONFIG_LIBCONFIG_IN_USEPKGCONFIG], [true])
])dnl
# AC_CONFIG_LIBCONFIG_IN_STATIC
# -----------------------------
# Disable pkgconfig support in libconfig script
AC_DEFUN([AC_CONFIG_LIBCONFIG_IN_STATIC],
[m4_define([AC_CONFIG_LIBCONFIG_IN_USEPKGCONFIG], [false])
])dnl
</pre>
</div>
<h2>
License
</h2>
<div class="indent">
<span style="white-space:nowrap;">Copyright © 2005 Roger Leigh
<roger@whinlatter.uklinux.net></span>
<p>
Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice and
this notice are preserved.
</p>
</div>
</body>
</html>
|