1

Lets suppose I want the benefits provided by implicit rules while also showing a progress message in the form of:

Compiling [main.cpp]
(...)
Linking...

Writing the %.o: %.cpp rule with the message replaces the implicit rule.
And writing the whole rule explicitly defeats the goal of using implicit rules.
So, any suggestions?

PS: If this isn't currently possible with make, it's ok.
PPS: NO CMAKE
PPPS: NO AUTOFOOLS

Community
  • 1
  • 1
bit2shift
  • 656
  • 1
  • 9
  • 17
  • Is the answer for [this question](http://stackoverflow.com/q/24820594/258523) close enough to what you want? You might be able tweak it to only output the message once with some clever use of `$(eval)` if necessary. – Etan Reisner Mar 22 '16 at 01:38
  • @EtanReisner Close, but it gave me an idea on how to do it. – bit2shift Mar 22 '16 at 02:25
  • You can prepend things to `COMPILE.cpp` to do part of what you want but getting `$@` in there correctly was escaping me in some quick attempts. I'm curious to see what you come up with. – Etan Reisner Mar 22 '16 at 02:35
  • @EtanReisner Posted it as answer below. – bit2shift Mar 22 '16 at 02:44

2 Answers2

0

Something like this:

%.o: %.cpp
    @echo compiling $<
    $(CC) -c $(CXXFLAGS) $(DEFS) $< -o $@
Joel
  • 1,805
  • 1
  • 22
  • 22
0

Because $(CXX) is used to compile C++ sources and $(CC) is used to link the objects together, I can prepend an echo to both.

CC = @echo "Linking..."; g++
CXX = @echo "Compiling [$<]"; g++

This will output the desired results.

bit2shift
  • 656
  • 1
  • 9
  • 17