Pre-requisite:
--------------

This will be a some work ...

1.	You need a Microsoft C/C++-Compiler including the libraries, includes and
    build tools. You may use the compiler included in Visual Studio 6.0,
    Microsoft Visual Studio .NET 2003, Visual Studio 2005, Visual Studio 2008 etc.
    If you have Cygwin installed you can also also use it. See the file
    INSTALL for the compilation.
    Obey, that you will have problems with the portability on older systems if you
    use newer compiler suites, i.e. on systems without a installed
    .NET framework some libraries linked against are missing (e.g. there is
    a problem with newer versions of msvcrt, e.g. msvcr80 and msvcr90 which are
    not available under previous versions of Windows).

	For a free way to build you need:

	Microsoft® Visual C++ 2008 Express Edition
	http://www.microsoft.com/express/vc/

    to get a C/C++ compiler suite.

    You also need the Platform SDK to get the libraries for linking.

    Download the Windows Server 2003 R2 Platform SDK.

    http://www.microsoft.com/downloads/details.aspx?FamilyID=0baf2b35-c656-4969-ace8-e4c0c0716adb&DisplayLang=en

    The SDK integrates automatically into Visual C++ 2008 Express.

2.	You need OpenSSL. Download the full version from http://www.slproweb.com/products/Win32OpenSSL.html
    The headers and the linker libraries ssleay32.lib and libeay32.lib must be
    available. For using the library the files libeay32.dll and ssleay32.dll must
    be installed in a common library search path, e.g. Windows/System32 or the
    directory of the program which uses it.

3.	You need the zlib library.
    Install the developer files of Zlib for Windows.
    Download it from http://gnuwin32.sourceforge.net/packages/zlib.htm. The headers
    and the linker library zlib.lib must be available. For using the library the file zlib1.dll must be
    installed in a common library search path, e.g. Windows/System32 or the
    directory of the program which uses it.

4.  Download the Windows Driver Kit (WDK).

    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff

    The WDK is needed to build a Windows platform independent version without getting into conflict with different
    Windows msvcrt DLL versions.

    See http://kobyk.wordpress.com/2007/07/20/dynamically-linking-with-msvcrtdll-using-visual-c-2005/

5.	You need Doxygen for generating the documentation.
    www.doxygen.org/


Installation:
-------------

a) nmake compilation
--------------------

Important for Windows is that applications linked against GlobalPlatform must
use the UNICODE and _UNICODE switch. Otherwise the application will crash,
because the GlobalPlatform Library is compiled with Unicode support.

1.	Set the environment (These are include files and libraries and programs of
    the building environment) for compilation and open a command prompt. If you
    have Visual Studio 200x or there is a file vcvars32.bat in the bin directory
    which does this for you	and opens a command prompt. There is also a link in
    the Start menu of Windows. For Visual C++ 2008 Express Edition this also works.
    Now also set the environment vars for the Platform SDK with SetEnv.Cmd located in
    the SDK directory

2. 	Change into this directory (The directory with the GlobalPlatform sources).

3. 	Run nmake -f Makefile.mak to build a release version without debugging information.
	or run nmake -f Makefile.mak all "DEBUG=1" to build a debug version with debugging information.
	There are some arguments which are displayed in the beginning of the makefile. You
	can change them if you specify them on the command line or in the makefile.

	This arguments are:

	OPENSSL_INC   - The path to the headers of OpenSSL
	OPENSSL_LIB   - The path to the link library (.lib) of OpenSSL
	ZLIB_INC  	  - The path to the headers of zlib
	ZLIB_LIB  	  - The path to the link library (.lib) of zlib
	SDK_LIB1      - A path to the SDK directory with additional libraries (containing the winscard.lib)
	SDK_LIB2      - A path to the SDK directory with additional libraries (containing msvcrt.lib)
	SDK_LIB3      - A path to the WDK directory with additional libraries (only used for release version, containing msvcrt_win2000.obj)
	SDK_LIB4      - A path to the WDK directory with additional libraries (only used for release version, containing msvcrt.lib)


	E.g. nmake -f Makefile.mak OPENSSL_INC=C:\Program Files\OpenSSL\include
	OPENSSL_LIB=C:\Program Files\OpenSSL\lib ZLIB_INC=C:\Program Files\GnuWin32\include
	ZLIB_LIB=CProgram Files\GnuWin32\lib
    SDK_LIB1="Microsoft Platform SDK for Windows Server 2003 R2\Lib"
    SDK_LIB2="C:\Program Files\Microsoft Visual Studio 9.0\VC\lib"
    SDK_LIB3="C:\WinDDK\7600.16385.1\lib\win7\i386"
    SDK_LIB4="C:\WinDDK\7600.16385.1\lib\Crt\i386"

    The parameters SDK_LIB1 and SDK_LIB2 might be not necessary if you have a full
    version of Visual Studio. For Visual C++ 2008 Express Edition these both
    directories must point to the winscard.lib and msvcrt.lib libraries.

    There is a file called make.bat which does this compilation step.

4.	Optional
    Copy the GlobalPlatform.dll library from the Release or Debug directory to
    a location, where the application(s) using it can find it. This is a directory
    included in the %PATH% environment, usually at least e.g. Windows\System32
    You may also need the GlobalPlatform.lib from the appropriate directory
	if your are linking applications against the library.

5.	Optional
    Build the documentation with nmake -f Makefile.mak DOC

	Doxygen must be in the PATH environment variable.

6.  Optional
    Build a prebuilt package with nmake -f Makefile.mak PREBUILD
    You also need the cp and zip command from Cygwin Setup http://cygwin.com/
    Add the Cygwin bin directory to you %PATH% environment.

7.  Optional
	Run nmake -f Makefile.mak clean to delete the Debug and Release directories.

If you need to get debugging output you must have built a debug version and
enable the debugging by setting the environment variable GLOBALPLATFORM_DEBUG=1.
If you explicitly set a log file with the environment variable
GLOBALPLATFORM_LOGFILE, this log file will be used. The default log file is
C:\Temp\GlobalPlatform.log. This must be writable for the user. Keep in mind
that the debugging output may contain sensitive information, e.g. keys!

b) Optional: Visual Studio solution file
----------------------------------------

You can also use the solution file .sln file for Visual C++ 2008 Express Edition
 (may also work under the full version) if you prefer a comfortable IDE or for
development needs. When using the solution file then you have to adjust the
C/C++->General->Additional Include Directories,
Linker->General->Additional Library Directories, Linker->Input->Additional
Dependencies and Resources->General->Additional Include Directories fields.

c) Optional: Code::Blocks workspace file
----------------------------------------

Code::Blocks is a free IDE.

http://www.codeblocks.org/downloads/binaries

You can open the .workspace file. You must adjust your Compiler, Linker and
Resource Compiler search directories under the Build Options.

Further information
-------------------

For more information visit:

http://sourceforge.net/projects/globalplatform/
