On Wed, Sep 10, 2008 at 2:33 PM, Eric Blake <ebb9@xxxxxxx> wrote: > 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? top level > If at the top level, is SOME_DEP defined before this point? Normally, you Yes, in a different file that was m4_include'd beforehand. > 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. OK I understand that the dependencies and mechanisms behind AC_REQUIRE are making this a bit more complex but I can't even properly inject another definition for a macro that is simply called (such as the case of _MY_HELPER_MACRO which is called from MY_MACRO). >> 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. Here is a full, standalone autoconfiscated package to reproduce what I'm trying to do: -------------------- begin configure.ac -------------------- AC_INIT([example], [0.1]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) MY_MACRO # Initialize the test suite. AC_CONFIG_TESTDIR([tests]) AM_MISSING_PROG([AUTOM4TE], [autom4te]) AC_CONFIG_FILES([ Makefile tests/Makefile ]) AC_OUTPUT -------------------- end configure.ac -------------------- -------------------- begin Makefile.am -------------------- ACLOCAL_AMFLAGS = -I build-aux SUBDIRS = . tests -------------------- end Makefile.am -------------------- -------------------- begin build-aux/mypkg.m4 -------------------- AC_DEFUN([SOME_DEP], [echo some dep ]) AC_DEFUN([_MY_HELPER_MACRO], [echo my helper macro ]) AC_DEFUN([MY_MACRO], [AC_REQUIRE([SOME_DEP])dnl echo some code here _MY_HELPER_MACRO([whatever]) echo some more code here ]) -------------------- end build-aux/mypkg.m4 -------------------- -------------------- begin tests/Makefile.am -------------------- EXTRA_DIST = testsuite.at $(TESTSUITE) TESTSUITE = $(srcdir)/testsuite CLEANFILES = atconfig check-local: atconfig $(TESTSUITE) $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS) clean-local: test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean rm -f -r autom4te.cache AUTOTEST = $(AUTOM4TE) --language=autotest $(TESTSUITE): $(srcdir)/testsuite.at $(AUTOTEST) -I '$(srcdir)' $@.at -o $@.tmp mv $@.tmp $@ atconfig: $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status tests/$@ -------------------- end tests/Makefile.am -------------------- -------------------- begin tests/testsuite.at -------------------- m4_define([AT_PACKAGE_STRING], [whatever]) AT_INIT AT_BANNER([Heavy tests]) AT_SETUP([End ot end test of MY_MACRO]) MY_MACRO dnl check that MY_MACRO worked... AT_CLEANUP[]dnl AT_BANNER([Lightweight tests]) AT_SETUP([Smaller test of MY_MACRO]) m4_rename([SOME_DEP], [SAVED_SOME_DEP]) m4_rename([_MY_HELPER_MACRO], [SAVED__MY_HELPER_MACRO]) AC_DEFUN([SOME_DEP], [echo hooked cheap dep]) AC_DEFUN([_MY_HELPER_MACRO], [echo hooked cheap helper]) echo test begins MY_MACRO echo test ends m4_rename([SAVED_SOME_DEP], [SOME_DEP]) m4_rename([SAVED__MY_HELPER_MACRO], [_MY_HELPER_MACRO]) AT_CLEANUP[]dnl -------------------- end tests/testsuite.at -------------------- (alternatively you can use http://www.tsunanet.net/~tsuna/example.tar.gz instead) -- Benoit Sigoure aka Tsuna EPITA Research and Development Laboratory _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf