Nicer Make output

E.g.

  CXX    src/nix-log2xml/log2xml.o
  CC     src/bsdiff-4.3/bsdiff.o
  GEN    scripts/nix-channel
  LD     src/libmain/libnixmain.so
This commit is contained in:
Eelco Dolstra 2014-01-10 22:31:38 +01:00
parent e991ab942b
commit ca73c0102f
10 changed files with 33 additions and 17 deletions

View file

@ -1,7 +1,7 @@
clean_files :=
clean:
$(QUIET) rm -fv -- $(clean_files)
$(suppress) rm -fv -- $(clean_files)
dryclean:
@for i in $(clean_files); do if [ -e $$i ]; then echo $$i; fi; done | sort

View file

@ -7,7 +7,7 @@ dist_files :=
dist: $(dist_name).tar.bz2
$(dist_name).tar.bz2: $(dist_files)
$(QUIET) tar cvfj $@ $(dist_files) --transform 's,^,$(dist_name)/,'
$(suppress) tar cvfj $@ $(dist_files) --transform 's,^,$(dist_name)/,'
clean_files += $(dist_name).tar.bz2

View file

@ -4,7 +4,7 @@ define create-dir =
ifndef $(1)_SEEN
$(1)_SEEN = 1
$(1):
$(QUIET) install -d $(1)
$$(trace-install) install -d $(1)
endif
endef
@ -18,7 +18,7 @@ define install-file-as =
$$(eval $$(call create-dir,$$(dir $(2))))
$(2): $(1) | $$(dir $(2))
$(QUIET) install -m $(3) $(1) $(2)
$$(trace-install) install -m $(3) $(1) $(2)
endef
@ -48,6 +48,6 @@ define install-symlink =
$$(eval $$(call create-dir,$$(dir $(2))))
$(2): | $$(dir $(2))
$(QUIET) ln -sfn $(1) $(2)
$$(trace-install) ln -sfn $(1) $(2)
endef

View file

@ -10,8 +10,8 @@ define build-jar =
$$($(1)_PATH): $$($(1)_SOURCES)
@rm -rf $$($(1)_TMPDIR)
@mkdir -p $$($(1)_TMPDIR)
$(QUIET) javac $(GLOBAL_JAVACFLAGS) $$($(1)_JAVACFLAGS) -d $$($(1)_TMPDIR) $$($(1)_SOURCES)
$(QUIET) jar cf $$($(1)_PATH) -C $$($(1)_TMPDIR) .
$$(trace-javac) javac $(GLOBAL_JAVACFLAGS) $$($(1)_JAVACFLAGS) -d $$($(1)_TMPDIR) $$($(1)_SOURCES)
$$(trace-jar) jar cf $$($(1)_PATH) -C $$($(1)_TMPDIR) .
@rm -rf $$($(1)_TMPDIR)
$(1)_INSTALL_DIR ?= $$(libdir)/java

2
lib.mk
View file

@ -6,7 +6,6 @@ default: all
# Initialise some variables.
QUIET = @
bin_SCRIPTS :=
noinst_SCRIPTS :=
OS = $(shell uname -s)
@ -49,6 +48,7 @@ endif
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
include mk/tracing.mk
include mk/clean.mk
include mk/dist.mk
include mk/install.mk

View file

@ -65,7 +65,7 @@ define build-library =
$(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT)
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
$(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
@ -76,7 +76,7 @@ define build-library =
$$(eval $$(call create-dir,$$($(1)_INSTALL_DIR)))
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
$(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
$(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
@ -89,7 +89,7 @@ define build-library =
$(1)_PATH := $$(_d)/$$($(1)_NAME).a
$$($(1)_PATH): $$($(1)_OBJS)
$(QUIET) ar crs $$@ $$?
$(trace-ar) ar crs $$@ $$?
$(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)

View file

@ -1,8 +1,8 @@
%.o: %.cc
$(QUIET) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
%.o: %.cpp
$(QUIET) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
%.o: %.c
$(QUIET) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP
$(trace-cc) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP

View file

@ -23,7 +23,7 @@ define build-program =
$(1)_PATH := $$(_d)/$(1)
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
$(QUIET) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$(1)_INSTALL_DIR ?= $$(bindir)
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1)
@ -37,7 +37,7 @@ define build-program =
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
$(QUIET) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
else

View file

@ -9,4 +9,4 @@ define instantiate-template =
endef
%: %.in
$(QUIET) ./config.status --quiet --file $@
$(trace-gen) ./config.status --quiet --file $@

16
tracing.mk Normal file
View file

@ -0,0 +1,16 @@
V ?= 0
ifeq ($(V), 0)
trace-gen = @echo " GEN " $@;
trace-cc = @echo " CC " $@;
trace-cxx = @echo " CXX " $@;
trace-ld = @echo " LD " $@;
trace-ar = @echo " AR " $@;
trace-install = @echo " INST " $@;
trace-javac = @echo " JAVAC " $@;
trace-jar = @echo " JAR " $@;
suppress = @
endif