I have attached the autoconf machinery we use at Progeny to generate
*-config scripts. It is a generic mechanism that is used to generate
*-config scripts for multiple packages. It's part of the buildtools
CVS module all modules include (the reason i want hard links in
svn).
The package's configure.ac needs to setup certain variables and
call the PROGENY_CONFIG_SCRIPT macro, which takes the name of the
conf script as an optional name (or ${PACKAGE_TARNAME}-config if
not specified). The config script name is exported as
PROGENY_CONFIG_SCRIPT_NAME. Extra variables can be added to the
script with the PROGENY_CONFIG_SCRIPT_VAR macro. configure.ac must
create the export_CPPFLAGS, export_LDFLAGS, and export_LIBS variables,
which are used for the --cppflags, --ldflags, and --libs options,
respectively. These may or may not be the same as CPPFLAGS, LDFLAGS,
and LIBS, which is why we use special variables for exporting to
the -config script.
Then one of the Makefiles copies config-script over to FOO-config.
We do this in buildtools/Makefile.in, but of course it doesn't
matter where it's done. Here are the relevant portions of that
Makefile:
##############################################################################
CONFIG_SCRIPT= @PROGENY_CONFIG_SCRIPT_NAME@
all: ${CONFIG_SCRIPT}
${CONFIG_SCRIPT}: config-script
${INSTALL} config-script $@
install: ${CONFIG_SCRIPT}
${INSTALL_DIR} ${DESTDIR}${bindir}
${INSTALL_SCRIPT} ${CONFIG_SCRIPT} ${DESTDIR}${bindir}/${CONFIG_SCRIPT}
##############################################################################
As a hint to how svn-config might work:
export_LIBS="${client_LIBS} ${fs_LIBS}" # etc.
PROGENY_CONFIG_SCRIPT_VAR(client_libs, ${client_LIBS})
PROGENY_CONFIG_SCRIPT_VAR(fs_libs, ${fs_LIBS})
This also generates a Docbook refentry fragment which we use to
make a man page for the -config script. I can share that stuff
too, if you're interested.
If this is useful, great, but it looks like someone has already
started work on an svn-config script, so whatever. It would be
remiss of me not to post it, though. If you do use it, you'll
probably want to remove the PROGENY_ crap that's all over the place
and use your own prefix ;->.
--
Eric Gillespie, Jr. <*> epg@pretzelnet.org
Build a fire for a man, and he'll be warm for a day. Set a man on
fire, and he'll be warm for the rest of his life. -Terry Pratchett
# $Progeny: config-script.m4,v 1.9 2002/07/12 07:02:12 epg Exp $
AC_DEFUN(PROGENY_CONFIG_SCRIPT_VAR, [
PROGENY_CONFIG_SCRIPT_VARS="${PROGENY_CONFIG_SCRIPT_VARS}; VARS=\"\${VARS} $1\""
PROGENY_CONFIG_SCRIPT_SET="${PROGENY_CONFIG_SCRIPT_SET}; $1=\"$2\""
PROGENY_CONFIG_SCRIPT_DOC="${PROGENY_CONFIG_SCRIPT_DOC}
<listitem>
<para><varname>$1</varname></para>
</listitem>
"
])
AC_DEFUN(PROGENY_CONFIG_SCRIPT, [
ifelse($1, [],
PROGENY_CONFIG_SCRIPT_NAME=${PACKAGE_TARNAME}-config
,
PROGENY_CONFIG_SCRIPT_NAME="$1"
)
dnl Initialize these so they don't start with a semicolon since some
dnl shells react badly to a leading semicolon.
PROGENY_CONFIG_SCRIPT_VARS=":"
PROGENY_CONFIG_SCRIPT_SET=":"
PROGENY_CONFIG_SCRIPT_VAR(major_version, ${PACKAGE_MAJOR})
PROGENY_CONFIG_SCRIPT_VAR(minor_version, ${PACKAGE_MINOR})
PROGENY_CONFIG_SCRIPT_VAR(micro_version, ${PACKAGE_MICRO})
PROGENY_CONFIG_SCRIPT_VAR(version,
\${major_version}.\${minor_version}.\${micro_version})
PROGENY_CONFIG_SCRIPT_VAR(lt_current, ${LT_CURRENT})
PROGENY_CONFIG_SCRIPT_VAR(lt_revision, ${LT_REVISION})
PROGENY_CONFIG_SCRIPT_VAR(lt_age, ${LT_AGE})
PROGENY_CONFIG_SCRIPT_VAR(cppflags, ${export_CPPFLAGS})
PROGENY_CONFIG_SCRIPT_VAR(ldflags, ${export_LDFLAGS})
PROGENY_CONFIG_SCRIPT_VAR(libs, ${export_LIBS})
for var in prefix \
exec_prefix; do
eval val="\$${var}"
if test "${val}" = "NONE"; then
val=${ac_default_prefix}
fi
PROGENY_CONFIG_SCRIPT_VAR(${var}, ${val})
done
for var in bindir \
sbindir \
libexecdir \
datadir \
sysconfdir \
sharedstatedir \
localstatedir \
libdir \
includedir \
oldincludedir \
infodir \
mandir \
build \
build_cpu \
build_vendor \
build_os \
host \
host_cpu \
host_vendor \
host_os \
target \
target_cpu \
target_vendor \
target_os; do
eval val="\$${var}"
PROGENY_CONFIG_SCRIPT_VAR(${var}, ${val})
done
AC_SUBST(PROGENY_CONFIG_SCRIPT_NAME)
AC_SUBST(PROGENY_CONFIG_SCRIPT_SET)
AC_SUBST(PROGENY_CONFIG_SCRIPT_VARS)
AC_CONFIG_FILES(buildtools/config-script)
AC_CONFIG_COMMANDS(config-script-doc,
echo "${doctext}" \
| ${ac_top_srcdir}/${mkdoc} \
${refentry} \
${docname}
,
doctext="${PROGENY_CONFIG_SCRIPT_DOC}";
mkdoc='buildtools/config-script-mkdoc';
refentry='buildtools/config-script.refentry';
docname="${PROGENY_CONFIG_SCRIPT_NAME}")
])
#! /bin/sh
# $Progeny: config-script.in,v 1.3 2002/07/11 23:45:44 epg Exp $$
# This program is in the public domain.
# Too bad we don't have something like sysexits.h for POSIX sh...
EX_USAGE=64
@PROGENY_CONFIG_SCRIPT_VARS@
@PROGENY_CONFIG_SCRIPT_SET@
usage ()
{
cat <<EOF
usage: $0 --VAR ...
Print the value of the variable VAR. Run $0 -l or $0 --list for a list
of valid variable names.
EOF
}
listvars ()
{
for i in ${VARS}; do
echo ${i}
done
}
###############################################################################
if [ $# -eq 0 ]; then
usage
exit ${EX_USAGE}
fi
while [ $# -gt 0 ]; do
case $1 in
-l|--list-vars)
listvars
break
;;
--)
usage
exit ${EXIT_USAGE}
;;
--*)
var=$(echo $1 | sed -e 's/^--//' -e 's/-/_/g')
eval val="\$${var}"
if [ "x${val}" = 'x' ]; then
usage
exit ${EX_USAGE}
else
echo ${val}
fi
;;
*)
usage
exit ${EX_USAGE}
esac
shift
done
exit 0
#! /bin/sh
# $Progeny: config-script-mkdoc,v 1.2 2002/07/11 21:08:20 epg Exp $
# This program is in the public domain.
# Too bad we don't have something like sysexits.h for POSIX sh...
EX_USAGE=64
if [ $# -ne 2 ]; then
exit ${EX_USAGE}
fi
refentry=$1
name=$2
set -e
cat <<EOF > ${refentry}
<refmeta>
<refentrytitle>${name}</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>${name}</refname>
<refpurpose>config script doohickey</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>${name}</command>
<arg choice="opt">options</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><command>${name}</command> reports
stuff about the package's configuration.</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term><option>--VAR</option></term>
<listitem>
<para>Print the value of the variable VAR followed by a
newline. See below for a list of available
variables.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-l, --list</option></term>
<listitem>
<para>List the available variables.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Variables</title>
<itemizedlist>
EOF
cat >> ${refentry}
cat <<EOF >> ${refentry}
</itemizedlist>
</refsect1>
EOF
exit 0
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 12 20:47:09 2002