autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dependency injection and unit testing of M4 macros


From: Eric Blake
Subject: Re: Dependency injection and unit testing of M4 macros
Date: Wed, 10 Sep 2008 06:33:26 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080708 Thunderbird/2.0.0.16 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to tsuna on 9/10/2008 2:39 AM:
> 
> I tried to use m4_rename like so:
> m4_rename([SOME_DEP], [SAVED_SOME_DEP])dnl <-- this is line 300
> AC_DEFUN([SOME_DEP], [echo hooked cheap dep])
> # my test with MY_MACOR here
> m4_rename([SAVED_SOME_DEP], [SOME_DEP])

Was this at the top level, or inside the definition of another macro?  If
at the top level, is SOME_DEP defined before this point?  Normally, you
can AC_DEFUN a macro before its dependencies, so long as the dependencies
are defined before the macro is expanded, but if you are trying m4_rename
at the top level, then you don't have the luxury of a deferred definition
of dependent macros.  If you were using m4_define instead of m4_defun,
then I would suggest m4_pushdef/m4_popdef rather than m4_rename, but
m4_pushdef doesn't play nicely with dependency tracking.

> 
> AC_DEFUN == m4_defun, right?  And m4_defun does a m4_define, so what
> am I doing wrong?

But it also tracks dependency, and sets things up to define witness macros
when SOME_DEP is expanded.  I'm not sure this will work for you, because
once you've expanded your alternate SOME_DEP, I don't know how you would
reset the witness machinery to think that SOME_DEP had not been used.

You can always turn on m4 tracing to try and figure out what is going on.
 For that matter, since you are trying to fake out dependencies to gain
some speed, it may be worth looking into m4sugar, to figure out which
undocumented witness macros to undefine to restore state (although I'm not
sure m4sugar should be modified to add such a macro to its public API).
But I'm afraid I won't be very effective at offering suggestions without a
standalone example that I can try compiling, instead of just snippets.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjHvpYACgkQ84KuGfSFAYAkOQCgvy0/q86NOQui4sU9ouADBXq2
+ycAniBE/FS7wFebriEE+eniZGtDWzxV
=OXXH
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]