]> granicus.if.org Git - flex/commitdiff
Configure checks for GNU m4.
authorJohn Millaway <john43@users.sourceforge.net>
Thu, 11 Dec 2003 01:43:13 +0000 (01:43 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Thu, 11 Dec 2003 01:43:13 +0000 (01:43 +0000)
Environment variable M4 overrides built-in m4 path.
Generated m4 does a late check for GNU m4.

configure.in
filter.c
main.c

index ba232d6f05fa568e6cb20eb099d08f112510c66a..819de5f5bd81a458ade6c5966d5e8604c6a3b333 100644 (file)
@@ -43,7 +43,22 @@ AC_PROG_RANLIB
 
 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
index 40c8cf214de81922f118a205dacc001d6f3d35ae..b925c57a2d530e52e5eb955b8d92424ce319f092 100644 (file)
--- a/filter.c
+++ b/filter.c
 /*  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;
@@ -248,6 +253,7 @@ int filter_tee_header (struct filter *chain)
         */
 
        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);
@@ -262,6 +268,7 @@ int filter_tee_header (struct filter *chain)
 
        }
 
+    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);
diff --git a/main.c b/main.c
index 1c1722f7720851733e519f949b054fd9b34659a7..f5f1812d526911d31b81bd68be7a3368cd3c4ff0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -211,6 +211,7 @@ int main (argc, argv)
 void check_options ()
 {
        int     i;
+    const char * m4 = NULL;
 
        if (lex_compat) {
                if (C_plus_plus)
@@ -342,9 +343,12 @@ void check_options ()
                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. */
@@ -431,7 +435,7 @@ void check_options ()
         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);
@@ -453,7 +457,7 @@ void check_options ()
 
     /* 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));
@@ -488,7 +492,7 @@ void flexend (exit_status)
                                skelname);
        }
 
-#if 0 
+#if 0
                fprintf (header_out,
                         "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
                fprintf (header_out,
@@ -646,7 +650,7 @@ void flexend (exit_status)
                 /* must be null-terminated */
                 NULL};
 
-                
+
                 for (i=0; undef_list[i] != NULL; i++)
                     fprintf (header_out, "#undef %s\n", undef_list[i]);
         }