I'm using the following Makefile with GNU make. As you can see, I prepended an @ to the lines which call g++, to prevent them from being echo'ed to the console.
However, the g++ commands are still echo'ed. Does anyone know how to prevent this?
I have an almost identical Makefile for a C project, and it works correctly..
Thanks!
# for portability. SHELL = /bin/sh CXX = g++ # compile flags. CXXFLAGS = -g -pedantic -Wall -Wextra -Werror -march=native -O2 \ -fwhole-program -flto TARGET = program MANPAGE = program.8 SOURCES = $(shell echo src/*.cpp) HEADERS = $(shell echo src/*.h) OBJECTS = $(SOURCES:.cpp=.o) VERSION = 0.1-beta # installation paths. PREFIX = $(DESTDIR)/usr/local BINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man/man8 # standard targets. all: $(TARGET) $(TARGET): $(OBJECTS) @echo "[LD] $@" @$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) man: @(cd man; gzip < $(MANPAGE) > $(MANPAGE).gz) install: $(TARGET) man @install -D -m 755 $(TARGET) $(BINDIR)/$(TARGET) @install -D -m 744 man/$(MANPAGE).gz $(MANDIR)/$(MANPAGE).gz install-strip: $(TARGET) man @install -D -m 755 -s $(TARGET) $(BINDIR)/$(TARGET) @install -D -m 744 man/$(MANPAGE).gz $(MANDIR)/$(MANPAGE).gz uninstall: @$(RM) $(BINDIR)/$(TARGET) @$(RM) $(MANDIR)/$(MANPAGE).gz clean: @$(RM) $(OBJECTS) distclean: clean @$(RM) $(TARGET) @(cd man; $(RM) $(MANPAGE).gz) %.o: %.cpp $(HEADERS) @echo "[CXX] $<" @$(CXX) $(CXXFLAGS) -c -o $@ $< .PHONY: all man install install-strip uninstall clean distclean
src/*.hfiles? If you do not, built-in rule for .o files will take precedence. Usingwildcardinstead ofshellshould solve that.make -sor adding a line.SILENT:would both suppress all the output frommake. However, the leading@markers should do that too. I personally don't like makefiles that don't show, or have a mechanism to show, exactly what is being executed because it is hard to debug when something goes wrong. That being the case, I don't use either-sor.SILENT:on a regular basis.