Skip to content

Mingw with Autotools is incomplete #701

@avih

Description

@avih

Commit 0571d11 is "Make mingw build properly from autotools", however, I think it's incomplete.

Specifically, ./configure fails for me, I think incorrectly, with:

checking for working terminal libraries... Cannot find terminal libraries - configure failed

while "terminal libraries" are likely not actually needed or used in a mingw build (it doesn't use curses or termcap or terminfo etc in a windows/mingw build as far as I know).

This was tested in w64devkit environment and configure generated by me on linux using make -f Makefile.aut, but I presume the same issue would happen with a pre-generated configure script distributed with a release tarball.

The same issue was observed on Alpine linux with the mingw-w64-gcc package installed (and invoking ./configure --host=<mingw-host>).

In both cases make -f Makefile.wng CC=<mingw-gcc> (the "stand alone" mingw makefile) does work.

If I workaround the terminal lib issue (just comment out the relevant exit 1 in configure) then it does complete successfully, and, assuming funcs.h and help.c exist (which make -f Makefile.aut does generate, though it only uses perl, and doesn't have fallbacks like the wng or wnm makefiles have to sh or a native binary), then make it does end up building successfully.

Some notable differences between the autotools mingw build and the Makefile.wng build:

  1. defines.h is diffrent. See below the full diff, however, at the very least the some dirs are different, regex setup is missing, as well as some default file names like .less vs _less and more, and OUTBUF_SIZE is also different (see 1f88659).
  2. During the build, there are a lot of these warnings, which don't exist with the Makefile.wng build:
funcs.h:443:12: warning: '_pclose' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  443 | public int pclose(FILE *f);
      |            ^~~~~~
For reference, here's a full diff (ignoring whitespace changes) of `defines.wn` to the generated `defines.h` (click me):
diff --git a/defines.wn b/defines.h
index 120d29e..e553a55 100644
--- a/defines.wn
+++ b/defines.h
@@ -1,28 +1,27 @@
-/*
- * Copyright (C) 1984-2025  Mark Nudelman
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Less License, as specified in the README file.
- *
- * For more information, see the README file.
- */
+/* defines.h.  Generated from defines.h.in by configure.  */
+/* defines.h.in.  Generated from configure.ac by autoheader.  */
 
 
-/* Windows definition file for less.  */
-/*
- * This file has 2 sections:
+/* Unix definition file for less.  -*- C -*-
+ *
+ * This file has 3 sections:
  * User preferences.
- * Settings always true for Windows systems. 
+ * Settings always true on Unix.
+ * Settings automatically determined by configure.
+ *
+ * * * * * *  WARNING  * * * * * *
+ * If you edit defines.h by hand, do "touch stamp-h" before you run make
+ * so config.status doesn't overwrite your changes.
  */
 
-
 /* User preferences.  */
 
 /*
  * SECURE is 1 if you wish to disable a bunch of features in order to
  * be safe to run by unprivileged users.
+ * SECURE_COMPILE is set by the --with-secure configure option.
  */
-#define	SECURE		0
+#define SECURE          SECURE_COMPILE
 
 /*
  * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
@@ -59,7 +58,6 @@
  * EDIT_PGM is the name of the (default) editor to be invoked.
  */
 #define EDITOR          (!SECURE)
-#define	EDIT_PGM	"edit"
 
 /*
  * TAGS is 1 if you wish to support tag files.
@@ -67,7 +65,7 @@
 #define TAGS            (!SECURE)
 
 /*
- * USERFILE is 1 if you wish to allow a .less file to specify 
+ * USERFILE is 1 if you wish to allow a .lesskey or .less file to specify 
  * user-defined key bindings.
  */
 #define USERFILE        (!SECURE)
@@ -77,13 +75,13 @@
  * This will generally work if your system provides the "popen" function
  * and the "echo" shell command.
  */
-#define	GLOB		0
+#define GLOB            (!SECURE)
 
 /*
  * PIPEC is 1 if you wish to have the "|" command
  * which allows the user to pipe data into a shell command.
  */
-#define	PIPEC		1
+#define PIPEC           (!SECURE && HAVE_POPEN)
 
 /*
  * LOGFILE is 1 if you wish to allow the -o option (to create log files).
@@ -91,7 +89,7 @@
 #define LOGFILE         (!SECURE)
 
 /*
- * OSC8_SEARCH is 1 if you wish to allow the ^O^O and related commands
+ * OSC8_LINK is 1 if you wish to allow the ^O^O and related commands
  * (to open OSC8 hyperlinks).
  */
 #define OSC8_LINK       1
@@ -118,21 +116,42 @@
  * LESSHISTFILE is the filename of the history file
  * (in the HOME directory).
  */
-#define	LESSKEYFILE		"_less"
-#define	LESSKEYFILE_SYS		"c:\\_sysless"
-#define	DEF_LESSKEYINFILE	"_lesskey"
-#define	LESSKEYINFILE_SYS	"c:\\_syslesskey"
-#define LESSHISTFILE		"_lesshst"
-
-
-/* Settings always true for Windows systems.  */
+#define LESSKEYFILE             ".less"
+#define LESSKEYFILE_SYS         SYSDIR "/sysless"
+#define DEF_LESSKEYINFILE       ".lesskey"
+#define LESSKEYINFILE_SYS       SYSDIR "/syslesskey"
+#define LESSHISTFILE            ".lesshst"
 
+/* Autodetect mingw */
+#if defined(__MINGW32__)
+/*
+ * Define MSDOS_COMPILER if compiling under Microsoft C.
+ */
 #define MSDOS_COMPILER  WIN32C
 
 /*
  * Pathname separator character.
  */
 #define PATHNAME_SEP    "\\"
+#else
+/*
+ * Define MSDOS_COMPILER if compiling under Microsoft C.
+ */
+#define MSDOS_COMPILER  0
+
+/*
+ * Pathname separator character.
+ */
+#define PATHNAME_SEP    "/"
+#endif
+
+/* Settings always true on Unix.  */
+
+/*
+ * The value returned from tgetent on success.
+ * Some HP-UX systems return 0 on success.
+ */
+#define TGETENT_OK  1
 
 /*
  * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes.
@@ -147,7 +166,7 @@
 /*
  * Define if you have the <sgstat.h> header file.
  */
-#define HAVE_SGSTAT_H	0
+/* #undef HAVE_SGSTAT_H */
 
 /*
  * HAVE_PERROR is 1 if your system has the perror() call.
@@ -163,19 +182,28 @@
 /*
  * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
  */
-#define	HAVE_SHELL	0
+#define HAVE_SHELL      1
 
 /*
  * Default shell metacharacters and meta-escape character.
  */
-#define	DEF_METACHARS	"; *?\t\n'\"()<>|&"
-#define	DEF_METAESCAPE	""
+#define DEF_METACHARS   "; *?\t\n'\"()<>[]|&^`#\\$%=~{},"
+#define DEF_METAESCAPE  "\\"
 
 /* 
  * HAVE_DUP is 1 if your system has the dup() call.
  */
 #define HAVE_DUP        1
 
+/* Define to 1 if you have the memcpy() function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the strchr() function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the strstr() function. */
+#define HAVE_STRSTR 1
+
 /* Define to 1 to support reading lesskey source files (not just binary). */
 #define HAVE_LESSKEYSRC 1
 
@@ -197,7 +225,7 @@
 #define CMDBUF_SIZE     2048    /* Buffer for multichar commands */
 #define UNGOT_SIZE      200     /* Max chars to unget() */
 #define LINEBUF_SIZE    1024    /* Initial max size of line in input file */
-#define	OUTBUF_SIZE	8192	/* Output buffer: 8K avoids end-of-buffer bugs in win_flush */
+#define OUTBUF_SIZE     1024    /* Output buffer */
 #define PROMPT_SIZE     2048    /* Max size of prompt string */
 #define TERMBUF_SIZE    2048    /* Termcap buffer for tgetent */
 #define TERMSBUF_SIZE   1024    /* Buffer to hold termcap strings */
@@ -206,196 +234,264 @@
 #define LINENUM_POOL    1024    /* Size of line number pool */
 #endif
 
-/* Define to `long' if <sys/types.h> doesn't define.  */
-/* #define	off_t	long */
-
-/* Define if you need to in order for stat and other things to work.  */
-/* #undef _POSIX_SOURCE */
-
 /* Define as the return type of signal handlers (int or void).  */
 #define RETSIGTYPE void
 
+/* Settings automatically determined by configure.  */
 
-/*
- * Regular expression library.
- * Define exactly one of the following to be 1:
- * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
- * HAVE_RE_COMP: BSD re_comp()
- * HAVE_REGCMP: System V regcmp()
- * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
- * NO_REGEX: pattern matching is supported, but without metacharacters.
- */
-/* #undef HAVE_POSIX_REGCOMP */
-/* #undef HAVE_RE_COMP */
-/* #undef HAVE_REGCMP */
-#ifdef MINGW
-    #ifdef USE_POSIX_REGCOMP
-	#define HAVE_POSIX_REGCOMP 1
-    #else
-	#ifdef USE_GNU_REGEX
-	    #define HAVE_GNU_REGEX  1
-        #else
-            #ifdef USE_REGEXP_C
-		#define HAVE_V8_REGCOMP 1
-		#define HAVE_REGEXEC2   1
-            #else
-                #define NO_REGEX 1
-	    #endif
-	#endif
-    #endif
-#else
-#define HAVE_V8_REGCOMP 1
-/* #undef NO_REGEX */
-#define HAVE_REGEXEC2 1
-#endif
 
-/* Define HAVE_VOID if your compiler supports the "void" type. */
-#define HAVE_VOID 1
+/* Define EDIT_PGM to your editor. */
+#define EDIT_PGM "vi"
 
 /* Define HAVE_CONST if your compiler supports the "const" modifier. */
 #define HAVE_CONST 1
 
-/* Define HAVE_TIME_T if your system supports the "time_t" type. */
-#define HAVE_TIME_T 1
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
 
-/* Define HAVE_STRERROR if you have the strerror() function. */
-#define HAVE_STRERROR 1
+/* Define HAVE_ERRNO if you have the errno variable. */
+#define HAVE_ERRNO 1
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the `fchmod' function. */
+/* #undef HAVE_FCHMOD */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
 
 /* Define HAVE_FILENO if you have the fileno() macro. */
 #define HAVE_FILENO 1
 
-/* Define HAVE_ERRNO if you have the errno variable */
-#define HAVE_ERRNO 1
-/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined in errno.h */
-#define MUST_DEFINE_ERRNO 0
+/* Define to 1 if you have the `fsync' function. */
+/* #undef HAVE_FSYNC */
+
+/* GNU regex library */
+/* #undef HAVE_GNU_REGEX */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+/* #undef HAVE_LOCALE */
+
+/* Define to 1 if you have the `nanosleep' function. */
+#define HAVE_NANOSLEEP 1
+
+/* Define to 1 if you have the <ncursesw/termcap.h> header file. */
+/* #undef HAVE_NCURSESW_TERMCAP_H */
+
+/* Define to 1 if you have the <ncurses/termcap.h> header file. */
+/* #undef HAVE_NCURSES_TERMCAP_H */
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
+/* #undef HAVE_OSPEED */
+
+/* PCRE (Perl-compatible regular expression) library */
+/* #undef HAVE_PCRE */
+
+/* PCRE2 (Perl-compatible regular expression) library */
+/* #undef HAVE_PCRE2 */
+
+/* Define to 1 if you have the `poll' function. */
+/* #undef HAVE_POLL */
+
+/* Define to 1 if you have the `popen' function. */
+#define HAVE_POPEN 1
+
+/* POSIX regcomp() and regex.h */
+/* #undef HAVE_POSIX_REGCOMP */
+
+/* Define to 1 if you have the `realpath' function. */
+/* #undef HAVE_REALPATH */
+
+/* System V regcmp() */
+/* #undef HAVE_REGCMP */
+
+/* */
+#define HAVE_REGEXEC2 1
+
+/* BSD re_comp() */
+/* #undef HAVE_RE_COMP */
+
 /* Define HAVE_SETTABLE_ERRNO if the errno variable can be assigned to. */
 #define HAVE_SETTABLE_ERRNO 1
 
-/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
-#define HAVE_SYS_ERRLIST 1
+/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
+/* #undef HAVE_SIGEMPTYSET */
 
-/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
-#define HAVE_OSPEED 0
-/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
- * in termcap.h. */
-#define MUST_DEFINE_OSPEED 0
+/* Define to 1 if you have the `sigprocmask' function. */
+/* #undef HAVE_SIGPROCMASK */
 
-/* Define HAVE_LOCALE if you have locale.h and setlocale. */
-#define HAVE_LOCALE 0
+/* Define HAVE_SIGSETJMP if you have sigsetjmp and siglongjmp. */
+/* #undef HAVE_SIGSETJMP */
 
-/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
-#define HAVE_TERMIOS_FUNCS 0
+/* Define to 1 if you have the `sigsetmask' function. */
+/* #undef HAVE_SIGSETMASK */
 
-/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
-#define HAVE_UPPER_LOWER 1
+/* Define to 1 if the system has the type `sigset_t'. */
+/* #undef HAVE_SIGSET_T */
 
-/* Define if you have the _setjmp function.  */
-#define HAVE__SETJMP	1
-
-/* Define if you have the memcpy function.  */
-#define HAVE_MEMCPY 1
-
-/* Define if you have the popen function.  */
-#define HAVE_POPEN 1
-
-/* Define if you have the sigsetmask function.  */
-#define HAVE_SIGSETMASK	0
-
-/* Define if you have the sigprocmask function.  */
-#define HAVE_SIGPROCMASK	0
-
-/* Define if you have the sigset_t type and sigemptyset macro */
-#define HAVE_SIGSET_T	0
-#define HAVE_SIGEMPTYSET	0
-
-/* Define if you have the stat function.  */
-#define HAVE_STAT 1
-
-/* Define if you have the strchr function.  */
-#define HAVE_STRCHR 1
-
-/* Define if you have the system function.  */
-#define HAVE_SYSTEM	1
-
-/* Define if you have the snprintf function.  */
+/* Define to 1 if you have the `snprintf' function. */
 #define HAVE_SNPRINTF 1
 
-/* Define if you have the <ctype.h> header file.  */
-#define HAVE_CTYPE_H 1
+/* Define to 1 if you have the `stat' function. */
+#define HAVE_STAT 1
 
-/* Define if you have the <wctype.h> header file.  */
-#define HAVE_WCTYPE_H 1
+/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
+#define HAVE_STAT_INO 1
 
-/* Define if you have the <errno.h> header file.  */
-#define HAVE_ERRNO_H 1
+/* Define to 1 if you have the <stdckdint.h> header file. */
+/* #undef HAVE_STDCKDINT_H */
 
-/* Define if you have the <fcntl.h> header file.  */
-#define HAVE_FCNTL_H 1
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
 
-/* Define if you have the <limits.h> header file.  */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <stdio.h> header file.  */
+/* Define to 1 if you have the <stdio.h> header file. */
 #define HAVE_STDIO_H 1
 
-/* Define if you have the <string.h> header file.  */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <stdlib> header file. */
+/* Define to 1 if you have the <stdlib.h> header file. */
 #define HAVE_STDLIB_H 1
 
-/* Define if you have the <sys/ioctl.h> header file.  */
-#define HAVE_SYS_IOCTL_H 0
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
 
-/* Define if you have the <sys/ptem.h> header file.  */
-#define HAVE_SYS_PTEM_H	0
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
 
-/* Define if you have the <sys/stream.h> header file.  */
-#define HAVE_SYS_STREAM_H	0
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
 
-/* Define if you have the <termcap.h> header file.  */
-#define HAVE_TERMCAP_H	0
+/* Define to 1 if you have the `strsignal' function. */
+/* #undef HAVE_STRSIGNAL */
 
-/* Define if you have the <termio.h> header file.  */
-#define HAVE_TERMIO_H	0
+/* Define to 1 if you have the `system' function. */
+#define HAVE_SYSTEM 1
 
-/* Define if you have the <termios.h> header file.  */
-#define HAVE_TERMIOS_H 0
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
+#define HAVE_SYS_ERRLIST 1
 
-/* Define if you have the <time.h> header file.  */
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+/* #undef HAVE_SYS_IOCTL_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/stream.h> header file. */
+/* #undef HAVE_SYS_STREAM_H */
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+/* #undef HAVE_SYS_WAIT_H */
+
+/* Define to 1 if you have the <termcap.h> header file. */
+/* #undef HAVE_TERMCAP_H */
+
+/* Define HAVE_TERMINFO if you have the terminfo library. */
+/* #undef HAVE_TERMINFO */
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
+/* #undef HAVE_TERMIOS_FUNCS */
+
+/* Define to 1 if you have the <termios.h> header file. */
+/* #undef HAVE_TERMIOS_H */
+
+/* Define to 1 if you have the <termio.h> header file. */
+/* #undef HAVE_TERMIO_H */
+
+/* Define to 1 if you have the <time.h> header file. */
 #define HAVE_TIME_H 1
 
-/* Define if you have the <unistd.h> header file.  */
-#ifdef MINGW
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define to 1 if you have the `ttyname' function. */
+/* #undef HAVE_TTYNAME */
+
+/* Define to 1 if you have the <unistd.h> header file. */
 #define HAVE_UNISTD_H 1
-#else
-#define HAVE_UNISTD_H 0
-#endif
 
-/* Define if you have the <values.h> header file.  */
-#ifdef _MSC_VER
-#define HAVE_VALUES_H 0
-#else
-#ifdef MINGW
-#define HAVE_VALUES_H 0
-#else
-#define HAVE_VALUES_H 1
-#endif
-#endif
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
+#define HAVE_UPPER_LOWER 1
 
-#define	popen	_popen
+/* Define to 1 if you have the `usleep' function. */
+#define HAVE_USLEEP 1
 
-/*
- * _snprintf in msvcrt/ucrt is non-compliant (no '\0' on overflow).
- * ucrt has a C99 snprintf, and is the default since msvc 2015 (ver 1900).
- * mingw with msvcrt has its own C99 snprintf, and with ucrt there's no need.
- * so if we don't have a compliant snprintf, specify that there's none.
- */
-#if !defined (MINGW) && (!defined(_MSC_VER) || (_MSC_VER < 1900))
-#undef HAVE_SNPRINTF
-#define HAVE_SNPRINTF 0
-#endif
+/* Henry Spencer V8 regcomp() and regexp.h */
+#define HAVE_V8_REGCOMP 1
 
-#ifndef MINGW
-#pragma warning(disable:4996)
-#endif
+/* Define to 1 if you have the <values.h> header file. */
+/* #undef HAVE_VALUES_H */
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
+#define HAVE_WCTYPE 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the `_setjmp' function. */
+#define HAVE__SETJMP 1
+
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined in
+   errno.h. */
+/* #undef MUST_DEFINE_ERRNO */
+
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
+   termcap.h. */
+/* #undef MUST_DEFINE_OSPEED */
+
+/* pattern matching is supported, but without metacharacters. */
+/* #undef NO_REGEX */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "less"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "less 1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "less"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1"
+
+/* Define SECURE_COMPILE=1 to build a secure version of less. */
+#define SECURE_COMPILE 0
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+/* #undef STAT_MACROS_BROKEN */
+
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
+#define STDC_HEADERS 1
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#define _FILE_OFFSET_BITS 64
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */

So I think the following are needed to really be able to say that the mingw autotools build is reasonably useful:

  1. Fix configure it so that it doesn't expect "terminal library" if we're doing a mingw build.
  2. Ensure the resulting defines.h is close enough to defines.wn, because it includes some windows-specific changes which are likely desirable.
  3. Address that pclose warning.

CC @Keno (as the author of 0571d11).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions