help-flex
[Top][All Lists]
Advanced

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

Re: 2.5.31: checking for GNU m4


From: Tim Van Holder
Subject: Re: 2.5.31: checking for GNU m4
Date: Fri, 4 Jul 2003 15:27:44 +0200

> at all. It just does this:
> 
> 0 main.c 347 filter_create_ext(output_chain,"m4","-P",0);
> 
> That "m4" clearly has to be become some macro call whose 
> value is deduced
> by configure via config.h, so platforms where GNU m4 is installed as
> "gnum4" or similar can use that.

Is the use of -P the only reason flex needs _GNU_ m4?
If so, can't it simply include an m4 file that simulates this?
For example, autoconf's m4sugar does this:

## ------------------------------- ##
## 1. Simulate --prefix-builtins.  ##
## ------------------------------- ##

# m4_define
# m4_defn
# m4_undefine
define([m4_define],   defn([define]))
define([m4_defn],     defn([defn]))
define([m4_undefine], defn([undefine]))

m4_undefine([define])
m4_undefine([defn])
m4_undefine([undefine])



Simply adding similar entries for all builtins (either based on the
POSIX spec, or on the output of the dumpdef builtin) would achieve
the same effect as using the GNU m4 -P option.

Something like the following in configure.ac might do the trick:

AC_PATH_PROG([M4], [gm4 gnum4 m4], [no])
if test x$M4 = xno; then
  AC_MSG_ERROR([M4 is required])
fi
ac_m4_builtins=`echo dumpdef |$M4 2>&1`
if x$? = x0; then # dumpdef works
  dnl Assume output is x: <def(x)>
  ac_m4_builtins=`echo dumpdef |$M4 2>&1 |sed 's/^\([^:]*\):\([
\t]*<[^>]*>\|\)/\1/'`
else
  ac_m4_builtins="foo blah" # Hardcode builtins defined by POSIX
fi

...
AC_CONFIG_COMMAND([prefix-builtins.m4], [
cat >prefix-builtins.m4 <<\EOF
define([m4_define],   defn([define]))
define([m4_defn],     defn([defn]))
define([m4_undefine], defn([undefine]))

m4_undefine([define])
m4_undefine([defn])
m4_undefine([undefine])

EOF
for ac_m4_builtin in $ac_m4_builtins; do
  test "$ac_m4_builtin" = "define" && continue
  test "$ac_m4_builtin" = "undefine" && continue
  test "$ac_m4_builtin" = "defn" && continue
  cat >prefix-builtins.m4 <<\EOF
m4_define([m4_$ac_m4_builtin], m4_defn([$ac_m4_builtin]))
m4_undefine([$ac_m4_builtin])
EOF
done
])

(Note: the above is untested and should be considered pseudo-code)






reply via email to

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