Repository: conan-io/conan-center-index

Issue:
[package] m4/1.4.18 won't build on x86
I'm indirectly using m4 because I'm trying to upgrade from `bison_installer/3.3.2@bincrafters/stable` (which doesn't use m4) to `bison/3.5.3`. The build fails on win32



### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **m4/1.4.18**
  * Operating System+version: **Windows, trying to compile x86**
  * Compiler+version: **MSVC 2019**
  * Docker image: **Visual Studio 2019**
  * Conan version: **conan 1.27.1**
  * Python version: **Python 3.7**

```
+-----+--------------------+--------------------+--------------+---------------+--------+
|   # | compiler.runtime   |   compiler.version | build_type   | compiler      | arch   |
|-----+--------------------+--------------------+--------------+---------------+--------|
|   1 | MD                 |                 16 | Release      | Visual Studio | x86    |
+-----+--------------------+--------------------+--------------+---------------+--------+
```


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
+------------------------+
| Profile                |
|------------------------|
| include(default)       |
|                        |
| [settings]             |
| arch=x86               |
| build_type=Release     |
| compiler=Visual Studio |
| compiler.runtime=MD    |
| compiler.version=16    |
| [options]              |
|                        |
| [env]                  |
|                        |
| [build_requires]       |
+------------------------+
[conan_create]

```


### Steps to reproduce (Include if Applicable)



### Logs (Include/Attach if Applicable)

https://ci.appveyor.com/project/ci-commercialbuildings/conan-openstudio-ruby/builds/34022248/job/cwpdsxi4huylrr92#L614

<details><summary>Click to expand log</summary>

```
Downloading conan_sources.tgz
m4/1.4.18: Configuring sources in C:\Users\appveyor\.conan\data\m4\1.4.18\_\_\source
m4/1.4.18: Copying sources to build folder
m4/1.4.18: Building your package in C:\Users\appveyor\.conan\data\m4\1.4.18\_\_\build\b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3
m4/1.4.18: Generator txt created conanbuildinfo.txt
m4/1.4.18: Calling build()
Conan:vcvars already set 
m4/1.4.18: run_in_windows_bash: "C:\Program Files\Git\usr\bin\bash.exe" --login -c ^"cd \^"/c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3\^" ^&^& /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/configure --help ^"
m4/1.4.18: `configure' configures GNU M4 1.4.18 to adapt to many kinds of systems.
m4/1.4.18: 
m4/1.4.18: Usage: /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/configure [OPTION]... [VAR=VALUE]...
m4/1.4.18: 
m4/1.4.18: To assign environment variables (e.g., CC, CFLAGS...), specify them as
m4/1.4.18: VAR=VALUE.  See below for descriptions of some of the useful variables.
m4/1.4.18: 
m4/1.4.18: Defaults for the options are specified in brackets.
m4/1.4.18: 
m4/1.4.18: Configuration:
m4/1.4.18:   -h, --help              display this help and exit
m4/1.4.18:       --help=short        display options specific to this package
m4/1.4.18:       --help=recursive    display the short help of all the included packages
m4/1.4.18:   -V, --version           display version information and exit
m4/1.4.18:   -q, --quiet, --silent   do not print `checking ...' messages
m4/1.4.18:       --cache-file=FILE   cache test results in FILE [disabled]
m4/1.4.18:   -C, --config-cache      alias for `--cache-file=config.cache'
m4/1.4.18:   -n, --no-create         do not create output files
m4/1.4.18:       --srcdir=DIR        find the sources in DIR [configure dir or `..']
m4/1.4.18: 
m4/1.4.18: Installation directories:
m4/1.4.18:   --prefix=PREFIX         install architecture-independent files in PREFIX
m4/1.4.18:                           [/usr/local]
m4/1.4.18:   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
m4/1.4.18:                           [PREFIX]
m4/1.4.18: 
m4/1.4.18: By default, `make install' will install all the files in
m4/1.4.18: `/usr/local/bin', `/usr/local/lib' etc.  You can specify
m4/1.4.18: an installation prefix other than `/usr/local' using `--prefix',
m4/1.4.18: for instance `--prefix=$HOME'.
m4/1.4.18: 
m4/1.4.18: For better control, use the options below.
m4/1.4.18: 
m4/1.4.18: Fine tuning of the installation directories:
m4/1.4.18:   --bindir=DIR            user executables [EPREFIX/bin]
m4/1.4.18:   --sbindir=DIR           system admin executables [EPREFIX/sbin]
m4/1.4.18:   --libexecdir=DIR        program executables [EPREFIX/libexec]
m4/1.4.18:   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
m4/1.4.18:   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
m4/1.4.18:   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
m4/1.4.18:   --libdir=DIR            object code libraries [EPREFIX/lib]
m4/1.4.18:   --includedir=DIR        C header files [PREFIX/include]
m4/1.4.18:   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
m4/1.4.18:   --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
m4/1.4.18:   --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
m4/1.4.18:   --infodir=DIR           info documentation [DATAROOTDIR/info]
m4/1.4.18:   --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
m4/1.4.18:   --mandir=DIR            man documentation [DATAROOTDIR/man]
m4/1.4.18:   --docdir=DIR            documentation root [DATAROOTDIR/doc/m4]
m4/1.4.18:   --htmldir=DIR           html documentation [DOCDIR]
m4/1.4.18:   --dvidir=DIR            dvi documentation [DOCDIR]
m4/1.4.18:   --pdfdir=DIR            pdf documentation [DOCDIR]
m4/1.4.18:   --psdir=DIR             ps documentation [DOCDIR]
m4/1.4.18: 
m4/1.4.18: Program names:
m4/1.4.18:   --program-prefix=PREFIX            prepend PREFIX to installed program names
m4/1.4.18:   --program-suffix=SUFFIX            append SUFFIX to installed program names
m4/1.4.18:   --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
m4/1.4.18: 
m4/1.4.18: System types:
m4/1.4.18:   --build=BUILD     configure for building on BUILD [guessed]
m4/1.4.18:   --host=HOST       cross-compile to build programs to run on HOST [BUILD]
m4/1.4.18: 
m4/1.4.18: Optional Features:
m4/1.4.18:   --disable-option-checking  ignore unrecognized --enable/--with options
m4/1.4.18:   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
m4/1.4.18:   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
m4/1.4.18:   --enable-silent-rules   less verbose build output (undo: "make V=1")
m4/1.4.18:   --disable-silent-rules  verbose build output (undo: "make V=0")
m4/1.4.18:   --enable-dependency-tracking
m4/1.4.18:                           do not reject slow dependency extractors
m4/1.4.18:   --disable-dependency-tracking
m4/1.4.18:                           speeds up one-time build
m4/1.4.18:   --disable-largefile     omit support for large files
m4/1.4.18:   --enable-threads={posix|solaris|pth|windows}
m4/1.4.18:                           specify multithreading API
m4/1.4.18:   --disable-threads       build without multithread safety
m4/1.4.18:   --enable-gcc-warnings   turn on lots of GCC warnings (for developers)
m4/1.4.18:   --disable-assert        turn off assertions
m4/1.4.18:   --disable-rpath         do not hardcode runtime library paths
m4/1.4.18:   --enable-c++            also build C++ sources
m4/1.4.18:   --enable-changeword     enable -W and changeword() builtin
m4/1.4.18: 
m4/1.4.18: Optional Packages:
m4/1.4.18:   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
m4/1.4.18:   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
m4/1.4.18:   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
m4/1.4.18:   --with-libsigsegv-prefix[=DIR]  search for libsigsegv in DIR/include and DIR/lib
m4/1.4.18:   --without-libsigsegv-prefix     don't search for libsigsegv in includedir and libdir
m4/1.4.18:   --with-libpth-prefix[=DIR]  search for libpth in DIR/include and DIR/lib
m4/1.4.18:   --without-libpth-prefix     don't search for libpth in includedir and libdir
m4/1.4.18:   --without-included-regex
m4/1.4.18:                           don't compile regex; this is the default on systems
m4/1.4.18:                           with recent-enough versions of the GNU C Library
m4/1.4.18:                           (use with caution on other systems).
m4/1.4.18:   --with-packager         String identifying the packager of this software
m4/1.4.18:   --with-packager-version Packager-specific version information
m4/1.4.18:   --with-packager-bug-reports
m4/1.4.18:                           Packager info for bug reports (URL/e-mail/...)
m4/1.4.18:   --with-syscmd-shell     shell used by syscmd [/bin/sh]
m4/1.4.18:   --with-dmalloc          use dmalloc, as in dmalloc.tar.gz from
m4/1.4.18:                           @/ftp.antaire.com:antaire/src/dmalloc.
m4/1.4.18: 
m4/1.4.18: Some influential environment variables:
m4/1.4.18:   CC          C compiler command
m4/1.4.18:   CFLAGS      C compiler flags
m4/1.4.18:   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
m4/1.4.18:               nonstandard directory <lib dir>
m4/1.4.18:   LIBS        libraries to pass to the linker, e.g. -l<library>
m4/1.4.18:   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
m4/1.4.18:               you have headers in a nonstandard directory <include dir>
m4/1.4.18:   CPP         C preprocessor
m4/1.4.18:   CXX         C++ compiler command
m4/1.4.18:   CXXFLAGS    C++ compiler flags
m4/1.4.18: 
m4/1.4.18: Use these variables to override the choices made by `configure' or to help
m4/1.4.18: it to find libraries and programs with nonstandard names/locations.
m4/1.4.18: 
m4/1.4.18: Report bugs to <bug-m4@gnu.org>.
m4/1.4.18: GNU M4 home page: <http://www.gnu.org/software/m4/>.
m4/1.4.18: General help using GNU software: <http://www.gnu.org/gethelp/>.
m4/1.4.18: Calling:
 > /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/configure --prefix=C:/Users/appveyor/.conan/data/m4/1.4.18/_/_/package/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3 --build=x86_64-windows-msvc --host=i686-windows-msvc
m4/1.4.18: run_in_windows_bash: "C:\Program Files\Git\usr\bin\bash.exe" --login -c ^"cd \^"/c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3\^" ^&^& /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/configure --prefix=C:/Users/appveyor/.conan/data/m4/1.4.18/_/_/package/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3 --build=x86_64-windows-msvc --host=i686-windows-msvc ^"
m4/1.4.18: checking for a BSD-compatible install... /usr/bin/install -c
m4/1.4.18: checking whether build environment is sane... yes
m4/1.4.18: checking for i686-windows-msvc-strip... :
m4/1.4.18: checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
m4/1.4.18: checking for gawk... gawk
m4/1.4.18: checking whether make sets $(MAKE)... no
m4/1.4.18: checking whether make supports nested variables... no
m4/1.4.18: checking whether make supports nested variables... (cached) no
m4/1.4.18: checking for i686-windows-msvc-gcc... cl -nologo
m4/1.4.18: checking whether the C compiler works... yes
m4/1.4.18: checking for C compiler default output file name... conftest.exe
m4/1.4.18: checking for suffix of executables... .exe
m4/1.4.18: checking whether we are cross compiling... yes
m4/1.4.18: checking for suffix of object files... obj
m4/1.4.18: checking whether we are using the GNU C compiler... no
m4/1.4.18: checking whether cl -nologo accepts -g... no
m4/1.4.18: checking for cl -nologo option to accept ISO C89... none needed
m4/1.4.18: checking whether cl -nologo understands -c and -o together... no
m4/1.4.18: checking for style of include used by make... none
m4/1.4.18: checking dependency style of /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/compile cl -nologo... none
m4/1.4.18: checking how to run the C preprocessor... /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/compile cl -nologo -E
m4/1.4.18: checking for grep that handles long lines and -e... /usr/bin/grep
m4/1.4.18: checking for egrep... /usr/bin/grep -E
m4/1.4.18: checking for ANSI C header files... yes
m4/1.4.18: checking for sys/types.h... yes
m4/1.4.18: checking for sys/stat.h... yes
m4/1.4.18: checking for stdlib.h... yes
m4/1.4.18: checking for string.h... yes
m4/1.4.18: checking for memory.h... yes
m4/1.4.18: checking for strings.h... no
m4/1.4.18: checking for inttypes.h... yes
m4/1.4.18: checking for stdint.h... yes
m4/1.4.18: checking for unistd.h... no
m4/1.4.18: checking minix/config.h usability... no
m4/1.4.18: checking minix/config.h presence... no
m4/1.4.18: checking for minix/config.h... no
m4/1.4.18: checking whether it is safe to define __EXTENSIONS__... yes
m4/1.4.18: checking whether _XOPEN_SOURCE should be defined... no
m4/1.4.18: checking for Minix Amsterdam compiler... no
m4/1.4.18: checking for i686-windows-msvc-ar... /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/ar-lib lib
m4/1.4.18: checking the archiver (/c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/ar-lib lib) interface... ar
m4/1.4.18: checking for i686-windows-msvc-ar... (cached) /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/ar-lib lib
m4/1.4.18: checking build system type... Invalid configuration `x86_64-windows-msvc': system `msvc' not recognized
m4/1.4.18: configure: error: /bin/sh /c/users/appveyor/.conan/data/m4/1.4.18/_/_/build/b93966b2c7cc0f91e10c82ffc67c5fb2d3101fa3/source_subfolder/build-aux/config.sub x86_64-windows-msvc failed
m4/1.4.18: 
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py
--- a/recipes/m4/all/conanfile.py
+++ b/recipes/m4/all/conanfile.py
@@ -39,7 +39,13 @@ def _configure_autotools(self):
             return self._autotools
         conf_args = []
         self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
-        self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder)
+        build_canonical_name = None
+        host_canonical_name = None
+        if self.settings.compiler == "Visual Studio":
+            # The somewhat older configure script of m4 does not understand the canonical names of Visual Studio
+            build_canonical_name = False
+            host_canonical_name = False
+        self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name)
         return self._autotools
 
     @contextmanager


Test patch: