BUILD: Makefile: switch to quiet mode by default for CC/LD/AR

These commands are now replaced with a prefix and the target name only
in quiet mode, which is much more readable and allows better detection
of build warnings than the default verbose mode. Using V=1 switches back
to the detailed output.
This commit is contained in:
Willy Tarreau 2018-11-19 08:15:54 +01:00
parent 6db8266409
commit 1611965e7d
2 changed files with 26 additions and 6 deletions

View File

@ -3,6 +3,9 @@
# You should use it this way :
# [g]make TARGET=os ARCH=arch CPU=cpu USE_xxx=1 ...
#
# By default the detailed commands are hidden for a cleaner output, but you may
# see them by appending "V=1" to the make command.
#
# Valid USE_* options are the following. Most of them are automatically set by
# the TARGET, others have to be explicitly specified :
# USE_DLMALLOC : enable use of dlmalloc (see DLMALLOC_SRC)
@ -886,6 +889,16 @@ endif
# add options at the beginning of the "ld" command line if needed.
LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB)
ifeq ($V,1)
cmd_CC = $(CC)
cmd_LD = $(LD)
cmd_AR = $(AR)
else
cmd_CC = $(Q)echo " CC $@";$(CC)
cmd_LD = $(Q)echo " LD $@";$(LD)
cmd_AR = $(Q)echo " AR $@";$(AR)
endif
ifeq ($(TARGET),)
all:
@echo
@ -953,22 +966,22 @@ DEP = $(INCLUDES) .build_opts
.build_opts: $(shell rm -f .build_opts.new; echo \'$(TARGET) $(BUILD_OPTIONS) $(VERBOSE_CFLAGS)\' > .build_opts.new; if cmp -s .build_opts .build_opts.new; then rm -f .build_opts.new; else mv -f .build_opts.new .build_opts; fi)
haproxy: $(OPTIONS_OBJS) $(OBJS) $(EBTREE_OBJS)
$(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
$(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
$(LIB_EBTREE): $(EBTREE_OBJS)
$(AR) rv $@ $^
$(cmd_AR) rv $@ $^
objsize: haproxy
$(Q)objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
%.o: %.c $(DEP)
$(CC) $(COPTS) -c -o $@ $<
$(cmd_CC) $(COPTS) -c -o $@ $<
src/trace.o: src/trace.c $(DEP)
$(CC) $(TRACE_COPTS) -c -o $@ $<
$(cmd_CC) $(TRACE_COPTS) -c -o $@ $<
src/haproxy.o: src/haproxy.c $(DEP)
$(CC) $(COPTS) \
$(cmd_CC) $(COPTS) \
-DBUILD_TARGET='"$(strip $(TARGET))"' \
-DBUILD_ARCH='"$(strip $(ARCH))"' \
-DBUILD_CPU='"$(strip $(CPU))"' \
@ -978,7 +991,7 @@ src/haproxy.o: src/haproxy.c $(DEP)
-c -o $@ $<
src/dlmalloc.o: $(DLMALLOC_SRC) $(DEP)
$(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
$(cmd_CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
install-man:
$(Q)install -v -d "$(DESTDIR)$(MANDIR)"/man1

7
README
View File

@ -65,6 +65,13 @@ one of the following choices to the CPU variable :
Alternatively, you may just set the CPU_CFLAGS value to the optimal GCC options
for your platform.
By default the build process runs in quiet mode and hide the details of the
commands that are executed. This allows to more easily catch build warnings
and see what is happening. However it is not convenient at all to observe what
flags are passed to the compiler nor what compiler is involved. Simply append
"V=1" to the "make" command line to switch to verbose mode and display the
details again.
You may want to build specific target binaries which do not match your native
compiler's target. This is particularly true on 64-bit systems when you want
to build a 32-bit binary. Use the ARCH variable for this purpose. Right now