0

I want to compile GNU make in Mac Mojave,and the OS default c compiler is clang.when I run:

./configure

The output is :

 dolphins-MacBook-Air:make-3.82 dolphin$ ./configure
    checking for a BSD-compatible install... /usr/local/bin/ginstall -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
    checking for gawk... no
    checking for mawk... no
    checking for nawk... no
    checking for awk... awk
    checking whether make sets $(MAKE)... yes
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in `/Users/dolphin/Desktop/make-3.82':
    configure: error: C compiler cannot create executables
    See `config.log' for more details.

How to specify the C compiler when install make? I have tried:

./configure CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7
CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7 ./configure

But It does not work.

Dolphin
  • 29,069
  • 61
  • 260
  • 539
  • It seems you're using Homebrew, so why not install GNU Make from Homebrew? `brew install make` – Nikos C. May 23 '19 at 07:37
  • Because I want to install 3.X version of GNU make,I am already installed 4.X but could not compile OpenJDK 10.@NikosC. – Dolphin May 23 '19 at 07:44
  • I just checked this on macOS 10.13 and it works with default clang (so just `./configure`, no `CC=`). In any event, is your path to GCC actually correct? Here, I need to do `./configure CC=/usr/local/Cellar/gcc/9.1.0/bin/gcc-9` – Nikos C. May 23 '19 at 07:59
  • Possible duplicate of [Configuring for a compiler different than the default while running configure](https://stackoverflow.com/questions/10435816/configuring-for-a-compiler-different-than-the-default-while-running-configure) – Mathieu May 23 '19 at 08:07
  • @Mathieu: The answers there all say to set the `CC` environment variable, and this question states that does not work. – Eric Postpischil May 23 '19 at 08:17
  • Been a long time but I think GCC's special and you have to give it `GCC=`. – Joshua Nov 15 '20 at 23:11

2 Answers2

1

So I decided to post an answer after all. The way I remember solving this problem reliably was doing PATH=/path/to/gcc/install/bin:$PATH ; ./configure && make bootstrap.

For you it would be PATH=/usr/local/Cellar/gcc@7/7.4.0_2/bin:$PATH I had a hard time resisting quoting the @ character so if you get a crazy error try quoting it.

Joshua
  • 40,822
  • 8
  • 72
  • 132
1

Try it instead on make cli

$ CC=/usr/local/Cellar/gcc@7/7.4.0_2/bin/gcc-7 make

But first must ensure the Makefile was perfectly generated and restart it all over again which needs make clean