[1677] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

something useful

daemon@ATHENA.MIT.EDU (Kev)
Fri Aug 30 15:40:19 1996

From: Kev <klmitch@MIT.EDU>
To: krbdev@MIT.EDU
Date: Fri, 30 Aug 1996 15:40:14 EDT

This is something that would allow us to do macro substitution in Makefile's,
of the form @foobar(1,2,3)@ => blah 1 2 3; Ted seems to think it's useful :)
The autoconf way of invoking it would be AC_SUBST_MACRO(<name>, <number of
arguments>, <sed replacement text>); for instance:

AC_SUBST_MACRO(CC, 1, $CC \1)

might replace "@CC(-g)@" in a Makefile with "gcc -g" (if $CC in the configure
script happens to evaluate to gcc).  It uses the exact same magic that AC_SUBST
uses to prevent a symbol from being defined more than once, so you can't define
a substitution and then a macro with the same name.  Also, note that you can't
redefine one of these macros.  Anyway, here's the stuff that could be added to
acgeneral.m4 (or aclocal.m4 or acsite.m4 or...):

define(AC_SUBST_MACRO,
[ifdef([AC_SUBST_$1], ,
[define ([AC_SUBST_$1], )dnl
AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
s%@$1(AC_MAKE_SED_REGEXP($2))@%$3%p
AC_DIVERT_POP()dnl
])])

define(AC_MAKE_SED_REGEXP,
[changequote(<<, >>)dnl
[	 ]*\(.*\)<<>>dnl
changequote([, ])dnl
ifelse($1, 1, ,
[,AC_MAKE_SED_REGEXP(decr($1))])])

questions?  comments?  ideas?  diversions?
-- 
Kevin L. Mitchell
----------------------------------------------------------
kev@alias.undernet.org  kev@wildstar.net   klmitch@mit.edu
         http://web.mit.edu/klmitch/www/home.html
         Finger klmitch@monk.mit.edu for PGP keys



home help back first fref pref prev next nref lref last post