Subject: m4 Macros for configure

From: Chris Ross <[email-masked]>
Date: Wed, 01 Sep 2004 11:36:02 -0400

Hi.  The definition of smr_SWITCH (in both acinclude.m4
and aclocal.m4) uses "m4_substr" and "m4_len", neither of
which exist in any m4 I know about.  (The three on my
Solaris 8 machine are /usr/ccs/bin/m4, /usr/xpg4/bin/m4,
and GNU m4 1.4.)

   Does this exist in some newer or more odd M4?  Shouldn't
we just use "substr" and "len"?

   The sign that this has failed is in the --help output of
the generated configure.  It contains the macro calls,
rather than the intended strings resulting from the
macro.

   Anyone know where these came from?  (And why there's
ones in both aclocal.m4, and acinclude.m4?)

                             - Chris

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Wed, 1 Sep 2004 16:20:31 +0000

> ones in both aclocal.m4, and acinclude.m4?)

You need a more recent autoconf. This part is tricky, I know how to make
autoconf <= 2.13 happy and autoconf > 2.13 happy, but not both together.

If someone knows, feel free to fix this, but I don't think it worth
the effort. It only affects the --help output, and if the recent autoconf
is used to create releases, then the release will be ok.

Regards,
Mikhael.

---

From: Chris Ross <[email-masked]>
Date: Wed, 01 Sep 2004 12:40:05 -0400

> is used to create releases, then the release will be ok.

   Well, at the very least, you could check which version of
autoconf is running, right?  And if it's <= 2.13, you can
redefine m4_substr and m4_len to substr and len, yes?

   I'll take a look into autoconf and see if I see how to
do this anywhere from inside of m4...

                        - Chris

---

From: Mikhael Goikhman <[email-masked]>
Date: Wed, 1 Sep 2004 16:48:24 +0000

> ones in both aclocal.m4, and acinclude.m4?)

aclocal.m4 is generated from acinclude.m4 by aclocal that's from automake
(before this generated file is used by autoconf to generate ./configure).

Regards,
Mikhael.

---

From: Chris Ross <[email-masked]>
Date: Wed, 01 Sep 2004 13:54:31 -0400

> (before this generated file is used by autoconf to generate ./configure).

   Excellent.  Thank you for that information.

   Okay, I've applied a fairly ugly patch to acinclude.m4.
It tears apart the AC_ACVERSION macro into the major and
minor number [string]s, and then if the minor number is
13, defines m4_substr and m4_len.  It works for me, and
I've tested that the macro leaves m4_* unset when I
hand-feed it a 2.51 instead of AC_ACVERSION.

   Unfortunately, m4 only knows about strings.  So, do
do a <= 2.13, I'd have to use syscmd() and sysval().
I could do that, but I wasn't sure it was worth the
effort.  But, I don't know what versions of autoconf
are likely to be in use.

   Let me know if anything like this would be acceptable.

   Thanks...

                        - Chris
Index: acinclude.m4
===================================================================
RCS file: /home/cvs/fvwm/fvwm/acinclude.m4,v
retrieving revision 1.49
diff -u -u -r1.49 acinclude.m4
--- acinclude.m4	8 Jul 2004 10:08:09 -0000	1.49
+++ acinclude.m4	1 Sep 2004 17:50:11 -0000
@@ -103,6 +103,17 @@
 fi
 ])
 
+dnl Versions of autoconf 2.13 and older don't have m4_substr and m4_len
+dnl built into them.  So, check the version of autoconf we're running,
+dnl and if it's 2.13, substitude alternative definitions for them.
+define([SEGMENT1],[substr([$1],0,ifelse(index([$1],.),-1,len([$1]),index([$1],.)))])dnl
+define([SEGMENT2],[ifelse( index([$1],.), -1, [], SEGMENT1(substr([$1], incr(index([$1],.)))))])dnl
+
+define([AC_ACVERSION_MAJOR],[SEGMENT1(AC_ACVERSION)])dnl
+define([AC_ACVERSION_MINOR],[SEGMENT2(AC_ACVERSION)])dnl
+ifelse(AC_ACVERSION_MINOR,13,
+[define([m4_substr],[substr([$1],[$2])])dnl
+define([m4_len],[len([$1])])dnl])dnl
 
 dnl Configure-time switch with default
 dnl