Environment variable M4 overrides built-in m4 path.
Generated m4 does a late check for GNU m4.
AC_PATH_PROG(BISON, bison,bison)
AC_PATH_PROG(HELP2MAN, help2man, help2man)
-AC_PATH_PROGS(M4, gnum4 gm4 m4, m4)
+
+
+# Check for a GNU m4 that supports --prefix-builtins
+AC_PATH_PROGS(M4, gm4 gnum4 m4, m4)
+if test x"$M4" != x; then
+ AC_MSG_CHECKING([for GNU m4])
+ case `$M4 --help < /dev/null 2>&1` in
+ *prefix-builtins*) AC_MSG_RESULT(yes) ;;
+ *) AC_MSG_RESULT(no) ;
+ AC_MSG_ERROR([GNU M4 1.4 is required]) ;;
+ esac
+else
+ AC_MSG_ERROR([GNU M4 1.4 is required]) ;
+fi
+AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
+
AC_PATH_PROG(INDENT, indent, indent)
dnl if INDENT is set to 'indent' then we didn't find indent
if test "$INDENT" != indent ; then
/* PURPOSE. */
#include "flexdef.h"
+static const char * check_4_gnu_m4 =
+ "m4_dnl ifdef(`__gnu__', ,"
+ "`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)"
+ " m4exit(2)')\n";
+
/** global chain. */
struct filter *output_chain = NULL;
*/
if (write_header) {
+ fputs (check_4_gnu_m4, to_h);
fputs ("m4_changecom`'m4_dnl\n", to_h);
fputs ("m4_changequote`'m4_dnl\n", to_h);
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h);
}
+ fputs (check_4_gnu_m4, to_c);
fputs ("m4_changecom`'m4_dnl\n", to_c);
fputs ("m4_changequote`'m4_dnl\n", to_c);
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
void check_options ()
{
int i;
+ const char * m4 = NULL;
if (lex_compat) {
if (C_plus_plus)
outfile_created = 1;
}
+
/* Setup the filter chain. */
output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
- filter_create_ext(output_chain,"m4","-P",0);
+ if ( !(m4 = getenv("M4")))
+ m4 = M4;
+ filter_create_ext(output_chain, m4, "-P", 0);
filter_create_int(output_chain, filter_fix_linedirs, NULL);
/* For debugging, only run the requested number of filters. */
buf_init(&tmpbuf, sizeof(char));
for (i = 1; i <= lastsc; i++) {
char *str, *fmt = "#define %s %d\n";
-
+
str = (char*)flex_alloc(strlen(fmt) + strlen(scname[i]) + (int)(1 + log(i)/log(10)) + 2);
sprintf(str, fmt, scname[i], i - 1);
buf_strappend(&tmpbuf, str);
/* Place a bogus line directive, it will be fixed in the filter. */
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
-
+
/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
outn ((char *) (userdef_buf.elts));
skelname);
}
-#if 0
+#if 0
fprintf (header_out,
"#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
fprintf (header_out,
/* must be null-terminated */
NULL};
-
+
for (i=0; undef_list[i] != NULL; i++)
fprintf (header_out, "#undef %s\n", undef_list[i]);
}