1 dnl -*-autoconf-*- *@--GLOB-HEADER--@*
3 dnl Common library of autoconf macros
5 dnl (c) 1997 Mark Wooding, except for macros and documentation where noted.
8 dnl----- Licensing notice ---------------------------------------------------
10 dnl This file is part of the Common Files Distribution (`common')
12 dnl `Common' is free software; you can redistribute it and/or modify
13 dnl it under the terms of the GNU General Public License as published by
14 dnl the Free Software Foundation; either version 2 of the License, or
15 dnl (at your option) any later version.
17 dnl `Common' is distributed in the hope that it will be useful,
18 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 dnl GNU General Public License for more details.
22 dnl You should have received a copy of the GNU General Public License
23 dnl along with `common'; if not, write to the Free Software Foundation,
24 dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 dnl *@--NOTICE--@* Common File Distribution
28 dnl --- *@-mdw_AUTO_VERSION-@* ---
30 dnl Author: Mark Wooding
32 dnl Synopsis: mdw_AUTO_VERSION
36 dnl Use: Defines an m4 macro AUTO_VERSION which contains the current
37 dnl version number, worked out in some clever way.
39 dnl AC_DEFUN([mdw_AUTO_VERSION], [nobody cares...])
40 m4_define([mdw_AUTO_VERSION], [m4_define([AUTO_VERSION], m4_esyscmd([
41 if test -d .git && version=$(git describe --abbrev=4 2>/dev/null); then
42 case "$(git diff-index --name-only HEAD)" in
43 "") ;; *) version="$version+" ;;
45 elif cat RELEASE 2>/dev/null; then
46 version=$(cat RELEASE)
47 elif test -f debian/changelog; then
48 version=$(sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog)
55 dnl --- *@-mdw_LIBTOOL_VERSION_INFO-@* ---
57 dnl Author: Mark Wooding
59 dnl Synopsis: mdw_LIBTOOL_VERSION
63 dnl Use: Decodes the PACKAGE_VERSION variable as a libtool
64 dnl version-info string. Strictly speaking, this is very
67 AC_DEFUN([mdw_LIBTOOL_VERSION_INFO], [
68 set -- $(echo $PACKAGE_VERSION |
69 sed 's:[^.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$]:\1 \2 \3:'
71 LIBTOOL_VERSION_INFO="$(expr $[]1 + $[]2):$[]3:$[]2"
72 AC_SUBST([LIBTOOL_VERSION_INFO])
75 dnl --- *@-mdw_DECL_ENVIRON-@* ---
77 dnl Author: Mark Wooding
79 dnl Synopsis: mdw_DECL_ENVIRON
83 dnl Use: Searches for a declaration of the global `environ' variable.
84 dnl If one is found in one of the `usual' places, DECL_ENVIRON
85 dnl is defined as a preprocessor symbol.
87 AC_DEFUN([mdw_DECL_ENVIRON],
88 [AC_CACHE_CHECK([for declaration of \`environ'], mdw_cv_environ,
89 [AC_EGREP_CPP([\<environ\>],
90 [#include <sys/types.h>
97 #endif], [mdw_cv_environ=yes], [mdw_cv_environ=no])])
98 if test $mdw_cv_environ = yes; then
99 AC_DEFINE([DECL_ENVIRON], [1],
100 [Define if you have the `environ' vector of environment variables.])
103 dnl --- *@-mdw_DEFINE_PATHS-@*
105 dnl Author: Mark Wooding
107 dnl Synopsis: mdw_DEFINE_PATHS(CODE)
109 dnl Arguments: CODE = shell script code to execute
111 dnl Use: Fixes up various variables so that pathname defines can be
112 dnl defined. Within CODE, you may use the following macros:
114 dnl mdw_PROG(NAME) Transformed program name
116 dnl mdw_PATH(PATH) Expanded path (may contain variables)
118 dnl mdw_DEFINE_PROG(SYMBOL, PROG)
119 dnl Define a symbol as a transformed
122 dnl mdw_DEFINE_PATH(SYMBOL, NAME)
123 dnl Define a symbol as an expanded path
125 AC_DEFUN([mdw_DEFINE_PATHS],
126 [mdw_prefix=$prefix mdw_exec_prefix=$exec_prefix
127 mdw_transform=`echo "$program_transform_name"|sed 's,\\\\\\\\,\\\\,g; s,\\$\\$,$,g'`
128 test "$prefix" = "NONE" && prefix=$ac_default_prefix
129 test "$exec_prefix" = "NONE" && exec_prefix=$prefix
131 prefix=$mdw_prefix exec_prefix=$mdw_exec_prefix])
133 AC_DEFUN([mdw_PROG], [`echo "$1"|sed "$mdw_transform"`])
134 AC_DEFUN([mdw_PATH], [dnl
138 *\\$[]*) t=\`eval echo "$t"\`;; dnl
142 AC_DEFUN([mdw_DEFINE_PROG],
143 [AC_DEFINE_UNQUOTED([$1], ["mdw_PROG([$2])"],
144 [Program name for $2.])])
145 AC_DEFUN([mdw_DEFINE_PATH], [AC_DEFINE_UNQUOTED([$1], ["mdw_PATH([$2])"],
146 [Pathname for $2.])])
148 dnl --- *@-mdw_MANEXT-@* ---
150 dnl Author: Mark Wooding
152 dnl Synopsis: mdw_MANEXT
156 dnl Use: Sets the substitution `manext' for man page extensions.
158 AC_DEFUN([mdw_MANEXT], [
159 AC_ARG_WITH([man-ext],
160 [ --with-man-ext=EXT give manpages the EXT extension (e.g., foo.3EXT)],
161 [manext=$withval], [manext=mLib])
164 dnl----- That's all, folks --------------------------------- *@--GLOB-END--@*