<?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>glandium.org</title>
	<atom:link href="http://glandium.org/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://glandium.org/blog</link>
	<description>glandium.org</description>
	<lastBuildDate>Thu, 14 Mar 2013 07:35:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Google Reader death, or how the cloud model can fail you</title>
		<link>http://glandium.org/blog/?p=2961</link>
		<comments>http://glandium.org/blog/?p=2961#comments</comments>
		<pubDate>Thu, 14 Mar 2013 07:35:45 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.d.o]]></category>
		<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2961</guid>
		<description><![CDATA[If you&#8217;re a Google Reader user, you probably read in one of your subscriptions that Google is pulling the plug on Google Reader. It is yet another demonstration of why putting data in the cloud isn&#8217;t so much of a nice idea: the service you rely on may well disappear some day, with all the [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re a Google Reader user, you probably read in one of your subscriptions that Google is pulling the plug on Google Reader. It is yet another demonstration of why putting data in the cloud isn&#8217;t so much of a nice idea: the service you rely on may well disappear some day, with all the data it contains.</p>
<p>Sure Google, in its extreme goodness, allows you to &#8220;take out&#8221; the Google Reader data. Or does it?<br />
These are what you&#8217;ll get from Google Takeout for Reader:</p>
<ul>
<li><code>followers.json</code>, <code>following.json</code>: both files contain similar data, that I suspect correspond to Buzz subscriptions (yet another dead service). Each <code>friends</code> item contains some information about your &#8220;friend&#8221;, and a stream identifier for their activity (I guess), as well as a few <code>websites</code> urls. For instance Tim Bray&#8217;s stream is &#8220;<code>user/05198174665841271019/state/com.google/broadcast</code>&#8220;. What the hell do I do with that? Fortunately, he has <code>websites</code>, but not all my &#8220;<code>friends</code>&#8221; have. Thankfully, I haven&#8217;t really been using this feature, so there&#8217;s almost nothing in these files.</li>
<li><code>liked.json</code>, <code>starred.json</code>, <code>shared.json</code>, <code>shared-by-followers.json</code>: all have the same structure, and contain items you liked, starred, shared, or that the people you follow shared (yeah, that file is badly named). Each item contains an url (or so I hope), and the corresponding content (yay). <code>shared-by-followers.json</code> however doesn&#8217;t contain more than the items the people you follow actively shared: it doesn&#8217;t contain their feeds (and I&#8217;m pretty sure I read more from Tim Bray than the two links he shared)</li>
<li><code>subscriptions.xml</code>: Essentially, a list of RSS feed urls, with no content ; nothing from Tim Bray here, but now that I think about it, I think I was only following his Buzz feed, so that went away with Buzz without me noticing.</li>
</ul>
<p>Interestingly, while looking into <code>shared-by-followers.json</code>, I found urls that would correspond to friend streams. For instance, Tim Bray&#8217;s is <a href="http://www.google.com/reader/public/atom/user/05198174665841271019/state/com.google/broadcast">http://www.google.com/reader/public/atom/user/05198174665841271019/state/com.google/broadcast</a>. But it&#8217;s useless: all it displays is &#8220;permission denied&#8221;.</p>
<p>As for subscriptions, one of the strengths of Google Reader is that it allowed to search though past items, which means a big part of the interesting data is the archived items. But that&#8217;s not part of the &#8220;take out&#8221;. Sure, you have the feed urls, but most RSS feeds contain a limited amount of items, not the entire history of items for the given feed. So, history is more or less lost. Except if I star, like or share all items in all my subscriptions and &#8220;take out&#8221; again.</p>
<p>So much goodness.</p>
<p>It could have been worse, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2961</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Ten years</title>
		<link>http://glandium.org/blog/?p=2936</link>
		<comments>http://glandium.org/blog/?p=2936#comments</comments>
		<pubDate>Tue, 19 Feb 2013 21:45:30 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2936</guid>
		<description><![CDATA[Ten years ago, this very day, my first Debian package entered the Debian unstable repository. It was an addon for Mozilla Composer, Daniel Glazman&#8217;s Cascades. On the same day, my second Debian package entered the Debian unstable repository as well. It was an addon for Mozilla Browser, Checky. A few days later, my third Debian [...]]]></description>
				<content:encoded><![CDATA[<p>Ten years ago, this very day, my first Debian package <a href="https://lists.debian.org/debian-devel-changes/2003/02/msg01413.html">entered the Debian unstable repository</a>. It was an addon for Mozilla Composer, <a href="http://daniel.glazman.free.fr/composer/cascades02.htm">Daniel Glazman&#8217;s Cascades</a>.</p>
<p>On the same day, my second Debian package <a href="https://lists.debian.org/debian-devel-changes/2003/02/msg01411.html">entered the Debian unstable repository as well</a>. It was an addon for Mozilla Browser, <a href="http://checky.sourceforge.net/extension.html">Checky</a>.</p>
<p>A few days later, my third Debian package <a href="https://lists.debian.org/debian-devel-changes/2003/02/msg01552.html">entered Debian unstable</a>. It was an addon for Mozilla Browser, <a href="http://diggler.mozdev.org/">Diggler</a>.</p>
<p>Do you see a pattern? They are now abandoned software, although I made Checky and Diggler live a little longer (and I&#8217;m actually considering reviving Diggler) but they had their importance in my journey, and are part of the reason why I am where I am now.</p>
<p>My journey on the web started with <a href="http://en.wikipedia.org/wiki/Mosaic_%28web_browser%29">NCSA Mosaic</a> on <a href="http://fr.wikipedia.org/wiki/Virtual_Memory_System">VAX/VMS</a>, then continued with <a href="http://en.wikipedia.org/wiki/Netscape_Navigator">Netscape Navigator</a>, <a href="http://en.wikipedia.org/wiki/Netscape_Communicator">Netscape Communicator</a> and <a href="http://en.wikipedia.org/wiki/Mozilla_Application_Suite">Mozilla Suite</a> on <a href="http://en.wikipedia.org/wiki/Linux">Linux</a>.</p>
<p>That&#8217;s where I was ten years ago, sailing between <a href="http://en.wikipedia.org/wiki/Galeon">Galeon</a> (a browser using the Mozilla engine) and Mozilla Suite, and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=132695">filing</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=183913">some</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=184897">layout</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=184899">bugs</a>.</p>
<p>Ten years ago, there was a new kid on the block. It used to be called Phoenix, it had just changed its name to Firebird. Eventually, it changed again for Firefox. You may have heard about it. Because Firebird was so much nicer than the browser in the Mozilla Suite, I started using its Debian package, and wanted my packaged addons to work with it. So I contacted Eric Dorland, Phoenix/Firebird package maintainer at the time, and <a href="http://packages.debian.org/changelogs/pool/main/i/iceweasel/current/changelog#version0.6-2">got the addons working</a>. I then ended up <a href="http://packages.debian.org/changelogs/pool/main/i/iceweasel/current/changelog#version0.6-5">fixing a bunch of packaging issues</a>.</p>
<p>This is how I got involved in Firefox packaging for Debian, and what eventually led me to work for Mozilla.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2936</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox in Debian?</title>
		<link>http://glandium.org/blog/?p=2922</link>
		<comments>http://glandium.org/blog/?p=2922#comments</comments>
		<pubDate>Sat, 29 Dec 2012 10:00:21 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2922</guid>
		<description><![CDATA[Got your attention? Don&#8217;t hold your breath, we&#8217;re not there yet, but we&#8217;re a step closer: it&#8217;s now possible to build Firefox from the Iceweasel package, since version 17.0.1-2 in experimental as of writing, 18.0~b6-1 from the iceweasel-beta repository, or 19.0~a2+20121228042015-1 from the iceweasel-aurora repository. Before letting you know how you can get yourself a [...]]]></description>
				<content:encoded><![CDATA[<p>Got your attention? Don&#8217;t hold your breath, we&#8217;re not there yet, but we&#8217;re a step closer: it&#8217;s now possible to <b>build</b> Firefox from the Iceweasel package, since version 17.0.1-2 in experimental as of writing, 18.0~b6-1 from the iceweasel-beta repository, or 19.0~a2+20121228042015-1 from the iceweasel-aurora repository.</p>
<p>Before letting you know how you can get yourself a packaged Firefox based on the Iceweasel source, I&#8217;ll remind you that redistribution of Firefox packages requires a trademark license from Mozilla, so please keep the packages you build for yourself for now.</p>
<p>That being said, now it&#8217;s clear that such Firefox packages are not official, you can still test them for yourself. First download the Iceweasel source version of your liking, and extract it, then rename all source files from <code>iceweasel_*</code> to <code>firefox_*</code> (<code>rename s/iceweasel/firefox/ iceweasel_*</code> should do it). Edit <code>debian/changelog</code> so that the first line reads:</p>
<blockquote><pre>firefox (x.y.z-r) distribution; urgency=low</pre>
</blockquote>
<p>instead of:</p>
<blockquote><pre>iceweasel (x.y.z-r) distribution; urgency=low</pre>
</blockquote>
<p>and run the following command:</p>
<blockquote><pre>$ debian/rules debian/control</pre>
</blockquote>
<p>Now you&#8217;re all set. You can build the package the usual way.</p>
<p>Note there are a few differences between the xulrunner packages you get from building Iceweasel vs. from building Firefox that need to be addressed, and a few other details to sort out.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2922</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using distcc and clang on Linux to build Firefox faster on MacOSX</title>
		<link>http://glandium.org/blog/?p=2908</link>
		<comments>http://glandium.org/blog/?p=2908#comments</comments>
		<pubDate>Tue, 04 Dec 2012 18:30:15 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2908</guid>
		<description><![CDATA[Apple makes nice hardware, until you look into the details. As it turns out, my Macbook Pro has issues with heat. So much that when building Firefox, the CPU decides it&#8217;s too hot and throttles its frequency to emit less heat. The result is that building Firefox takes much more time than it would if [...]]]></description>
				<content:encoded><![CDATA[<p>Apple makes nice hardware, until you look into the details. As it turns out, my Macbook Pro has issues with heat. So much that when building Firefox, the CPU decides it&#8217;s too hot and throttles its frequency to emit less heat. The result is that building Firefox takes much more time than it would if the CPU could stay at its highest frequency all the time. On this machine, it takes more than an hour to build Firefox.</p>
<p>Most of the time, this MBP runs Linux. The heat problem is the same, but I also have a much beefier build server, running Linux too, that I use for builds. I used to use distcc from the MBP, using both the MBP and the build server to build everything. This was convenient, because the source tree could stay on the MBP. It however turned out to be slower than doing a local build on the build server. So I now push my changes to the build server, which then does the build alone. It takes about 18 minutes for a clobber build (without ccache), this way.</p>
<p>Anyways, I don&#8217;t build often on Windows or Mac, but when I need to, I&#8217;m essentially doing a clobber build, and as a result, the MBP spends an awful lot of time doing so. So, since I already had a distcc daemon running, with clang available, and since I was in need for a Mac build, I figured I&#8217;d try something seemingly crazy: use the Linux build server.</p>
<p>It turns out Linux clang is able to emit Mach-O objects (the binary format used on MacOSX). So all I needed to do was to add something like the following to my <code>.mozconfig</code>:</p>
<blockquote><pre>
export CC="distcc clang -ccc-host-triple x86_64-apple-darwin"
export CXX="distcc clang++ -ccc-host-triple x86_64-apple-darwin"
</pre>
</blockquote>
<p>(After fixing <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=818092">bug 818092</a>)</p>
<p>Now I can enjoy builds taking slightly less than 30 minutes. Which is more than twice as fast.</p>
<p><b>Update:</b> in case this wasn&#8217;t very clear, the build is initiated from OSX, where preprocessing is handled (distcc pump mode is not enabled), which allows the Linux build server to do the right thing with clang.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2908</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hooking the memory allocator in Firefox</title>
		<link>http://glandium.org/blog/?p=2848</link>
		<comments>http://glandium.org/blog/?p=2848#comments</comments>
		<pubDate>Tue, 27 Nov 2012 12:49:15 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2848</guid>
		<description><![CDATA[Supplanting the system memory allocator usually involves some tricks. In a cross-platform software like Firefox, this involves different tricks on different platforms. Firefox uses such tricks to implant jemalloc. Sadly, this makes replacing jemalloc itself even trickier. For instance, trace-malloc, our leak detection tool, used on debug builds, requires that jemalloc is disabled. Work is [...]]]></description>
				<content:encoded><![CDATA[<p>Supplanting the system memory allocator usually involves some tricks. In a cross-platform software like Firefox, this involves different tricks on different platforms. Firefox uses such tricks to implant jemalloc. Sadly, this makes replacing jemalloc itself even trickier.</p>
<p>For instance, trace-malloc, our leak detection tool, used on debug builds, requires that jemalloc is disabled.</p>
<p>Work is under way to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=804303">make supplanting jemalloc much easier</a>. It is not yet clear if this will be enabled by default on release builds, but it would make sense to enable the feature at least on nightlies.</p>
<p>What does the feature provide? A way to hook or replace jemalloc in Firefox at startup time (as opposed to build time, like trace-malloc). The idea is to build a specialized library (more on that further below) and make Firefox use it instead, or on top of jemalloc, with some <a href="/blog/?p=2764">weak linking tricks</a>. To enable the feature, pass <code>--enable-replace-malloc</code> to configure or add <code>ac_add_options --enable-replace-malloc</code> to your <code>mozconfig</code> (provided you applied the patches or got a tree where the patches are landed).</p>
<p>With the feature built, you can start Firefox with a malloc replacement library easily:</p>
<ul>
<li>On GNU/Linux:</p>
<blockquote><pre>$ LD_PRELOAD=/path/to/library.so firefox</pre>
</blockquote>
</li>
<li>On OSX:<br />
<blockquote><pre>$ DYLD_INSERT_LIBRARIES=/path/to/library.dylib firefox</pre>
</blockquote>
</li>
<li>On Windows:<br />
<blockquote><pre>$ MOZ_REPLACE_MALLOC_LIB=drive:\path\to\library.dll firefox</pre>
</blockquote>
</li>
</ul>
<ul>
<li>On Android:</p>
<blockquote><pre>$ am start -a android.activity.MAIN -n org.mozilla.fennec/.App --es env0 MOZ_REPLACE_MALLOC_LIB=/path/to/library.so</pre>
</blockquote>
</li>
</ul>
<p>As I happen to have built Firefox with the feature enabled for all platforms on try, to validate that it works, you can toy around <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/mh@glandium.org-3e9cc4c7baa9/">with these builds</a>.</p>
<p>A replacement library is expected to provide the following functions, or any subset:</p>
<ul>
<li><code>void replace_init(const malloc_table_t *table)</code></li>
<li><code>void *replace_malloc(size_t size)</code></li>
<li><code>int replace_posix_memalign(void **ptr, size_t alignment, size_t size)</code></li>
<li><code>void *replace_aligned_alloc(size_t alignment, size_t size)</code></li>
<li><code>void *replace_calloc(size_t num, size_t size)</code></li>
<li><code>void *replace_realloc(void *ptr, size_t size)</code></li>
<li><code>void replace_free(void *ptr)</code></li>
<li><code>void *replace_memalign(size_t alignment, size_t size)</code></li>
<li><code>void *replace_valloc(size_t size)</code></li>
<li><code>size_t replace_malloc_usable_size(usable_ptr_t ptr)</code></li>
<li><code>size_t replace_malloc_good_size(size_t size)</code></li>
<li><code>void replace_jemalloc_stats(jemalloc_stats_t *stats)</code></li>
<li><code>void replace_jemalloc_purge_freed_pages()</code></li>
<li><code>void replace_jemalloc_free_dirty_pages()</code></li>
</ul>
<p>The first function, <code>replace_init</code> is the first function from the library that will be called (if it exists), before the first call to any other. It is passed a pointer to a function table containing pointers to the corresponding jemalloc functions from Firefox.</p>
<p>The last three functions are specific to jemalloc. <code>jemalloc_stats</code> is only important to replace if you want <code>about:memory</code> to still be accurate according to anything you&#8217;ve done in other functions, and <code>jemalloc_purge_freed_pages</code> and <code>jemalloc_free_dirty_pages</code> are used to force the allocator to return some unused memory to the system.</p>
<p>The other functions are the usual suspects, picked from C89, POSIX, C11, or OSX (<code>malloc_good_size</code>). They should however all be considered cross-platform (especially <code>malloc_good_size</code>).</p>
<p>All these functions, when they exist, are called <b>instead of</b> the corresponding jemalloc functions, which makes it the responsibility of the replacing functions to call back the corresponding jemalloc function if necessary.<br />
This allows, for example, to:</p>
<ul>
<li>Replace jemalloc entirely. The third patch <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=804303">bug 804303</a> does that to allow to replace the (currently default) old fork of jemalloc with a fresh jemalloc. Something similar could be done to test other allocators, like tcmalloc.</li>
<li>Make memory allocation functions randomly return NULL as in Out of Memory conditions, aka fuzzing.</li>
<li>Make all allocations bigger to add tracing data.</li>
<li>Log allocations.</li>
<li>etc.</li>
</ul>
<h2>A small implementation example</h2>
<p>Consider the following question: how many times does <code>realloc</code> end up copying data? Stated differently, how many times does <code>realloc</code> not return the pointer it was given?</p>
<p>Create the <code>memory/replace/realloc/realloc.c</code> file with the following content:</p>
<blockquote><pre>// This header will declare all the replacement functions, such that you don't need
// to worry about exporting them with the right idiom (dllexport, visibility...)
#include "replace_malloc.h"
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;

static const malloc_table_t *funcs = NULL;
static unsigned int total = 0, copies = 0;

void print_stats()
{
  printf("%d reallocs, %d copies\n", total, copies);
}

void replace_init(const malloc_table_t *table)
{
  funcs = table;
  atexit(print_stats);
}

void *replace_realloc(void *ptr, size_t size)
{
  void *newptr = funcs->realloc(ptr, size);
  // Not thread-safe, but it's only an example.
  total++;
  // We don't want to count deallocations as copies.
  if (newptr &amp;&amp; newptr != ptr)
    copies++;
  return newptr;
}
</pre>
</blockquote>
<p>Add a <code>memory/replace/realloc/Makefile.in</code> file:</p>
<blockquote><pre>DEPTH           = @DEPTH@
topsrcdir       = @top_srcdir@
srcdir          = @srcdir@
VPATH           = @srcdir@

include $(DEPTH)/config/autoconf.mk

LIBRARY_NAME = replace_realloc
FORCE_SHARED_LIB = 1
NO_DIST_INSTALL = 1

CSRCS = realloc.c

MOZ_GLUE_LDFLAGS = # Don't link against mozglue
WRAP_LDFLAGS = # Never wrap malloc function calls with -Wl,--wrap

include $(topsrcdir)/config/rules.mk
</pre>
</blockquote>
<p>Add the following to <code>memory/replace/Makefile.in</code>:</p>
<blockquote><pre>DIRS += realloc</pre>
</blockquote>
<p>Finally, build <code><i>objdir</i>/memory/replace</code>. You&#8217;ll get a library in <code><i>objdir</i>/memory/replace/realloc</code> that you can use as described at the beginning of this post.</p>
<p>On my system, after starting and quitting Firefox without doing much, it prints:</p>
<blockquote><pre>41078 reallocs, 37197 copies</pre>
</blockquote>
<p>It sure is a simple example, that can actually be fulfilled with other tools (like dtrace), but it&#8217;s now up to you, developers, to come up with more useful uses. The <a href="https://bugzilla.mozilla.org/showdependencytree.cgi?id=804303&#038;maxdepth=1&#038;hide_resolved=0">blocked bugs already show some</a>. Note this facility still has the advantage of being more cross-platform than tools like dtrace, and to work happily on top of jemalloc (valgrind, for instance, doesn&#8217;t support that gracefully), which can be important when looking at some particular aspects of memory allocation. The above example, while simple, is a typical case where the underlying memory allocation library has an impact on the result: other memory allocation libraries have different size classes, which modifies how often realloc will need to actually reallocate, as opposed to grow the existing allocation in-place.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2848</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Debian EFI mode boot on a Macbook Pro, without rEFIt</title>
		<link>http://glandium.org/blog/?p=2830</link>
		<comments>http://glandium.org/blog/?p=2830#comments</comments>
		<pubDate>Sun, 18 Nov 2012 10:18:14 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2830</guid>
		<description><![CDATA[Diego&#8217;s post got me to switch from grub-pc to grub-efi to boot Debian on my Macbook Pro. But I wanted to go further: getting rid of rEFIt. rEFIt is a pretty useful piece of software, but it&#8217;s essentially dead. There is the rEFInd fork, which keeps it up-to-date, but it doesn&#8217;t really help with FileVault. [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blogs.gnome.org/diegoe/2012/11/16/efi-mode-boot-on-macbook31-with-debian/">Diego&#8217;s post</a> got me to switch from grub-pc to grub-efi to boot Debian on my Macbook Pro. But I wanted to go further: getting rid of rEFIt.</p>
<p><a href="http://refit.sourceforge.net/">rEFIt</a> is a pretty useful piece of software, but it&#8217;s essentially dead. There is the <a href="http://www.rodsbooks.com/refind/">rEFInd fork</a>, which keeps it up-to-date, but it doesn&#8217;t really help with <a href="http://support.apple.com/kb/HT4790">FileVault</a>. Moreover, the boot sequence for a Linux distro with rEFIt/rEFInd looks like: Apple EFI firmware → rEFIt/rEFInd → GRUB → Linux kernel. Each intermediate step adding its own timeout, so rEFIt/rEFInd can be seen as not-so-useful intermediate step.</p>
<p>Thankfully, Matthew Garrett did all the research to allow <a href="http://mjg59.dreamwidth.org/12037.html">to directly boot GRUB from the Apple EFI firmware</a>. Unfortunately, his blog post didn&#8217;t have much actual detail on how to do it.</p>
<p>So here it is, for a Debian system:</p>
<ul>
<li>Install a few packages you&#8217;ll need in this process:<br />
<blockquote><pre># apt-get install hfsprogs icnsutils</pre>
</blockquote>
</li>
<li>Create a small HFS+ partition. I have a 9MB one, but it&#8217;s only filled by about 500K, so even smaller should work too. If, like me, you were previously using grub-pc, you probably have a GRUB partition, you can repurpose it. In <code>gdisk</code>, it looks like this:<br />
<blockquote><pre>Number  Start (sector)    End (sector)  Size       Code  Name
   5       235284480       235302943   9.0 MiB     AF00  Apple HFS/HFS+

Partition GUID code: 48465300-0000-11AA-AA11-00306543ECAC (Apple HFS/HFS+)
Partition unique GUID: AD1F5465-B777-4178-AC4D-1DE8B2EB1B4B
First sector: 235284480 (at 112.2 GiB)
Last sector: 235302943 (at 112.2 GiB)
Partition size: 18464 sectors (9.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'Apple HFS/HFS+'
</pre>
</blockquote>
</li>
<li>Create a HFS+ filesystem on that partition:<br />
<blockquote><p><code># mkfs.hfsplus /dev/sda5 -v Debian</code></p></blockquote>
<p>(replace <code>/dev/sda5</code> with whatever your partition is)
</li>
<li>Add a <code>fstab</code> entry for that filesystem:<br />
<blockquote><pre># echo $(blkid -o export -s UUID /dev/sda5) /boot/efi auto defaults 0 0 &gt;&gt; /etc/fstab</pre>
</blockquote>
</li>
<li>Mount the filesystem:<br />
<blockquote><pre># mkdir /boot/efi
# mount /boot/efi
</pre>
</blockquote>
</li>
<li>Edit <code>/usr/sbin/grub-install</code>, look for « <code>xfat</code> », and remove the block of code that looks like:<br />
<blockquote><pre>if test "x$efi_fs" = xfat; then :; else
    echo "${efidir} doesn't look like an EFI partition." 1>&#038;2
    efidir=
fi
</pre>
</blockquote>
</li>
<li>Run <code>grub-install</code>. At this point, there should be a <code>/boot/efi/EFI/debian/grubx64.efi</code> file (if using <code>grub-efi-amd64</code>).</li>
<li>Create a <code>/boot/efi/System/Library/CoreServices</code> directory:<br />
<blockquote><pre># mkdir -p /boot/efi/System/Library/CoreServices</pre>
</blockquote>
</li>
<li>Create a hard link:<br />
<blockquote><pre># ln /boot/efi/EFI/debian/grubx64.efi /boot/efi/System/Library/CoreServices/boot.efi</pre>
</blockquote>
</li>
<li>Create a dummy <code>mach_kernel</code> file:<br />
<blockquote><pre># echo "This file is required for booting" &gt; /boot/efi/mach_kernel</pre>
</blockquote>
</li>
<li>Grab the <a href="http://www.codon.org.uk/~mjg59/mactel-boot/mactel-boot-0.9.tar.bz2"><code>mactel-boot</code> source code</a>, unpack and build it:<br />
<blockquote><pre># wget http://www.codon.org.uk/~mjg59/mactel-boot/mactel-boot-0.9.tar.bz2
# tar -jxf mactel-boot-0.9.tar.bz2
# cd mactel-boot-0.9
# make PRODUCTVERSION=Debian
</pre>
</blockquote>
</li>
<li>Copy the <code>SystemVersion.plist</code> file:<br />
<blockquote><pre># cp SystemVersion.plist /boot/efi/System/Library/CoreServices/</pre>
</blockquote>
</li>
<li>Bless the boot file:<br />
<blockquote><pre># ./hfs-bless /boot/efi/System/Library/CoreServices/boot.efi</pre>
</blockquote>
</li>
<li>(optional) Add an icon:<br />
<blockquote><pre># rsvg-convert -w 128 -h 128 -o /tmp/debian.png /usr/share/reportbug/debian-swirl.svg
# png2icns /boot/efi/.VolumeIcon.icns /tmp/debian.png
# rm /tmp/debian.png
</pre>
</blockquote>
</li>
</ul>
<p>Now, the Apple Boot Manager, shown when holding down the option key when booting the Macbook Pro, looks like this:<br />
<img src="/blog/wp-content/uploads/2012/11/MBP-boot-manager-with-Debian.png" /></p>
<p>And the Startup disk preferences dialog under OSX, like this:<br />
<img src="/blog/wp-content/uploads/2012/11/Startup-disk-prefs.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2830</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Fun with weak dynamic linking</title>
		<link>http://glandium.org/blog/?p=2764</link>
		<comments>http://glandium.org/blog/?p=2764#comments</comments>
		<pubDate>Mon, 05 Nov 2012 20:49:26 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2764</guid>
		<description><![CDATA[Dynamic linkers, at least in the UNIX world, usually allow to load libraries in a process address space at startup. On Linux systems, you load such a library with LD_PRELOAD. On OSX, with DYLD_INSERT_LIBRARIES. On Linux systems, when using LD_PRELOAD, the dynamic linker will also use symbols from the (pre)loaded library instead of system libraries. [...]]]></description>
				<content:encoded><![CDATA[<p>Dynamic linkers, at least in the UNIX world, usually allow to load libraries in a process address space at startup. On Linux systems, you load such a library with <code>LD_PRELOAD</code>. On OSX, with <code>DYLD_INSERT_LIBRARIES</code>.</p>
<p>On Linux systems, when using <code>LD_PRELOAD</code>, the dynamic linker will also use symbols from the (pre)loaded library instead of system libraries. For example, if a program calls the <code>write</code> function and a library exporting a <code>write</code> symbol is loaded with <code>LD_PRELOAD</code>, the <code>write</code> function from the loaded library will be used instead of that of the libc (even when the symbol version doesn&#8217;t match).</p>
<p>On OSX, symbol resolution is usually done with a &#8220;two-level namespace&#8221;: symbols are associated with library names, and when resolving symbols, both are used. More than that, the library name is used to find the library in the dyld search path. Libraries loaded with <code>DYLD_INSERT_LIBRARIES</code> won&#8217;t be used with two-level namespace symbol resolution, which makes it less useful than <code>LD_PRELOAD</code>. Fortunately, it is also possible to use a &#8220;flat&#8221; namespace, in which case only the symbol name is considered during symbol resolution, and is searched in all loaded libraries, in the order in which they were loaded. Flat namespace can be triggered by setting the <code>DYLD_FORCE_FLAT_NAMESPACE</code> environment variable, linking the main program with <code>-force_flat_namespace</code>, or linking programs and libraries with the <code>-flat_namespace</code> argument. Note the latter only affects the programs and libraries built with that argument, while the former two force to use a flat namespace for all libraries, including those which, like system ones, were built with a two-level namespace. There are also cases where a single symbol may be resolved with the flat namespace, while others in the program or library are using two-level namespace.</p>
<p>Weak dynamic linking is another feature that can be used to tell the dynamic linker to ignore missing symbols. Consider the following source code:</p>
<blockquote><pre>extern void foo() __attribute__((weak)); // weak_import is preferred on OSX.
int main() {
  if (foo)
    foo();
  return 0;
}
</pre>
</blockquote>
<p>On Linux systems, this just works. Compile the program (you&#8217;ll need to build it with <code>-fPIC</code>, though), start it, and it will do nothing, since <code>foo</code> is defined nowhere.</p>
<p>Combined with shared library (pre)loading, this can be used to provide simple hooks in your application. For example, with the following source code built as a shared library:</p>
<blockquote><pre>#include &lt;stdio.h&gt;
void foo() {
  printf("foo\n");
}
</pre>
</blockquote>
<p>Running the program again with <code>LD_PRELOAD</code> set to load that shared library (note <code>LD_PRELOAD=foo.so</code> won&#8217;t work, a path is needed, like <code>LD_PRELOAD=./foo.so</code>), it will print <code>foo</code> because the dynamic linker will have resolved the <code>foo</code> symbol to that of the shared library.</p>
<p>On OSX, unfortunately, things are not as easy. First, building the test program above fails:</p>
<blockquote><pre>Undefined symbols for architecture x86_64:
  "_foo", referenced from:
      _main in test-LIeVtB.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</pre>
</blockquote>
<p>There are linker options to force undefined symbols to be resolved at runtime:</p>
<ul>
<li><code>-undefined dynamic_lookup</code>, which will mark all undefined symbols as having to be looked up at runtime,</li>
<li><code>-Wl,-U,<i>symbol_name</i></code>, which only does so for the given symbol (note: you have to prepend an underscore to the symbol name)</li>
</ul>
<p>With one of these options, the program works as on Linux: it does nothing when run alone, and prints <code>foo</code> when loading the library with <code>DYLD_INSERT_LIBRARIES</code>&#8230; if you build with XCode 4.5. Running the program built with XCode 4.3 fails when <em>not</em> loading the shared library, with the following error:</p>
<blockquote><pre>dyld: Symbol not found: _foo
  Referenced from: ./test
  Expected in: flat namespace
 in ./test
Trace/BPT trap: 5
</pre>
</blockquote>
<p>And if at build time, you target OSX 10.5 (with <code>MACOSX_DEPLOYMENT_TARGET</code> or <code>-mmacosx-version-min</code>), the error is slightly different:</p>
<blockquote><pre>dyld: Symbol not found: _foo
  Referenced from: ./test
  Expected in: dynamic lookup

Trace/BPT trap: 5
</pre>
</blockquote>
<p>Each error is due to a different bug:</p>
<ul>
<li>Since OSX 10.6, the link edition rules in the <code>__LINKEDIT</code> segment are in a new, compressed, format: DYLD_INFO. The linker in Xcode &lt; 4.5 forgets to flag weak imports as weak in the DYLD_INFO data. Compare the output for <code>dyldinfo</code> with a binary built with Xcode 4.5 vs. the output for a binary built with Xcode 4.3:<br />
<blockquote><pre>$ dyldinfo -bind test-xcode4.5 | sed -n '2p;/foo/p'
segment section          address        type    addend dylib            symbol
__DATA  __got            0x100001038    pointer      0 flat-namespace   _foo (weak import)

$ dyldinfo -bind test-xcode4.3 | sed -n '2p;/foo/p'
segment section          address        type    addend dylib            symbol
__DATA  __got            0x100001038    pointer      0 flat-namespace   _foo
</pre>
</blockquote>
<p>Notice the missing <code>weak import</code>. Manually setting the flag with a hexadecimal editor fixes it (in both bind and lazy_bind tables).
</li>
<li>In older OSX releases, the link edition rules use a &#8220;classic&#8221; format. In that format, the symbol table is used for flags such as <code>N_WEAK_REF</code> (weak reference). In the new <code>DYLD_INFO</code> format, the <code>N_WEAK_REF</code> flag isn&#8217;t used, which partly explains the previous bug. When using the old format and two-level namespaces, missing weak symbols are errors. With flat namespace, they aren&#8217;t. This means the error we get with a program built for a 10.5 target goes away if building with <code>-flat_namespace</code>. Note this doesn&#8217;t work at the symbol level: if the library is built for two-level namespace (and is marked as such in the Mach-O header), and the weak symbol is without a corresponding library name, making it resolved with a flat namespace, it doesn&#8217;t work.</li>
</ul>
<p>At this point, one could think weak dynamic linking is pretty much useless on OSX, at least, that it was before Xcode 4.5 was released. As it turns out, there are other use cases where it actually works. Consider the following code:</p>
<blockquote><pre>#include &lt;malloc/malloc.h&gt;
// The following is defined in malloc/malloc.h:
// extern size_t malloc_zone_pressure_relief(malloc_zone_t *zone, size_t goal) __attribute__((weak_import));
int main() {
  if (malloc_zone_pressure_relief)
    malloc_zone_pressure_relief(NULL, 0);
  return 0;
}
</pre>
</blockquote>
<p>This program in itself is useless, but the point is, the <code>malloc_zone_pressure_relief</code> function is only available since OSX 10.7. Without the <code>weak_import</code>, the program would fail to start with an undefined symbol on OSX 10.6 and below. Without the <code>if</code>, it would crash because the symbol would resolve to NULL, and the program would jump there. But the program itself has to be built on OSX 10.7 at least, for the <code>malloc_zone_pressure_relief</code> function to be there when building.</p>
<p>And in that use-case, we end up with the right flags in <code>DYLD_INFO</code>:</p>
<blockquote><pre>$ dyldinfo -bind test | sed -n '2p;/malloc/p'
segment section          address        type    addend dylib            symbol
__DATA  __got            0x100001038    pointer      0 libSystem        _malloc_zone_pressure_relief (weak import)
</pre>
</blockquote>
<p>This actually gives us a hint for a way out of our misery for our <code>foo</code> function on Xcode &lt; 4.5: linking against a dummy library implementing the weak symbol. When doing so, we get the proper flag in <code>DYLD_INFO</code>, like with <code>malloc_zone_pressure_relief</code>:</p>
<blockquote><pre>$ dyldinfo -bind test | sed -n '2p;/foo/p'
segment section          address        type    addend dylib            symbol
__DATA  __got            0x100001038    pointer      0 libfoo           _foo (weak import)
</pre>
</blockquote>
<p>And the linker additionally does something nice: when all symbols needed from a library are weak references, it marks the library import itself as weak:</p>
<blockquote><pre>$ otool -l test | grep -B 2 libfoo
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 40
         name libfoo.dylib (offset 24)
</pre>
</blockquote>
<p>What this means is that even if the <code>libfoo.dylib</code> is missing, it will still work. The downside is that we are now using two-level namespace, which, as mentioned above, makes <code>DYLD_INSERT_LIBRARIES</code> useless. The program thus needs to be built with a flat namespace.</p>
<p><b>Update:</b> It turns out some versions of XCode don&#8217;t conveniently mark libraries with only weak imports as weakly linked, so the <code>-Wl,-weak_library,<em>libraryname</em>.dylib</code> flag is required instead of <code>-L<em>libraryname</em></code>.</p>
<p>In summary, if you want to add optional hooks that a library loaded through <code>LD_PRELOAD</code>/ <code>DYLD_INSERT_LIBRARIES</code> can implement:</p>
<ul>
<li>on OSX &lt; 10.6, use weak symbols and build with <code>-flat_namespace</code>,</li>
<li>on OSX &gt;= 10.6, when building with Xcode &lt; 4.5, use weak symbols, build with <code>-flat_namespace</code> and link against a dummy library implementing the hook functions with <code>-Wl,-weak_library,<em>libraryname</em>.dylib</code>,</li>
<li>on Linux systems and on OSX &gt;= 10.6, when building with Xcode 4.5, simply use weak symbols,</li>
<li>on Windows, to the best of my knowledge, weak dynamic linking is not supported.</li>
</ul>
<p>Stay tuned for the next post, which will describe what this will be used for in Firefox.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2764</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Android Debug Bridge for Firefox</title>
		<link>http://glandium.org/blog/?p=2722</link>
		<comments>http://glandium.org/blog/?p=2722#comments</comments>
		<pubDate>Thu, 23 Aug 2012 18:35:51 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2722</guid>
		<description><![CDATA[I uploaded an experimental add-on on AMO that adds some kind of support for the Android Debug Bridge to Firefox. It requires the adb/adb.exe executable from the Android SDK. Disclaimer: the add-on is experimental and is known to leak small amounts of memory and have various problems handling errors. It&#8217;s also on github, if you [...]]]></description>
				<content:encoded><![CDATA[<p>I uploaded an experimental add-on on AMO that adds <a href="https://addons.mozilla.org/en-US/firefox/addon/android-debug-bridge-for-fi/">some kind of support for the Android Debug Bridge</a> to Firefox. It requires the <code>adb</code>/<code>adb.exe</code> executable from the Android SDK. <b>Disclaimer</b>: the add-on is experimental and is known to leak small amounts of memory and have various problems handling errors. It&#8217;s also <a href="https://github.com/glandium/adb4ff">on github</a>, if you want to give a hand.</p>
<p>The add-on provides three features.</p>
<p><img src="/blog/wp-content/uploads/2012/08/adb.png" /></p>
<p>The first one is access to Android and Firefox OS devices filesystem through the <code>adb://</code> protocol. Without the serial number for any device, a list of connected devices is shown, like in the screenshot above. With a device serial number in the url (<code>adb://<i>serial</i>/</code>), it shows filesystem contents, as below:</p>
<p><img src="/blog/wp-content/uploads/2012/08/adb-directory.png" /></p>
<p>Please note the add-on doesn&#8217;t work well with symbolic links at the moment.</p>
<p>Another feature is the ability to grab the framebuffer on a device and display it as a PNG image. This feature is available through <code>adbview://</code> urls, and like <code>adb://</code>, a list of connected devices will be shown if no device serial is given.</p>
<p>It can show a screen capture of Android devices:<br />
<img src="/blog/wp-content/uploads/2012/08/adbview.png" /></p>
<p>As well as Firefox OS devices:<br />
<img src="/blog/wp-content/uploads/2012/08/adbview-b2g.png" /></p>
<p>For Firefox OS devices, it requires <a href="https://github.com/mozilla-b2g/screencap-gonk">a fork of the screencap tool</a>. It should be <a href="https://github.com/mozilla-b2g/b2g-manifest/commit/2901ddaed139ce9c2afeb7c0d23fd94941de90b3">included</a> in recent Firefox OS builds.</p>
<p>Finally, the add-on improves the <a href="http://starkravingfinkle.org/blog/2012/08/firefox-for-android-remote-debugging-is-here/">Remote Debugging feature included in Firefox</a>. As described on <a href="http://starkravingfinkle.org/blog/2012/08/firefox-for-android-remote-debugging-is-here/">Mark Finkle&#8217;s blog</a>, you would normally type an <code>adb</code> command to forward a tcp port first. When you have several devices, that requires forwarding different local ports to port 6000 on each device, and remembering which is which.</p>
<p>The addon allows to skip that step, and to connect through the Android Debug Bridge directly, without local port forwarding.</p>
<p>Check out Mark&#8217;s post for instructions to enable Remote Debugging on both the device and desktop.</p>
<p><img src="http://glandium.org/blog/wp-content/uploads/2012/08/remote-debugger-adb.png" /></p>
<p>The prompt shown when opening the Remote Debugger is augmented with a list of devices. <code>local</code> is the desktop machine running Firefox. The other items in the list are the connected Android or Firefox OS devices. This relies on monkey-patching Firefox Remote Debugger code, so this is not completely reliable, currently only works with a recent Firefox 17 nightly, and may break at any time in the future.</p>
<p><img src="http://glandium.org/blog/wp-content/uploads/2012/08/remote-debugger-adb-select.png" /></p>
<p>When you select a device, you shouldn&#8217;t need to change the <code>host:port</code> field, but you could theoretically change it to access even more remote devices through the device&#8217;s network.</p>
<p>Once you selected a device in the Remote Debugger prompt, you get the usual prompt on the device itself:</p>
<p><img src="http://glandium.org/blog/wp-content/uploads/2012/08/remote-debugger-prompt.png" width="240" height="400" /></p>
<p>(By the way, the screenshot above was taken with <code>adbview://</code>)</p>
<p>That brings up scripts running in the Firefox instance on the device:</p>
<p><img src="http://glandium.org/blog/wp-content/uploads/2012/08/remote-debugger-view.png" /></p>
<p>Thanks to the mobile team for having brought Remote Debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2722</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Forget about autoconf.mk.in</title>
		<link>http://glandium.org/blog/?p=2713</link>
		<comments>http://glandium.org/blog/?p=2713#comments</comments>
		<pubDate>Tue, 07 Aug 2012 17:58:00 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2713</guid>
		<description><![CDATA[When you add a flag somewhere in configure.in and need to use it in code or in the build system, you use AC_SUBST or AC_DEFINE. While using AC_DEFINE in configure.in is usually sufficient for its purpose, using AC_SUBST requires to add some boilerplate in config/autoconf.mk.in, in the form: VARIABLE_NAME = @VARIABLE_NAME@ Here&#8217;s the news for [...]]]></description>
				<content:encoded><![CDATA[<p>When you add a flag somewhere in <code>configure.in</code> and need to use it in code or in the build system, you use <code>AC_SUBST</code> or <code>AC_DEFINE</code>. While using <code>AC_DEFINE</code> in <code>configure.in</code> is usually sufficient for its purpose, using <code>AC_SUBST</code> requires to add some boilerplate in <code>config/autoconf.mk.in</code>, in the form:</p>
<blockquote><pre>VARIABLE_NAME = @VARIABLE_NAME@
</pre>
</blockquote>
<p>Here&#8217;s the news for you: these days are over. With <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=742795">bug 742795</a>, now on mozilla-central, <code>autoconf.mk</code> is auto-generated. No need to touch <code>config/autoconf.mk.in</code> anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2713</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The DEPTH of me</title>
		<link>http://glandium.org/blog/?p=2709</link>
		<comments>http://glandium.org/blog/?p=2709#comments</comments>
		<pubDate>Mon, 06 Aug 2012 16:52:34 +0000</pubDate>
		<dc:creator>glandium</dc:creator>
				<category><![CDATA[p.m.o]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://glandium.org/blog/?p=2709</guid>
		<description><![CDATA[When adding a new directory to the Mozilla codebase, one usually needs to add a Makefile.in file, with some magic incantations at the beginning of it: DEPTH = ../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk etc. Some even add: relativesrcdir = foo/bar In the above, DEPTH and relativesrcdir both need [...]]]></description>
				<content:encoded><![CDATA[<p>When adding a new directory to the Mozilla codebase, one usually needs to add a <code>Makefile.in</code> file, with some magic incantations at the beginning of it:</p>
<blockquote><pre>DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

<i>etc.</i>
</pre>
</blockquote>
<p>Some even add:</p>
<blockquote><pre>relativesrcdir = foo/bar
</pre>
</blockquote>
<p>In the above, <code>DEPTH</code> and <code>relativesrcdir</code> both need to be carefully filled depending where the <code>Makefile.in</code> is.</p>
<p>As of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=774032">bug 774032</a>, landed over the week-end (along with some now hopefully fixed tree breakage for some people, sorry for the inconvenience), there are two additional substitution variables for <code>Makefile.in</code> that replace the need to be careful.</p>
<p>Now the boilerplate for a new <code>Makefile.in</code> is:</p>
<blockquote><pre>DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

<i>etc.</i>
</pre>
</blockquote>
<p>And, if needed,</p>
<blockquote><pre>relativesrcdir = @relativesrcdir@
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://glandium.org/blog/?feed=rss2&#038;p=2709</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
