How to compile OpenObex on Windows platform
===========================================

You should read INSTALL.txt before continuing reading this file.

1 Requirements
==============

The requirements to compile OpenObex on Windows are fairly low:
1. a compiler
2. the Platform SDK (now also called Windows SDK)
3. LibUSB-Win32[1]
4. CMake(>= 2.6)[2] or autoconf+automake

The supported compilers are:
 * Microsoft Visual Studio 2010 (10)
 * Microsoft Visual Studio 2008 (9)
 * Microsoft Visual Studio 2005 (8)
 * Microsoft Visual Studio .NET 2003 (7.1)
 * MinGW gcc
 * Cygwin gcc

Visual Studio 2008 and 2010 already include the SDK.

[1]: at http://libusb-win32.sf.net (if not compiling for cygwin)
[2]: at http://www.cmake.org


2 Compilation
=============

There are two ways to compile OpenObex. Step 2a describes building with
autoconf+automake, step 2b describes building with CMake. The latter is
recommended as it is a lot easier to setup and supports more environments.


2a Compilation using autoconf+automake
======================================

Compiling with autoconf+automake is restricted to a very specific environment,
an Unix-like one. Under Windows, this can only be provided by MSYS or Cygwin.

MSYS
----

You need to install the following extra packages from http://www.mingw.org:
  * MSYS (1.0.10 works)
  * msysDTK (1.0.1 works)

Libtool from msysDTK in incomplete, it needs an additional 'file' utility. You
can get this from http://gnuwin32.sf.net. Do NOT install it in the MSYS
directory but somewhere else that is already mounted and in $PATH (e.g. into
the mingw directory).

Additionally, download the following packages from e.g.
http://www.gtk.org/download-windows.html:
  * pkg-config
Unpack them all into the same directory!

You need to prepare the build environment by editing /etc/fstab and mount the
libusb-win32 installation dir to /libusb. MinGW should already be present under
/mingw.
Additionally, you create /pdsk/include and copy the following header files from
the Platform SDK to there:
  ws2bth.h
  bthdef.h
  bthsdpdef.h
  af_irda.h

If you check out from VCS and configure does not exist, you can create it with:
  $ autoreconf -v -f -i

Now you need some environment variables for configure:
  $ export CFLAGS="-I/libusb/include -I/psdk/include"
  $ export LDFLAGS="-L/libusb/lib/gcc"

Now you can finally run configure:
  $ ./configure --prefix=/mingw --disable-shared

This will build a static library. Due to a bug in libtool, you cannot build the
static and the shared version at the same time.
To build the shared version, run:
  $ ./configure --prefix=/mingw --disable-static


2b Compilation using CMake
==========================

Visual Studio
-------------

Using Visual Studio >= 2008 (Express versions are sufficient) is the
recommended way of compiling under Windows. You must open the console link that
runs the proper vcvars.bat (see Start menu).
Then, you _MUST_ add the directories of the platform SDK include files,
libraries and executables to the environment variables INCLUDE, LIB and PATH.
Now, your build environment is set up. You can now call cmake with the proper
generator (see "cmake --help"). Using the "NMake Makefiles" generator, OpenObex
can be compiled directly in the command prompt window:
  > mkdir build
  > cd build
  > cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..
  > nmake


MinGW
-----

Install MinGW, including core and mingw32-make, to e.g. C:\mingw.
To get Bluetooth and Irda support, you must copy the following files from the
Platform SDK include directory to usr/local/include in the MinGW installation
directory:
  ws2bth.h
  bthdef.h
  bthsdpdef.h
  af_irda.h

Either you add MinGW bin directory to PATH, or you call the mingw32-make with
full path, both variations work.
Then, at the command prompt:
  > set PATH=%PATH%;C:\mingw\bin
  > mkdir build
  > cd build
  > cmake -G"MinGW Makefiles" ..
  > mingw32-make

You can also use MSYS as environment:
  > mkdir build
  > cd build
  > cmake -G"MSYS Makefiles" ..
  > make


Cygwin
------

You must not use the Windows version of CMake but a version compiled specially
for cygwin. You may also install cygwin version of libusb. Copy the same files
as for the MinGW case to /usr/local/include. Then cou can run in the cygwin
shell command window:
  $ mkdir build
  $ cd build
  $ cmake -G"Unix Makefiles" ..
  $ make



3 Installation
==============

You can run the installation directly by calling the "install" make target.
With the DESTDIR variable, you can add an additional prefix:
  $ make install DESTDIR=/some/directory

Additionally, when you used CMake, you can create installation packages but a
few steps are needed:
  * install NSIS
  * install a ZIP program (e.g. info-zip)
Now you are ready to run the "package" make target.
