<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Damien Lespiau &#187; cool hacks</title>
	<atom:link href="http://damien.lespiau.name/blog/category/cool-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://damien.lespiau.name/blog</link>
	<description>errands</description>
	<lastBuildDate>Sat, 17 Sep 2011 00:37:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AS_AM_STFU</title>
		<link>http://damien.lespiau.name/blog/2010/02/03/as_am_stfu/</link>
		<comments>http://damien.lespiau.name/blog/2010/02/03/as_am_stfu/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:04:19 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=154</guid>
		<description><![CDATA[Writing m4 macro is fun, it really is. If you want to have make be a &#8220;make -s&#8221; without doing boring stuff like aliases and actually respect the default verbosity of automake &#62;= 1.11, use this small m4 macro I wrote.]]></description>
			<content:encoded><![CDATA[<p>Writing m4 macro is fun, it really is.</p>
<p>If you want to have make be a &#8220;make -s&#8221; without doing boring stuff like aliases and actually respect the default verbosity of automake &gt;= 1.11, use <a href="http://git.lespiau.name/cgit/sk/tree/build/m4/as-am-stfu.m4">this small m4 macro</a> I wrote.</p>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2010/02/03/as_am_stfu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blending two RGBA 5551 layers</title>
		<link>http://damien.lespiau.name/blog/2009/06/06/blending-two-rgba-5551-layers/</link>
		<comments>http://damien.lespiau.name/blog/2009/06/06/blending-two-rgba-5551-layers/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 17:59:12 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=132</guid>
		<description><![CDATA[I&#8217;ve just stumbled accross a small piece of code, written one year and a half ago, that blends two 512&#215;512 RGBA 5551 images. It was originally written for a (good!) GIS, so the piece of code blends roads with rivers (and displays the result in a GdkPixbuf). The only thing interesting is that it uses [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just stumbled accross a small piece of code, written one year and a half ago, that blends two 512&#215;512 RGBA 5551 images. It was originally written for a (good!) GIS, so the piece of code blends roads with rivers (and displays the result in a GdkPixbuf). The only thing interesting is that it uses some MMX, SSE2 and <code>rdtsc</code> instructions. You can have a look at the code in <a href="http://git.lespiau.name/cgit/blend-5551-sse2/tree/main.c">its git repository</a>.<br />
<img class="aligncenter size-full wp-image-134" title="screenshot-layer-fusion" src="http://damien.lespiau.name/blog/wp-content/uploads/2009/06/screenshot-layer-fusion.png" alt="screenshot-layer-fusion" width="534" height="554" /></p>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/06/06/blending-two-rgba-5551-layers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>shave 0.1.0</title>
		<link>http://damien.lespiau.name/blog/2009/04/13/shave-010/</link>
		<comments>http://damien.lespiau.name/blog/2009/04/13/shave-010/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 11:22:08 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=122</guid>
		<description><![CDATA[After a month without anyone shouting at shave in despair or horror, it&#8217;s time to tag something to have a &#8220;stable&#8221; branch so people can rely on a stable interface (yes, it&#8217;s important even for a 100 lines macro!). What&#8217;s the most amazing is that quite a few projects have adopted shave in the GNOME [...]]]></description>
			<content:encoded><![CDATA[<p>After a month without anyone shouting at shave in despair or horror, it&#8217;s time to tag something to have a &#8220;stable&#8221; branch so people can rely on a stable interface (yes, it&#8217;s important even for a 100 lines macro!).</p>
<p>What&#8217;s the most amazing is that quite a few projects have adopted shave in the GNOME and freedesktop.org communities : Clutter, Niepce Digital, Giggle, GStreamer, GObject introspection, PulseAudio, ConnMan, Json-glib, libunique, gnote, seed, gnome-utils, libccss, <a title="shave + xorg" href="http://lists.freedesktop.org/archives/xorg/2009-April/044920.html">xorg ?</a> and maybe some more I&#8217;ve forgotten or I don&#8217;t even know about.</p>
<p>You can grab the <a href="http://download.lespiau.name/shave/shave-0.1.0.tar.bz2">tarball</a> or clone the <a href="http://git.lespiau.name/cgit/shave/">git repositoy</a> (git clone git://git.lespiau.name/shave) and have a look at the <a href="http://git.lespiau.name/cgit/shave/tree/README">README</a> file.</p>
<p>Time to celebrate.</p>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/04/13/shave-010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Still some hair left</title>
		<link>http://damien.lespiau.name/blog/2009/02/24/still-some-hair-left/</link>
		<comments>http://damien.lespiau.name/blog/2009/02/24/still-some-hair-left/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 11:11:13 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=87</guid>
		<description><![CDATA[I&#8217;ve been asked to give more input on make V=1 Vs. --disable-shave, so here it is: once again, before shipping your package with shave enabled by default, there is something crucial to understand: make V=1 (when having configured your package with --enable-shave) is NOT equivalent to no shave at all (ie --disable-shave). This is because [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been asked to give more input on  <code class="command">make V=1</code> Vs.  <code class="command">--disable-shave</code>, so here it is: once again, before shipping your package with shave enabled by default, there is something crucial to understand:  <code class="command">make V=1</code> (when having configured your package with  <code class="command">--enable-shave</code>) is <strong>NOT</strong> equivalent to no shave at all (ie  <code class="command">--disable-shave</code>). This is because the shave m4 macro is setting  <code>MAKEFLAGS=-s</code> in every single Makefile. This means that make won&#8217;t print the commands as is used to, and that the only way to print something on the screen is to echo it. It&#8217;s precisely what the shave wrappers do, they echo the CC/CXX and LIBTOOL commands when  <code>V=1</code>. So in short custom rules and a few automake commands won&#8217;t be displayed with <code class="command">make V=1</code>.</p>
<p>That said, it&#8217;s possible to craft a rule that would display the command with shaved enabled and <code class="command">make V=1</code>. The following rule:</p>
<pre> lib-file2.h: Makefile
        $(SHAVE_GEN)echo "#define FOO_DEFINE 0xbabe" &gt; lib-file2.h</pre>
<p>would become:</p>
<pre> lib-file2.h: Makefile
        @cmd='echo "#define FOO_DEFINE 0xbabe" &gt; lib-file2.h'; \
        if test x"$$V" = x1; then echo $$cmd; fi
        $(SHAVE_GEN)echo "#define FOO_DEFINE 0xbabe" &gt; lib-file2.h</pre>
<p>which is quite ugly, to say the least. (if you find a smarter way, please enlighten me!).</p>
<p>On the development side, shave is slowly becoming more mature:</p>
<ul>
<li>Thanks to Jan Schmidt, shave works with non GNU <code class="command">sed</code> and <code class="command">echo</code> that do not support <code>-n</code>. It now works on Solaris, hopefully on BSDs and various Unixes as well (not tested though).</li>
<li><code>SHAVE_INIT</code> has a new, optional, parameter which empowers the programmer to define shave&#8217;s default behaviour (when <code class="command">./configure</code> is run without shave any related option): either <code>enable</code> or <code>disable</code>. ie. <code>SHAVE_INIT([autootols], [enable])</code> will instruct shave to find its wrapper scripts in the autotools directory and that running <code class="command">./configure</code> will actually enable the beast. SHAVE_INIT without parameters at all is supposed to mean that the wrapper scripts are in <code>$top_builddir</code> and that <code class="command">./configure</code> will not enable shave without the <code class="command">--enable-shave</code> option.</li>
<li>however, shave has been reported to fail miserably with scratchbox.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/02/24/still-some-hair-left/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>After-shave</title>
		<link>http://damien.lespiau.name/blog/2009/02/23/after-shave/</link>
		<comments>http://damien.lespiau.name/blog/2009/02/23/after-shave/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 01:09:12 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=70</guid>
		<description><![CDATA[A few concerns have been raised by shave, namely not being able to debug build failure in an automated environment as easily as before, or users giving  useless bug reports of failed builds. One capital thing to realize is that, even when compiling with make V=1, everything that was not echoed was not showed (MAKEFLAGS=-s). [...]]]></description>
			<content:encoded><![CDATA[<p>A few concerns have been raised by shave, namely not being able to debug build failure in an automated environment as easily as before, or users giving  useless bug reports of failed builds.</p>
<p>One capital thing to realize is that, even when compiling with make V=1, everything that was not echoed was not showed (MAKEFLAGS=-s).</p>
<p>Thus, I&#8217;ve made a few changes:</p>
<ul>
<li>Add CXX support (yes, that&#8217;s unrelated, but the question was raised, thanks to Tommi Komulainen for the initial patch),</li>
<li>add a &#8211;enable-shave option to the configure script,</li>
<li>make the Good Old Behaviour the default one,</li>
<li>as a side effect, the V and Q variables are now defined in the m4 macro, please remove them from your Makefile.am files.</li>
</ul>
<p>The rationale for the last point can be summarized as follow:</p>
<ul>
<li>the default behaviour is as portable as before (for non GNU make that is), which is not the case is shave is activated by default,</li>
<li>you can still add &#8211;enable-shave to you autogen.sh script, bootstraping your project from a SCM will enable shave and that&#8217;s cool!</li>
<li>don&#8217;t break tools that were relying on automake&#8217;s output.</li>
</ul>
<p>Grab the <a title="shave git repository" href="http://git.lespiau.name/cgit/shave/">latest version</a>! (git://git.lespiau.name/shave)</p>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/02/23/after-shave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shave: making the autotools output sane</title>
		<link>http://damien.lespiau.name/blog/2009/02/18/shave-making-the-autotools-output-sane/</link>
		<comments>http://damien.lespiau.name/blog/2009/02/18/shave-making-the-autotools-output-sane/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 17:54:15 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=40</guid>
		<description><![CDATA[updated: Automake 1.11 has been release with &#8220;silent rules&#8221; support, a feature that supersedes the hack that shave is. If you can depend on automake 1.11 please consider using its silent rules rather than shave. updated: add some gtk-doc info updated: CXX support thanks to Tommi Komulainen shave Fed up with endless screens of libtool/automake [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">updated</span><span style="color: #ff0000;">:</span> Automake 1.11 has been release with &#8220;silent rules&#8221; support, a feature that supersedes the hack that shave is. If you can depend on automake 1.11 please consider using its silent rules rather than shave.</p>
<p style="text-align: left;">
<p><span style="color: #ff0000;">updated:</span> add some gtk-doc info</p>
<p><span style="color: #ff0000;">updated:</span> CXX support thanks to Tommi Komulainen</p>
<h3>shave</h3>
<p>Fed up with endless screens of libtool/automake output? Fed up with having to resort to -Werror to see warnings in your code? Then shave might be for you. shave transforms the messy output of autotools into a pretty Kbuild-like one (Kbuild is the Linux build system). It&#8217;s composed of a m4 macro and 2 small shell scripts and it&#8217;s available in a <a title="shave git repository" href="http://git.lespiau.name/cgit/shave/">git repository</a>.</p>
<p><strong><code>git clone git://git.lespiau.name/shave</code></strong></p>
<p>Hopefully, in a few minutes, you should be able to see your project compile like this:</p>
<pre>$ make
Making all in foo
Making all in internal
  CC    internal-file0.o
  LINK  libinternal.la
  CC    lib-file0.o
  CC    lib-file1.o
  LINK  libfoo.la
Making all in tools
  CC    tool0-tool0.o
  LINK  tool0</pre>
<p>Just like Kbuild, shave supports outputting the underlying commands using:</p>
<p><strong><code>$ make V=1</code></strong></p>
<h3>Setup</h3>
<ul>
<li>Put the two shell scripts shave.in and shave-libtool.in in the directory of your choice (it can be at the root of your autotooled project).</li>
<li>add shave and shave-libtool to AC_CONFIG_FILES</li>
<li>add shave.m4 either in acinclude.m4 or your macro directory</li>
<li>add a call to SHAVE_INIT just before AC_CONFIG_FILES/AC_OUTPUT. SHAVE_INIT takes one argument, the directory where shave and shave-libtool are.</li>
</ul>
<h3>custom rules</h3>
<p>Sometimes you have custom Makefile rules, e.g. to generate a small header, run glib-mkenums or glib-genmarshal. It would be nice to output a pretty &#8216;GEN&#8217; line. That&#8217;s quite easy actually, just add few (portable!) lines at the top of your Makefile.am:</p>
<pre>V         = @
Q         = $(V:1=)
QUIET_GEN = $(Q:@=@echo '  GEN   '$@;)</pre>
<p>and then it&#8217;s just a matter of prepending $(QUIET_GEN) to the rule creating the file:</p>
<pre>lib-file2.h: Makefile
       $(QUIET_GEN)echo "#define FOO_DEFINE 0xbabe" &gt; lib-file2.h</pre>
<h3>gtk-doc + shave</h3>
<p>gtk-doc + shave + libtool 1.x (2.x is fine) is known to have a small issue, <a title="bug #572396" href="http://bugzilla.gnome.org/show_bug.cgi?id=572396">a patch</a> is available. Meanwhile I suggest adding a few lines to your autogen.sh script.</p>
<pre>sed -e 's#) --mode=compile#) --tag=CC --mode=compile#' gtk-doc.make &gt; gtk-doc.temp \
        &amp;&amp; mv gtk-doc.temp gtk-doc.make
sed -e 's#) --mode=link#) --tag=CC --mode=link#' gtk-doc.make &gt; gtk-doc.temp \
        &amp;&amp; mv gtk-doc.temp gtk-doc.make</pre>
<h3>dolt + shave</h3>
<p>It&#8217;s possible to use <a title="dolt" href="http://dolt.freedesktop.org/">dolt</a> in conjunction with shave with a <a title="patch to make dolt work with shave" href="http://git.lespiau.name/cgit/dolt/commit/?h=shave-dolt">surprisingly small patch</a> to dolt.</p>
<h3>Real world example: Clutter</h3>
<pre>$ make
GEN   stamp-clutter-marshal.h
GEN   clutter-marshal.c
GEN   stamp-clutter-enum-types.h
Making all in cogl
Making all in common
CC    cogl-util.o
CC    cogl-bitmap.o
CC    cogl-bitmap-fallback.o
CC    cogl-primitives.o
CC    cogl-bitmap-pixbuf.o
CC    cogl-clip-stack.o
CC    cogl-fixed.o
CC    cogl-color.o
cogl-color.c: In function ‘cogl_set_source_color4ub’:
cogl-color.c:141: warning: implicit declaration of function ‘cogl_set_source_color’
CC    cogl-vertex-buffer.o
CC    cogl-matrix.o
CC    cogl-material.o
LINK  libclutter-cogl-common.la
[...]</pre>
<p>Eh! now we can see a warning there!</p>
<h3>TODO</h3>
<p>This is a first release, shave has not been widely tested aka it may not work for you!</p>
<ul>
<li>test it with a wider range of automake/libtool versions</li>
<li>shave won&#8217;t work without AC_CONFIG_HEADERS due to shell quoting problems</li>
<li>see what can be done for make install/dist (they are prettier thanks to make -s, but we probably miss a few actions)</li>
<li>there is a &#8216;-s&#8217; hardcoded in MAKEFLAGS,  I have to find a way to make it more flexible</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/02/18/shave-making-the-autotools-output-sane/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>ADV: ADV is a Dependency Viewer</title>
		<link>http://damien.lespiau.name/blog/2009/02/10/adv-adv-is-a-dependency-viewer/</link>
		<comments>http://damien.lespiau.name/blog/2009/02/10/adv-adv-is-a-dependency-viewer/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 11:25:42 +0000</pubDate>
		<dc:creator>damien</dc:creator>
				<category><![CDATA[cool hacks]]></category>

		<guid isPermaLink="false">http://damien.lespiau.name/blog/?p=12</guid>
		<description><![CDATA[A few months ago I wrote a small script to draw a dependency graph between the object files of a library (the original idea is from Lionel Landwerlin). You&#8217;ll need an archive of your library for the tool to be able to look for the needed pieces. Let&#8217;s have a look at a sample of [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I wrote a small script to draw a dependency graph between the object files of a library (the original idea is from Lionel Landwerlin). You&#8217;ll need an archive of your library for the tool to be able to look for the needed pieces. Let&#8217;s have a look at a sample of its output to understand what it does. I ran it against the HEAD of <a title="clutter" href="http://www.clutter-project.org/">clutter</a>.</p>
<div id="attachment_16" class="wp-caption aligncenter" style="width: 310px"><a href="http://damien.lespiau.name/files/blog/clutter-b4f9c8204d.svg"><img class="size-medium wp-image-16" title="clutter-b4f9c8204d-small" src="http://damien.lespiau.name/blog/wp-content/uploads/2009/02/clutter-b4f9c8204d-small.png" alt="A view of the clutter library" width="300" height="177" /></a><p class="wp-caption-text">A view of the clutter library</p></div>
<p>This graph was generated with the following (tred is part of graphviz to do transitive reductions on graphs):</p>
<p><code>$ adv.py clutter/.libs/libclutter-glx-0.9.a | tred | dot -Tsvg &gt; clutter.svg</code></p>
<p>You can provide more than one library to the tool:</p>
<p><code>./adv.py ../clutter/clutter/.libs/libclutter-glx-0.9.a \<br />
../glib-2.18.4/glib/.libs/libglib-2.0.a \<br />
../glib-2.18.4/gobject/.libs/libgobject-2.0.a \<br />
| tred | dot -Tsvg &gt; clutter-glib-gobject-boxed.svg</code></p>
<div id="attachment_17" class="wp-caption aligncenter" style="width: 310px"><a href="http://damien.lespiau.name/files/blog/clutter-glib-gobject.svg"><img class="size-medium wp-image-17" title="clutter-glib-gobject-small" src="http://damien.lespiau.name/blog/wp-content/uploads/2009/02/clutter-glib-gobject-small.png" alt="" width="300" height="186" /></a><p class="wp-caption-text">clutter, glib and gobject</p></div>
<p><code> </code></p>
<p>What you can do with this:</p>
<ul>
<li>trim down your library by removing the object files you don&#8217;t need and that are leafs in the graph. This was actually the reason behind the script and it proved useful,</li>
<li>get an overview of a library,</li>
<li>make part of a library optional more easily.</li>
</ul>
<p>To make the script work you&#8217;ll need graphviz, python, ar and nm (you can provide a cross compiler prefix with &#8211;cross-prefix).</p>
<p>Interested? clone it! (or <a title="adv git repository" href="http://git.lespiau.name/cgit/adv/tree/adv.py">look at the code</a>)</p>
<p><code>$ git clone git://git.lespiau.name/misc/adv</code></p>
]]></content:encoded>
			<wfw:commentRss>http://damien.lespiau.name/blog/2009/02/10/adv-adv-is-a-dependency-viewer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

