Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 16 Aug 2012 18:18:05 +0200
From: Luca Barbato <lu_zero@...too.org>
To: musl@...ts.openwall.com
Subject: [PATCH 1/3] makefile: add silent rules

make V=0 to enable them
---

I forgot to resend it long ago once fixed, sorry

 Makefile |   62 ++++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index 683850d..fa44829 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,8 @@ CFLAGS_ALL_SHARED = $(CFLAGS_ALL) -fPIC -DSHARED -O3
 
 AR      = $(CROSS_COMPILE)ar
 RANLIB  = $(CROSS_COMPILE)ranlib
+INSTALL = install
+LN      = ln -sf
 
 ALL_INCLUDES = $(sort $(wildcard include/*.h include/*/*.h) $(GENH))
 
@@ -48,6 +50,22 @@ TOOL_LIBS = lib/musl-gcc.specs
 ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
 ALL_TOOLS = tools/musl-gcc
 
+V ?= 1
+
+ifeq ($(strip $(V)), 0)
+Q      = @
+ECHO   = printf "$(1)\t%s\n" $(2)
+BRIEF  = CC AS AR LD HOSTCC SH LN
+SILENT = DEPCC RM RANLIB
+MSG    = $@
+M      = @$(call ECHO,$(TAG),$@);
+$(foreach VAR,$(BRIEF), \
+    $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
+$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
+$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
+endif
+
+
 LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH).so.1
 
 -include config.mak
@@ -57,25 +75,25 @@ all: $(ALL_LIBS) $(ALL_TOOLS)
 install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:tools/%=$(DESTDIR)$(bindir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
 
 clean:
-	rm -f crt/*.o
-	rm -f $(OBJS)
-	rm -f $(LOBJS)
-	rm -f $(ALL_LIBS) lib/*.[ao] lib/*.so
-	rm -f $(ALL_TOOLS)
-	rm -f $(GENH) 
-	rm -f include/bits
+	$(RM) crt/*.o
+	$(RM) $(OBJS)
+	$(RM) $(LOBJS)
+	$(RM) $(ALL_LIBS) lib/*.[ao] lib/*.so
+	$(RM) $(ALL_TOOLS)
+	$(RM) $(GENH)
+	$(RM) include/bits
 
 distclean: clean
-	rm -f config.mak
+	$(RM) config.mak
 
 include/bits:
 	@test "$(ARCH)" || { echo "Please set ARCH in config.mak before running make." ; exit 1 ; }
-	ln -sf ../arch/$(ARCH)/bits $@
+	$(Q)ln -sf ../arch/$(ARCH)/bits $@
 
 include/bits/alltypes.h.sh: include/bits
 
 include/bits/alltypes.h: include/bits/alltypes.h.sh
-	sh $< > $@
+	$(Q)sh $< > $@
 
 src/ldso/dynlink.lo: arch/$(ARCH)/reloc.h
 
@@ -97,41 +115,41 @@ lib/libc.so: $(LOBJS)
 	-Wl,-soname=libc.so -o $@ $(LOBJS) $(LIBCC)
 
 lib/libc.a: $(OBJS)
-	rm -f $@
+	$(RM) $@
 	$(AR) rc $@ $(OBJS)
 	$(RANLIB) $@
 
 $(EMPTY_LIBS):
-	rm -f $@
+	$(RM) $@
 	$(AR) rc $@
 
 lib/%.o: crt/%.o
-	cp $< $@
+	$(Q)cp $< $@
 
 lib/musl-gcc.specs: tools/musl-gcc.specs.sh config.mak
-	sh $< "$(includedir)" "$(libdir)" "$(LDSO_PATHNAME)" > $@
+	$(Q)sh $< "$(includedir)" "$(libdir)" "$(LDSO_PATHNAME)" > $@
 
 tools/musl-gcc: config.mak
-	printf '#!/bin/sh\nexec gcc "$$@" -specs "%s/musl-gcc.specs"\n' "$(libdir)" > $@
-	chmod +x $@
+	$(Q)printf '#!/bin/sh\nexec gcc "$$@" -specs "%s/musl-gcc.specs"\n' "$(libdir)" > $@
+	$(Q)chmod +x $@
 
 $(DESTDIR)$(bindir)/%: tools/%
-	install -D $< $@
+	$(INSTALL) -D $< $@
 
 $(DESTDIR)$(libdir)/%.so: lib/%.so
-	install -D -m 755 $< $@
+	$(INSTALL) -D -m 755 $< $@
 
 $(DESTDIR)$(libdir)/%: lib/%
-	install -D -m 644 $< $@
+	$(INSTALL) -D -m 644 $< $@
 
 $(DESTDIR)$(includedir)/%: include/%
-	install -D -m 644 $< $@
+	$(INSTALL) -D -m 644 $< $@
 
 $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(syslibdir)
-	ln -sf $(libdir)/libc.so $@ || true
+	$(LN) $(libdir)/libc.so $@ || true
 
 $(DESTDIR)$(syslibdir):
-	install -d -m 755 $(DESTDIR)$(syslibdir)
+	$(INSTALL) -d -m 755 $(DESTDIR)$(syslibdir)
 
 .PRECIOUS: $(CRT_LIBS:lib/%=crt/%)
 
-- 
1.7.8.rc1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.