# Building the Mach Interface Generator from Source
If you want to build the Mach Interface Generator yourself instead of just
using a pre-built package, follow these instructions.
## Getting the Source Code
You can chose between getting the [sources from the developers'
RCS](http://savannah.gnu.org/git/?group=hurd):
$ git clone git://git.savannah.gnu.org:/srv/git/hurd/mig.git
... or (if you are working on a Debian system) the ones that are used for the
[current Debian mig package](http://packages.debian.net/source/unstable/mig):
$ apt-get source mig
Please see the Debian [[hurd/running/debian/FAQ]] before using _apt-get source_.
The unpacked source tree is around 1 MiB, and the build tree also is around 1 MiB.
## On Debian Systems:
### Preparing for the Build
Building the Mach Interface Generator requires the _build-essential_ and
_fakeroot_ packages, their dependencies and additional packages that are
specified by the source mig package:
# apt-get install build-essential fakeroot
# apt-get build-dep mig
### Building and Installing ... a _.deb_ file
Change into the directory with the downloaded / unpacked MIG sources (_mig-1.3.1.99_):
$ cd mig-1.3.1.99
Start the build process:
$ dpkg-buildpackage -us -uc -b -rfakeroot
You can then install / distribute the _.deb_ file which will drop out one
directory above the current one.
## On non-Debian Systems:
### Preparing for the Build
Building the Mach Interface Generator requires a C compiler, a standard 32 bit
C library (with corresponding header files) and your favourite flavor of awk
(gawk), yacc (bison), lex (flex) and make.
Additionally, you need to have GNU Mach's header files installed. See
[[mach/gnumach/building]] about how to do that, then come back here.
### Building and Installing
First, generate the configuration files:
$ cd mig
$ autoreconf --install
The Mach Interface Generator should be built in a subdirectory:
$ mkdir mig-build
$ cd mig-build
Find the root directory where you installed GNU Mach's header files and where
you now intend to install the Mach Interface Generator (_~/gnu_) and the path
to your Mach Interface Generator sources (../mig) and configure it:
$ GNU=~/gnu
$ TARGET_CPPFLAGS=-I"$GNU"/include ../configure
The --host flag is necessary if you are building on a 64 bit machine:
$ GNU=~/gnu
$ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU" --host=i686-unknown-linux-gnu
Build and install the Mach Interface Generator into _$GNU_, i.e. _~/gnu/_ in our example:
$ make all install
To make your _mig_ binary easily available, you should append something like
the following to e.g. your _~/.bash\_profile_:
PATH=~/gnu/bin:$PATH
export PATH
If you already have e.g. _~/bin_ in your _$PATH_, you could also create a symbolic link:
$ ln -s ~/gnu/bin/mig ~/bin/