[FFmpeg-devel] [PATCH v2] Beautify build output making it easier to see compiler warnings

Georgi Chorbadzhiyski gf
Fri Mar 5 15:09:25 CET 2010


Around 03/05/10 12:14, Stefano Sabatini scribbled:
> On date Friday 2010-03-05 10:59:41 +0200, Georgi Chorbadzhiyski encoded:
>> Around 03/04/10 16:37, Luca Barbato scribbled:
>>> On 03/03/2010 05:57 PM, Georgi Chorbadzhiyski wrote:
>>>> With this patch the build output will look similar to Linux Kernel kbuild and git.
>>>> Something like this:
>>>>
>>>>   CC         libavdevice/alldevices.c
>>>> libavdevice/alldevices.c:32: warning: no previous prototype for 'avdevice_register_all'
>>>>   CC         libavdevice/avdevice.c
>>>>   CC         libavdevice/alsa-audio-common.c
>>>>
>>>> This makes it very easy to see compiler warnings for example. If you want
>>>> to see the whole command that make executes you may use
>>>>
>>>> make Q=
>>>
>>> Usually you call it with V=1, beside that I did something like that long
>>> ago, yours seems less invasive since doesn't cover the install target.
>>
>> Of course it should be with V=1, my bad. Attached version 2 of the patch now
>> with added support for install and uninstall targets, also make V=1 should be
>> used to see the executed command or exported BUILD_OUPUT=1.
>>
>> make clean and distclean are not covered in the moment. I can easily add them
>> but I don't think their output will improve.
>>
>> diffstat pretty-build-output_v2.diff
>>  Makefile   |   67 ++++++++++++++++++++++++++++++++-------------------
>>  common.mak |   37 +++++++++++++++++++++++-----
>>  subdir.mak |   79 ++++++++++++++++++++++++++++++++++++-------------------------
>>  3 files changed, 119 insertions(+), 64 deletions(-)
> 
> Consider this approach:
> http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/95102
> 
> which should issue a smaller change.

Is this better:

-   $(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
+   $(call build_cmd,LD,$<, $(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) )


Than this:

+   @echo "  CC         $<"
    $(CCDEP)
-   $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
+   $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<

Sure the first one is less lines changed but in the long term when somebody
tries to read this $(call build_cmd) it is not going to be pleasant :)

Also the minimal attached patch (based on the mail you point me to) do not
handle many of the build targets. When install, uninstall, strip, docs, tests,
etc. are added there will be similar number of lines + the ugliness in
every command. Also the "eval" approach in theory will slow down the build.

-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
-------------- next part --------------
diff --git a/common.mak b/common.mak
index 5420c7d..9b96bba 100644
--- a/common.mak
+++ b/common.mak
@@ -22,16 +22,32 @@ ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
 CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
 CFLAGS   += $(ECFLAGS)
 
+# Default to quiet build unless V=1 is set on the make command line
+# or BUILD_VERBOSE=1 is exported in the environment
+ifeq ("$(origin V)", "command line")
+  BUILD_VERBOSE = $(V)
+endif
+
+ifndef BUILD_VERBOSE
+  BUILD_VERBOSE = 0
+endif
+
+ifeq ($(BUILD_VERBOSE),1)
+  build_cmd = eval "$3"
+else
+  build_cmd = @echo "  [$1] $2" ; eval "$3"
+endif
+
 %.o: %.c
 	$(CCDEP)
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<
+	$(call build_cmd,CC,$<, $(CC) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -c $(CC_O) $< )
 
 %.o: %.S
 	$(ASDEP)
-	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<
+	$(call build_cmd,AS,$<, $(AS) $(CPPFLAGS) $(ASFLAGS) $(LIBOBJFLAGS) -c -o $@ $< )
 
 %.ho: %.h
-	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
+	$(call build_cmd,HO,$<, $(CC) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $< )
 
 %$(EXESUF): %.c
 
diff --git a/subdir.mak b/subdir.mak
index 2448950..0e5fedb 100644
--- a/subdir.mak
+++ b/subdir.mak
@@ -22,16 +22,16 @@ THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
 
 define RULES
 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
-	$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
+	$(call build_cmd,LD,$<, $(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS) )
 
 $(SUBDIR)%-test.o: $(SUBDIR)%.c
-	$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
+	$(call build_cmd,CC-TEST,$<, $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c -o $$@ $$^ )
 
 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
-	$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $$(CC_O) $$^
+	$(call build_cmd,CC-TEST,$<, $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c -o $$@ $$^ )
 
 $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
-	$(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:.o=.d)
+	$(call build_cmd,DEPEND,$< $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@ )
 	$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
 
 clean::



More information about the ffmpeg-devel mailing list