[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Suggestion: Allow cleanup code in AC_LANG_POP
From: |
Martin Wilck |
Subject: |
Suggestion: Allow cleanup code in AC_LANG_POP |
Date: |
Fri, 16 Mar 2001 17:24:46 +0100 (CET) |
Hello,
I'd like to suggest the following small patch (rationale below):
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.124
diff -u -r1.124 aclang.m4
--- aclang.m4 2001/03/13 12:28:19 1.124
+++ aclang.m4 2001/03/16 16:09:41
@@ -108,6 +108,14 @@
[AC_FATAL([$1: unknown language: $2])])])
+# _AC_LANG_DISPATCH_NONFATAL(MACRO, LANG, ARGS)
+# ---------------------------------------------
+# Like _AC_LANG_DISPATCH, but don't complain.
+m4_define([_AC_LANG_DISPATCH_NONFATAL],
+[m4_ifdef([$1($2)],
+ [m4_indir([$1($2)], m4_shiftn(2, $@))])])
+
+
# _AC_LANG_SET(OLD, NEW)
# ----------------------
# Output the shell code needed to switch from OLD language to NEW language.
@@ -121,7 +129,8 @@
# m4-current-language when m4_require is used. Something more subtle
# might be possible, but at least for the time being, play it safe.
m4_defun([_AC_LANG_SET],
+# CALL _AC_LANG_CLEANUP for OLD language before switching to NEW.
-[_AC_LANG_DISPATCH([AC_LANG], [$2])])
+[m4_ifval([$1], [_AC_LANG_DISPATCH_NONFATAL([_AC_LANG_CLEANUP], [$1])])
+_AC_LANG_DISPATCH([AC_LANG], [$2])])
# AC_LANG(LANG)
=====================================================================
Rationale:
This would enable an optional macro _AC_LANG_CLEANUP(LANG) that,
if defined for LANG, would be called when AC_LANG_POP() was called
for LANG and could undo stuff done by AC_LANG_PUSH(LANG).
I would like to have this opportunity in order to add m4_pushdef
statements to AC_LANG(LANG), which would be popped by _AC_LANG_CLEANUP:
m4_define([AC_LANG(Preprocessed Fortran 77)],
[m4_pushdef([m4_FC], [F77])
m4_pushdef([m4_dot_F],[.F])
...
])
m4_define([_AC_LANG_CLEANUP(Preprocessed Fortran 77)],
[m4_popdef([m4_FC])
m4_popdef([m4_dot_F])
])
m4_define([AC_LANG(Preprocessed Fortran 90)],
[m4_pushdef([m4_FC], [F90])
m4_pushdef([m4_dot_F],[.F90])
...
])
m4_define([_AC_LANG_CLEANUP(Preprocessed Fortran 77)],
[m4_popdef([m4_FC])
m4_popdef([m4_dot_F])
])
This would be very helpful for code reuse (code for preprocessed Fortran
77 and 90 is very similar, except that the compiler is $F77 in one case
and $F90 in the other, and that some file extensions vary).
By using pushdefs like that, I could extend on the already used autoconf
prtogramming technique with things like
ac_cv_[]_AC_LANG_ABBREV[]_whatever = ...
I think this is a clean solution that does not affect running code
but might add more opportunities for language switching.
Regards
Martin
--
Martin Wilck <address@hidden>
Institute for Tropospheric Research, Permoserstr. 15, D-04318 Leipzig, Germany
Tel. +49-341-2352151 / Fax +49-341-2352361
- Suggestion: Allow cleanup code in AC_LANG_POP,
Martin Wilck <=