rfelker writes in Bug 736: stty.c includes unneeded, obsolete header memory.h
[oweals/busybox.git] / Rules.mak
index 335cb3664fe002072b50a84935cbd919c5ff41fe..ab6e311c661c76c356befb7f66c437fbbd03295b 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -117,28 +117,11 @@ check_gcc=$(shell \
 
 # A not very robust macro to check for available ld flags
 check_ld=$(shell \
-       echo "checking='$(1)'" >> foo.txt ; \
        if [ "x$(1)" != "x" ]; then \
-               $(LD) --help | grep -q \\$(1) && echo "-Wl,$(1)$(2)" ; \
+               $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \
        fi)
 
-# A not very robust macro to check for available as flags
-check_as=$(shell \
-       if [ "x$(1)" != "x" ]; then \
-               $(AS) --help | grep -q "\\$(1)" && echo "-Wa,$(1)$(2)" ; \
-       fi)
-
-
-# Setup some shortcuts so that silent mode is silent like it should be
-ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
-export MAKE_IS_SILENT=n
-SECHO=@echo
-else
-export MAKE_IS_SILENT=y
-SECHO=-@false
-endif
-
-#CFLAGS+=$(call check_gcc,-funsigned-char,)
+CFLAGS+=$(call check_gcc,-funsigned-char,)
 
 CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
 
@@ -214,19 +197,19 @@ else
 endif
 ifeq ($(strip $(CONFIG_DEBUG)),y)
     CFLAGS  +=$(WARNINGS) -g -D_GNU_SOURCE
-    LDFLAGS += $(call check_ld,-warn-common,)
+    LDFLAGS += $(call check_ld,--warn-common,)
     STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
 else
     CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
-    LDFLAGS += $(call check_ld,-warn-common,)
+    LDFLAGS += $(call check_ld,--warn-common,)
     LDFLAGS += $(call check_ld,--sort-common,)
     STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
 endif
 ifeq ($(strip $(CONFIG_STATIC)),y)
-    LDFLAGS += $(call check_ld,--static,)
-#else
-#    LIBRARIES += -ldl
+    PROG_CFLAGS += $(call check_gcc,-static,)
 endif
+CFLAGS_SHARED += $(call check_gcc,-shared,)
+LIB_CFLAGS+=$(CFLAGS_SHARED)
 
 ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
     CFLAGS_PIC:= $(call check_gcc,-fPIC,)
@@ -269,4 +252,59 @@ ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
 INSTALL_OPTS=
 endif
 
+#------------------------------------------------------------
+# Make the output nice and tight
+MAKEFLAGS += --no-print-directory
+export MAKE_IS_SILENT=n
+ifneq ($(findstring s,$(MAKEFLAGS)),)
+export MAKE_IS_SILENT=y
+SECHO := @-false
+DISP  := sil
+Q     := @
+else
+ifneq ($(V)$(VERBOSE),)
+SECHO := @-false
+DISP  := ver
+Q     := 
+else
+SECHO := @echo
+DISP  := pur
+Q     := @
+endif
+endif
+
+show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
+pur_disp_compile.c = echo "  "CC $(show_objs)
+pur_disp_compile.h = echo "  "HOSTCC $(show_objs)
+pur_disp_strip     = echo "  "STRIP $(show_objs)
+pur_disp_link      = echo "  "LINK $(show_objs)
+pur_disp_ar        = echo "  "AR $(ARFLAGS) $(show_objs)
+sil_disp_compile.c = true
+sil_disp_compile.h = true
+sil_disp_strip     = true
+sil_disp_link      = true
+sil_disp_ar        = true
+ver_disp_compile.c = echo $(cmd_compile.c)
+ver_disp_compile.h = echo $(cmd_compile.h)
+ver_disp_strip     = echo $(cmd_strip)
+ver_disp_link      = echo $(cmd_link)
+ver_disp_ar        = echo $(cmd_ar)
+disp_compile.c     = $($(DISP)_disp_compile.c)
+disp_compile.h     = $($(DISP)_disp_compile.h)
+disp_strip         = $($(DISP)_disp_strip)
+disp_link          = $($(DISP)_disp_link)
+disp_ar            = $($(DISP)_disp_ar)
+disp_gen           = $(SECHO) "  "GEN $@ ; true
+disp_doc           = $(SECHO) "  "DOC $(subst docs/,,$@) ; true
+cmd_compile.c      = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+cmd_compile.h      = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
+cmd_strip          = $(STRIPCMD) $@
+cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
+cmd_ar             = $(AR) $(ARFLAGS) $@ $^
+compile.c          = @$(disp_compile.c) ; $(cmd_compile.c)
+compile.h          = @$(disp_compile.h) ; $(cmd_compile.h)
+do_strip           = @$(disp_strip)     ; $(cmd_strip)
+do_link            = @$(disp_link)      ; $(cmd_link)
+do_ar              = @$(disp_ar)        ; $(cmd_ar)
+
 .PHONY: dummy