bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU make troubleshooting


From: Paul Smith
Subject: Re: GNU make troubleshooting
Date: Tue, 11 Jul 2023 09:44:36 -0400
User-agent: Evolution 3.48.3 (by Flathub.org)

On Mon, 2023-07-10 at 17:17 -0400, Jeffrey Walton wrote:
> Yes, lots of conditionals and lots of shell'ing, like:
> 
> GREP ?= grep
> SED ?= sed
> 
> ifneq ($(wildcard /usr/xpg4/bin/grep),)
>   GREP := /usr/xpg4/bin/grep
> endif
> ifneq ($(wildcard /usr/xpg4/bin/sed),)
>   SED := /usr/xpg4/bin/sed
> endif
> 
> SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(GREP) -i -c -E 'CC:
> (Sun|Studio)')
> GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E
> '(llvm|clang)' | $(GREP) -i -c -E '(gcc|g\+\+)')
> XLC_COMPILER := $(shell $(CXX) -qversion 2>/dev/null |$(GREP) -i -c
> "IBM XL")
> CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -
> c
> -E '(llvm|clang)')
> INTEL_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -
> c
> '\(icc\)')
> ...

But, what about this do you want to know?

If what you want to know is "what was the result of all this", the
database print (-p) option will show you what make computed as the
final value for each of these variables, and also what linenumber of
the makefile was used to set the final version:

  # makefile (from 'Makefile', line 12)
  GCC_COMPILER := 0
   ...
  # makefile (from 'Makefile', line 1)
  GREP = grep
   ...


I don't want to suggest that everything is just peachy.  There are lots
of rough edges for working with GNU Make and Makefiles, there is no
question about that.  I'm just trying to understand clearly what things
will actually be useful, rather than simply spewing out more output
similar to what -d does.

I do agree with Bruno that there is a lot of implicit knowledge for
working with Makefiles that is not well described, or in some cases
even hinted at, in the manual.  Maybe I'll try to add a new chapter
this weekend... writing will be a nice change from hacking.  I've spent
enough time on StackOverflow that I have a good idea of the places
people have troubles.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]