Subject: Re: documentation for in-tree autoconf & wrapper
To: None <blair.sadewitz@gmail.com>
From: Masao Uebayashi <uebayasi@gmail.com>
List: current-users
Date: 01/11/2007 10:22:04
> I'm wondering if there's any reading out there on how GNU autoconf
> interfaces with our build system, especially with regard to
> cross-compiling.
> 
> If not, if someone who knows offhand could give me a synopsis (one
> line per makefile is fine) of the makefiles involved and each of their
> functions, I'd really appreciate it.  I'm hoping to have the time to
> take a crack at getting modular Xorg to build in the reachover
> framework soon.

I have been trying the exact same thing here; convert Automake files
(*.am) automagically into BSD makefiles, I use Dovecot and other
programs instead of Xorg though.

I wrote a set of super ugly sh + sed + Perl scripts, and I think I
could cross compile some programs.  This work is very incomplete yet,
but I believe the basic ideas should work to some extent, that is:

- Many GNU Autotools'ified package use Autoconf / Automake.  I want to
  build them on *only* NetBSD, and I want to cross compile them.

- We have well-designed cross compile infrastructure.  It can be
  available through BSD makefile.

- configure does OS-dependent / machine-dependent configurations.  I
  think most of them are OS-dependent, so configure needs to be run
  once in most cases.  We save the result and reuse it.
  machine-dependent part has to be separated out somehow, but let's
  consider later...

- If we write BSD makefiles for those programs, most information we
  need is in Makefile.am.

- Automake parser is very complicate Perl scripts.  

- If you look at one of Makefile.am, you'll find it is simple and is
  nearly compatible with BSD makefile, with some exceptions.  Those
  files can be included (.include ...) from within BSD makefile, after
  trimming those exceptions.  Let's consider those exceptions later...

- Makefile.am can define multiple programs / libraries in one file.
  BSD makefile (bsd.prog.mk / bsd.lib.mk) can define one for each.  We
  have to care about this.

- Makefile.am defines subdirectories.  This is similar to BSD's.

- ...

So, the basic strategy I took was:

- Find Makefile.am and trim them (remove conditionals and target
  definitions), generate "trimmed" Makefile.am, which I call
  "Makefile.nb".

- Dig directory tree along with original's directory tree.

- Dig sets of (directory + BSD makefile) for each Makefile.nb; e.g.,
  if a Makefile.nb defines two programs, foo and bar:

	${ORIGDIR}/.../Makefile.nb

	${ROVRDIR}/.../Makefile		<- SUBDIR=	foo bar
	${ROVRDIR}/.../foo/
	${ROVRDIR}/.../foo/Makefile	<- PROG=	foo
	${ROVRDIR}/.../bar/
	${ROVRDIR}/.../bar/Makefile	<- PROG=	bar

- Do many other hacks needed.

I hope I'll post scripts after cleaning up them, this weekend.

Masao