[PATCH intel-gpu-tools 1/6] Debugger: convert existing makefiles to Automake.

2012-01-06 Thread Gaetan Nadon
A common xorg idiom is used. The dependencies are auto-detected.
If they are present, the debugger is build.
If any are missing, the debugger is silently skipped.
If --enable-shader-debugger is specified, the configuration
will abort if any of the dependencies is missing.
No user actions is needed, no env variable to set (as it should be)

This will fix a number of problems:
build cannot start due Makefile missing in tarball.
build fails as GEN4ASM variable not available in Makefile.
no binaries are installed, so it cannot be used from a distro.
distcheck is also disturbed.

In the process other minor problems were fixed:
helper target is missing dependencies on evict.h.
too may arguments given to pre_cpp.py but they were ignored.
fills /tmp with temporary files.

Signed-off-by: Gaetan Nadon 
---
 Makefile.am|8 ++--
 configure.ac   |   51 +++-
 debugger/Makefile.am   |   27 +--
 debugger/system_routine/.gitignore |   12 -
 debugger/system_routine/GNUmakefile.in |3 -
 debugger/system_routine/Makefile   |   84 
 debugger/system_routine/Makefile.am|   42 
 7 files changed, 107 insertions(+), 120 deletions(-)
 delete mode 100644 debugger/system_routine/GNUmakefile.in
 delete mode 100644 debugger/system_routine/Makefile
 create mode 100644 debugger/system_routine/Makefile.am

diff --git a/Makefile.am b/Makefile.am
index c7ae735..e049e3c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,11 +19,11 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-if HAVE_SHADER_DEBUGGER
-SHADER_DEBUGGER_SUBDIR = debugger
-endif
+SUBDIRS = lib man tools scripts tests benchmarks
 
-SUBDIRS = lib man tools scripts tests benchmarks $(SHADER_DEBUGGER_SUBDIR)
+if BUILD_SHADER_DEBUGGER
+SUBDIRS += debugger
+endif
 
 test:
${MAKE} -C tests test
diff --git a/configure.ac b/configure.ac
index b415a97..7265917 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
 
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_PATH_PYTHON([3],, [:])
 AM_MAINTAINER_MODE
 
 # Initialize libtool
@@ -65,22 +66,47 @@ if test "x$HAVE_GLIB" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_GLIB, [test "x$HAVE_GLIB" = xyes])
 
-AC_ARG_ENABLE(shader-debugger,
- AS_HELP_STRING([--enable-shader-debugger],
-[Enable shader debugging support [default=no]]),
- [SHADER_DEBUGGER="$enableval"],
- [SHADER_DEBUGGER=no])
-AM_CONDITIONAL(HAVE_SHADER_DEBUGGER, [test "x$SHADER_DEBUGGER" = xyes])
-if test "x$SHADER_DEBUGGER" = xyes; then
-   AC_CHECK_PROG([GEN4ASM], intel-gen4asm, intel-gen4asm)
-   if test -z "$GEN4ASM"; then
-   AC_MSG_ERROR([Cannot find intel-gen4asm in your path; please 
set GEN4ASM env variable])
+# -
+#  Configuration options
+# -
+# Define a configure option for the shadder debugger
+AC_ARG_ENABLE(shader-debugger, AS_HELP_STRING([--enable-shader-debugger],
+[Enable shader debugging support [autodetected]]),
+[BUILD_SHADER_DEBUGGER="$enableval"], [BUILD_SHADER_DEBUGGER=auto])
+
+# Shadder debugger depends on python3, intel-genasm and objcopy
+if test "x$BUILD_SHADER_DEBUGGER" != xno; then
+# Check Python 3 is installed
+if test "$PYTHON" = ":" ; then
+   if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+   AC_MSG_ERROR([Shader debugger requested, python version 3 not 
found.])
+   else
+   BUILD_SHADER_DEBUGGER=no
+   fi
+fi
+# Check for the Intel Chipset assembler compiler
+AC_PATH_PROGS([GEN4ASM], intel-gen4asm)
+if test -z "$GEN4ASM" ; then
+   if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+   AC_MSG_ERROR([Shader debugger requested, but intel-gen4asm not 
found.])
else
-   AC_CONFIG_FILES([debugger/system_routine/GNUmakefile])
-   AC_DEFINE(HAVE_SHADER_DEBUGGER, 1, [Have shader debugging 
support])
+   BUILD_SHADER_DEBUGGER=no
fi
+fi
+# Check for the objcopy GNU binary utiliy command
+AC_PATH_PROGS([OBJCOPY], objcopy)
+if test -z "$OBJCOPY" ; then
+   if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+   AC_MSG_ERROR([Shader debugger requested, but objcopy command not 
found.])
+   else
+   BUILD_SHADER_DEBUGGER=no
+   fi
+fi
 fi
 
+AM_CONDITIONAL(BUILD_SHADER_DEBUGGER, [test "x$BUILD_SHADER_DEBUGGER" != xno])
+# -
+
 AC_CONFIG_FILES([
Makefile
benchmarks/Makefile
@@ -90,5 +116,6 @@ AC_CONFIG_FILES([
tests/Makefile

Re: [PATCH intel-gpu-tools 1/6] Debugger: convert existing makefiles to Automake.

2012-01-06 Thread Colin Walters
On Fri, 2012-01-06 at 10:52 -0500, Gaetan Nadon wrote:

> +sr.cpp : sr.g4a
> + $(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@

I recommend writing custom build commands to be atomic.  Which means:

$(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@.tmp && mv $@.tmp $@

This way if the developer uses Control-C to send SIGINT to the process
group which kills the command in the middle of a write (or the command
crashes), you don't spend any time debugging the later program which is
consuming a half-written input file.  In some cases this can cause very
subtle corruption or errors.



___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH intel-gpu-tools 1/6] Debugger: convert existing makefiles to Automake.

2012-01-06 Thread Gaetan Nadon
On 12-01-06 11:19 AM, Colin Walters wrote:
> On Fri, 2012-01-06 at 10:52 -0500, Gaetan Nadon wrote:
>
>> +sr.cpp : sr.g4a
>> +$(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@
> I recommend writing custom build commands to be atomic.  Which means:
>
> $(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@.tmp && mv $@.tmp $@
>
> This way if the developer uses Control-C to send SIGINT to the process
> group which kills the command in the middle of a write (or the command
> crashes), you don't spend any time debugging the later program which is
> consuming a half-written input file.  In some cases this can cause very
> subtle corruption or errors.
This is news to me. Makes sense. For the gcc command, would it not take
care of removing output before exiting?
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH intel-gpu-tools 1/6] Debugger: convert existing makefiles to Automake.

2012-01-06 Thread Colin Walters
On Fri, 2012-01-06 at 17:19 -0500, Gaetan Nadon wrote:
> On 12-01-06 11:19 AM, Colin Walters wrote:
> > On Fri, 2012-01-06 at 10:52 -0500, Gaetan Nadon wrote:
> >
> >> +sr.cpp : sr.g4a
> >> +  $(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@
> > I recommend writing custom build commands to be atomic.  Which means:
> >
> > $(srcdir)/pre_cpp.py $(srcdir)/sr.g4a > $@.tmp && mv $@.tmp $@
> >
> > This way if the developer uses Control-C to send SIGINT to the process
> > group which kills the command in the middle of a write (or the command
> > crashes), you don't spend any time debugging the later program which is
> > consuming a half-written input file.  In some cases this can cause very
> > subtle corruption or errors.
> This is news to me. Makes sense. For the gcc command, would it not take
> care of removing output before exiting?

>From a quick:
strace -f -erename gcc -o foo foo.c

Nothing in that process chain invokes rename(2), so it can't be atomic.
It's probably worth patching automake at some point to output atomic
rules, but anyways I do it in my custom rules.

See also https://github.com/apenwarr/redo


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel