How to build dfu-util from source

Prerequisites for building from git

Mac OS X

First install MacPorts (and if you are on 10.6 or older, the Java Developer Package) and then run:

	sudo port install libusb-devel git-core

FreeBSD

	sudo pkg_add -r git pkgconf

Ubuntu and Debian and derivatives

	sudo apt-get build-dep dfu-util
	sudo apt-get install libusb-1.0-0-dev

Get the source code and build it

The first time you will have to clone the git repository:

	git clone git://gitorious.org/dfu-util/dfu-util.git
	cd dfu-util

If you later want to update to latest git version, just run this:

	make maintainer-clean
	git pull

To build the source:

	./autogen.sh
	./configure  # on most systems
	make

If you are building on Mac OS X, replace the ./configure command with:

	./configure --libdir=/opt/local/lib --includedir=/opt/local/include  # on MacOSX only

Your dfu-util binary will be inside the src folder. Use it from there, or install it to /usr/local/bin by running "sudo make install".

Building for Windows

Windows binaries can be built in a MinGW environment, on a Windows computer or cross-hosted in another OS. To build it on a Ubuntu 12.04 host, first install build dependencies:

	sudo apt-get build-dep libusb-1.0-0 dfu-util
	sudo apt-get install mingw32

The below example script builds dfu-util 0.6 and libusb 1.0.9 from release tarballs. If you instead build from git, you will have to run "./autogen.sh" before running the "./configure" steps.

#!/bin/sh

#
# The dfu-util binaries for Windows (win32) were built on Ubuntu 12.04
# using this build script.
#
# To install needed build dependencies run:
#  sudo apt-get build-dep libusb-1.0-0 dfu-util
#  sudo apt-get install mingw32
#

set -e

BUILD_DIR=/tmp/mingw
MINGW_VERSION=i586-mingw32msvc

[ -d $BUILD_DIR ] || mkdir -p $BUILD_DIR
cd $BUILD_DIR

# get libusb sources
[ -d libusb-1.0.9 ] || { wget -O libusb-1.0.9.tar.bz2 http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2/download ; tar jxvf libusb-1.0.9.tar.bz2 ;}
cd libusb-1.0.9
PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig ./configure --host=$MINGW_VERSION --prefix=$BUILD_DIR
make
make install
cd ..

# get dfu-util sources
[ -d dfu-util ] || { wget http://dfu-util.gnumonks.org/releases/dfu-util-0.6.tar.gz ; tar zxvf dfu-util-0.6.tar.gz ;}
cd dfu-util-0.6
PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig ./configure --host=$MINGW_VERSION --prefix=$BUILD_DIR
make
make install
cd ..

[Back to dfu-util main page]