HOW-TO-COMPILE
==============

Install QT 4.8, either using your packet manager or using the following        
download link: http://qt-project.org/downloads

You should not use QT 5.x.
   

Windows:
========

Use Visual Studio / Visual C++ 2010.

1. Use a command line, e.g. executing Win+R and entering "cmd.exe" and head
   to the adviemulator folder.

2. Enter "set QMAKESPEC=win32-msvc2010".

3. Qt is by default not part of your path, it is by default installed to
   "\Qt\4.8.4". The qmake tool is in "\Qt\4.8.4\bin".
   
   Execute "\Qt\4.8.4\bin\qmake -tp vc".
   
   The file "adviemulator.exe.vcxproj" and other Windows specific files
   will be generated.
   
3. Open "adviemulator.vcxproj" using Visual Studio / Visual C++ 2010.

4. Change "Debug" to "Release" in the header toolbar.

5. In the main menu, choose "Build / Clean Solution".

6. In the main menu, choose "Build / Build Solution". VS might ask you
   for a place to store the Solution File (SLN); you could for exaple 
   save it to the adviemulator folder.
   
7. The EXE file that you can use for distribution is located in the folder
   "release" of your adviemulator folder.
   
   IMPORTANT: If you linked to the default version of QT, you need to distribute
   the following DLLs together with your EXE file, e.g. by putting them to the
   same folder as your EXE:

   		QtCore4.dll
   		QtGui4.dll   
   		QtMultimedia4.dll
   		QtOpenGL4.dll
   		
   	The DLLs are located at \Qt\4.8.4\bin.
   	
   	Additionally, you need to distribute the MSVC 2010 redistributable files:
   	<http://www.microsoft.com/en-us/download/details.aspx?id=5555>
   	
   	ALTERNATELY: Create a statically linked version of QT by modifying
   	"C:\Qt\4.8.4\mkspecs\win32-msvc2010\qmake.conf":
	Change QMAKE_CFLAGS_RELEASE from -MD to -MT, and add /NODEFAULTLIB:MSVCRT
	to the QMAKE_LFLAGS_RELEASE. Then follow the various instructions in the
	internet how to compile QT. It is important, that the "configure.exe"
	is called with at least the parameters "-release -static".
	If you use such a QT version, then your EXE generated when running through
	the steps (1) .. (7) will be statically linked and self-contained, i.e.
	it needs no DLL and no additional installation of redistributable files
	at all.
   	
8. You may want to clean up by deleting files and folders matching to the
   following patterns:
   
   		ui*
   		*.sln *.suo *.vcxproj *.filters *.user *.pdb
   		debug
	

OSX:
====

g++/gcc:

Use the terminal.

1. Run "qmake" without command line parameters in the adviemulator folder
   to generate a make file that make/gcc can process.

2. Run "make", and adviemulator will be built.

3. The binary is located in the folder "bin", so go to bin via "cd bin".

4. Prepare for deployment by adding the QT libs to the executable package
   (otherwise your package will not run on Macs that don't have QT installed):
   
   Run "sudo macdeployqt adviemulator.app -dmg"
   
   You will be promted to enter your administrator password.
   
5. "adviemulator.dmg" will contain the app that you can run and distribute
   on every Mac, not only on yours.

   Warning: I am not sure, if the gcc C++ library is present on any Mac.
   If you want to be sure, then use XCode to compile, since the XCode C++
   libraries are according to my tests present on any Mac.
   
6. So you should delete the raw "adviemulator.app", e.g. by entering
   "rm adviemulator.app" in the terminal, since only the .dmg file should
   be shared.
    
7. You may want to clean up by entering

   "make clean"
   "rm Makefile"
   
   
XCode:

1. Use the terminal and run "qmake -spec macx-xcode" in the adviemulator
   folder. The XCode project file "adviemulator.xcodeproj" and other OSX
   specific files will be generated.

2. Open "adviemulator.xcodeproj" in XCode.

3. In the navigation tree on the left side, click "adviemulator", and then
   select the target "adviemulator" in the "Targets" list, that appears
   on the right
   
4. Select the "Summary" tab and drag'n'drop the file "advi-osx.icns" from
   the folder "res" to the "App Icon" drop area. Answer questions with yes
   and finish the wizard.
   
   Enter "org.m-e-g-a.adviemulator" as "Identifyer" and select meaningful
   values for "Version" and "Deployment Target".
   
5. Select the "Build Settings" tab.

   In the "Architectures" section, select "64-bit Intel", a meaningful
   "Base SDK" that is corresponding to the "Deployment Target" you chose
   in step (4) and remove "i386" from "Valid Architectures".
   
   In the "Linking" section select "Dead Code Stripping" = yes.
   
   In the "... - Code Generation" (... depends on XCode Version), select
   "Optimization Level / Release" = Fastest [-O3]
   
6. Head to XCode's menu bar "Product / Edit Scheme", select "Release"
   and close the scheme editor window with "OK".
   
7. Head to XCode's menu bar "Product / Clean".

8. Head to XCode's menu bar "Product / Build For / Running"

9. Head to the navigation tree on the left, open the "Products" folder.

   Right-click "adviemulator.app" and choose "Show in Finder". Drag the
   raw "adviemulator.app" file to your desktop. Ignore XCodes warnings after
   you dragged the file away and close XCode.
   
10. Open the terminal and enter "cd ~/Desktop/".

11. Prepare for deployment by adding the QT libs to the executable package
    (otherwise your package will not run on Macs that don't have QT installed):
   
    Run "sudo macdeployqt adviemulator.app -dmg"
   
    You will be promted to enter your administrator password
   
11. "adviemulator.dmg" will contain the app that you can run and distribute
    on every Mac, not only on yours. So you should delete the raw
    "adviemulator.app", e.g. by entering "sudo rm -r adviemulator.app/" in the
    terminal that is still pointing to the desktop.
    
12. You may want to clean up by using the terminal to head back to your
	adviemulator home folder and by entering:

	"rm -r moc* ui* adviemulator.xcodeproj *.plist advi-osx.icns *.cpp"


Linux:
======

You need g++ from the Gnu Compiler Collection.

Hint: If you'd like to build QT 4.8 by yourself, make sure that the following
dependencies (libraries) are installed before attempting to do so:

    libfontconfig1-dev
    libfreetype6-dev
    libx11-dev
    libxcursor-dev
    libxext-dev
    libxfixes-dev
    libxft-dev
    libxi-dev
    libxrandr-dev
    libxrender-dev
    libasound2‑dev
    
It is highly recommended to activate the ALSA sound system and to deactivate
all other legacy sound systems.

1. Run "qmake" without command line parameters in the adviemulator folder
   to generate a make file that make/gcc can process. (If qmake is not in
   your path and if you use the standard installation, then this you might want
   to try this: "/usr/local/Trolltech/Qt-4.8.4/bin/qmake" or something similar.)

2. Run "make", and adviemulator will be built.

3. The binary is located in the folder "bin", so go to bin via "cd bin".

4. You may want to clean up by heading to your adviemulator folder and
   running "make clean" and after that "rm Makefile"

WARNING: For really being able to distribute your build, you need to do a
static build (i.e. also have a statically built QT) or ship the QT libraries
or tell your users how to install the runtime.


written by sy2002, May 20, 2013
