Suggestions for more efficient make rules, clearer documentation and a
better macro than the generic 'DBG' welcome.

-- 
Christophe
From 8e2adea82a4ec440744b701716a93e6ecaf211d6 Mon Sep 17 00:00:00 2001
From: Christophe Gisquet <christophe.gisq...@gmail.com>
Date: Sun, 8 Feb 2015 12:18:27 +0100
Subject: [PATCH] x86/doc/Makefile: DBG=1 to preprocess external asm

The macro hell sometimes make it difficult to trace the source of
an error, so it is easier to analyze the preprocessed output.

This patch makes this automatical by specifying DBG=1 on the
command line: a file ffmpeg/dir/file.asm gets preprocessed to
builddir/dir/file.dbg.asm, which is then compiled.
---
 common.mak           | 6 ++++++
 doc/build_system.txt | 5 +++++
 doc/optimization.txt | 5 +++++
 library.mak          | 6 +++++-
 4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/common.mak b/common.mak
index a493792..80cc8e2 100644
--- a/common.mak
+++ b/common.mak
@@ -5,6 +5,12 @@
 # first so "all" becomes default target
 all: all-yes
 
+ifndef DBG
+YASMD=
+else
+YASMD=.dbg
+endif
+
 ifndef SUBDIR
 
 ifndef V
diff --git a/doc/build_system.txt b/doc/build_system.txt
index 2efde5c..dc77f93 100644
--- a/doc/build_system.txt
+++ b/doc/build_system.txt
@@ -7,6 +7,11 @@ V
     Disable the default terse mode, the full command issued by make and its
     output will be shown on the screen.
 
+DBG
+    Preprocess external assembler files to a .dbg.asm file in the object
+    directory, which then gets compiled. Helps developping those assembler
+    files.
+
 DESTDIR
     Destination directory for the install targets, useful to prepare packages
     or install FFmpeg in cross-environments.
diff --git a/doc/optimization.txt b/doc/optimization.txt
index 94a4277..743865a 100644
--- a/doc/optimization.txt
+++ b/doc/optimization.txt
@@ -191,6 +191,11 @@ __asm__() block.
 Use external asm (nasm/yasm) or inline asm (__asm__()), do not use intrinsics.
 The latter requires a good optimizing compiler which gcc is not.
 
+When debugging an external asm compilation issue, if lost in the macro
+expansions, add DBG=1 to your make command-line: the input file will be
+preprocessed, stripped of the debug/empty lines, then compiled, showing the
+actual lines causing issues.
+
 Inline asm vs. external asm
 ---------------------------
 Both inline asm (__asm__("..") in a .c file, handled by a compiler such as gcc)
diff --git a/library.mak b/library.mak
index 72e5574..d94ba15 100644
--- a/library.mak
+++ b/library.mak
@@ -22,7 +22,11 @@ $(SUBDIR)%-test.i: $(SUBDIR)%-test.c
 $(SUBDIR)%-test.i: $(SUBDIR)%.c
 	$(CC) $(CCFLAGS) $(CC_E) $<
 
-$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
+$(SUBDIR)x86/%.dbg.asm: $(SUBDIR)x86/%.asm
+	$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
+	$(YASM) $(YASMFLAGS) -I $(<D)/ -e $< | sed '/^%/d;/^$$/d;' > $@
+
+$(SUBDIR)x86/%.o: $(SUBDIR)x86/%$(YASMD).asm
 	$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
 	$(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
 	-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
-- 
1.9.2.msysgit.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to