우분투 20.04 m4 patch

아래와 같은 m4 빌드 에러는 우분투 18.04 이상 버전을 사용할 경우 발생한다.

| ../../m4-1.4.17/lib/freadahead.c: In function ‘freadahead’:
| ../../m4-1.4.17/lib/freadahead.c:91:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
|    91 |  #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
|       |   ^~~~~
| make[3]: *** [Makefile:1842: freadahead.o] Error 1
| make[3]: *** Waiting for unfinished jobs....
| ../../m4-1.4.17/lib/fseeko.c: In function ‘rpl_fseeko’:
| ../../m4-1.4.17/lib/fseeko.c:109:4: error: #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
|   109 |   #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
|       |    ^~~~~
| make[3]: *** [Makefile:1842: fseeko.o] Error 1
...

_IO_ftrylockfile 옵션이 GCC7부터 삭제되어 발생한 문제이며, _IO_EOF_SEEN 옵션으로 변경하면 해결할 수 있다.

diff -Nura host-m4-1.4.17_old/lib/fflush.c host-m4-1.4.17_new/lib/fflush.c
--- host-m4-1.4.17_old/lib/fflush.c	2013-09-22 15:15:20.000000000 +0900
+++ host-m4-1.4.17_new/lib/fflush.c	2020-05-30 21:04:10.383906871 +0900
@@ -33,7 +33,7 @@
 #undef fflush
 
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
 static void
@@ -71,7 +71,7 @@
 
 #endif
 
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
 
 # if (defined __sferror || defined __DragonFly__) && defined __SNPT /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
 
@@ -145,7 +145,7 @@
   if (stream == NULL || ! freading (stream))
     return fflush (stream);
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
   clear_ungetc_buffer_preserving_position (stream);
 
diff -Nura host-m4-1.4.17_old/lib/fpurge.c host-m4-1.4.17_new/lib/fpurge.c
--- host-m4-1.4.17_old/lib/fpurge.c	2013-09-22 15:15:20.000000000 +0900
+++ host-m4-1.4.17_new/lib/fpurge.c	2020-05-30 21:04:45.575543668 +0900
@@ -61,7 +61,7 @@
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   fp->_IO_read_end = fp->_IO_read_ptr;
   fp->_IO_write_ptr = fp->_IO_write_base;
   /* Avoid memory leak when there is an active ungetc buffer.  */
diff -Nura host-m4-1.4.17_old/lib/freadahead.c host-m4-1.4.17_new/lib/freadahead.c
--- host-m4-1.4.17_old/lib/freadahead.c	2013-09-22 15:15:20.000000000 +0900
+++ host-m4-1.4.17_new/lib/freadahead.c	2020-05-30 21:00:08.606540606 +0900
@@ -25,7 +25,7 @@
 size_t
 freadahead (FILE *fp)
 {
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_write_ptr > fp->_IO_write_base)
     return 0;
   return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -Nura host-m4-1.4.17_old/lib/freading.c host-m4-1.4.17_new/lib/freading.c
--- host-m4-1.4.17_old/lib/freading.c	2013-09-22 15:15:20.000000000 +0900
+++ host-m4-1.4.17_new/lib/freading.c	2020-05-30 21:03:45.696164271 +0900
@@ -31,7 +31,7 @@
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return ((fp->_flags & _IO_NO_WRITES) != 0
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
               && fp->_IO_read_base != NULL));
diff -Nura host-m4-1.4.17_old/lib/fseeko.c host-m4-1.4.17_new/lib/fseeko.c
--- host-m4-1.4.17_old/lib/fseeko.c	2013-09-22 15:15:55.000000000 +0900
+++ host-m4-1.4.17_new/lib/fseeko.c	2020-05-30 21:02:24.749025027 +0900
@@ -47,7 +47,7 @@
 #endif
 
   /* These tests are based on fpurge.c.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_read_end == fp->_IO_read_ptr
       && fp->_IO_write_ptr == fp->_IO_write_base
       && fp->_IO_save_base == NULL)
@@ -121,7 +121,7 @@
           return -1;
         }
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       fp->_flags &= ~_IO_EOF_SEEN;
       fp->_offset = pos;
 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
diff -Nura host-m4-1.4.17_old/lib/stdio-impl.h host-m4-1.4.17_new/lib/stdio-impl.h
--- host-m4-1.4.17_old/lib/stdio-impl.h	2013-09-22 15:20:02.000000000 +0900
+++ host-m4-1.4.17_new/lib/stdio-impl.h	2020-05-30 21:11:15.965671007 +0900
@@ -18,6 +18,12 @@
    the same implementation of stdio extension API, except that some fields
    have different naming conventions, or their access requires some casts.  */
 
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
+   internals.  */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
 
 /* BSD stdio derived implementations.  */

우분투가 판올림되면 GCC 및 각종 라이브러리가 업데이트 되기 때문에 크로스컴파일을 해야하는 환경이라면 가급적 우분투 판올림을 조심스럽게 진행해야 한다. 진심으로...