ATTENTION: This guide is out of date as of 2016. The gr-fosphor site has an install guide now:
  http://sdr.osmocom.org/trac/wiki/fosphor

  If you still want to follow this document exactly it'll install OpenCl 1.2.
  Modern gr-fosphor requires OpenCl 2.0. Below is the last OpenCl commit of gr-fosphor:
  https://github.com/osmocom/gr-fosphor/tree/b17258f1fc4ccc7859839a048916c8ad355c1e4c
  Use it instead of the latest gr-fosphor.

  But really this is only for people that already have OpenCl 1.2 installed who upgraded GNU Radio
  and now need to recompile gr-fosphor without the hassle of messing with new graphics drivers.

_________________________________________________________________________________________________

How to prepare for and install gr-fosphor (for gnuradio 3.7.x) under Ubuntu 12.04 w/AMD graphics.

Step 0. Get AMD driver 13.4 installed.
	$ sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev* xorg-driver-fglrx
	# *restart* then download the drivers and unpack the .zip
	$ chmod +x amd-driver-installer-catalyst-13-4-x86.x86_64.run
	$ sudo ./amd-driver-installer-catalyst-13-4-x86.x86_64.run
	# Make a package for a distribution, select Ubuntu/precise at the bottom, make packages.
	$ sudo dpkg -i fglrx*.deb
	# *restart*

Step 1. Get the AMD APP SDK installed (2.8.1.0). Unpack it, cd in, run their installer.
	# http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/downloads/
	$ sudo ./Install-AMD-APP.sh
	# etc, etc

Step 1.5. Export some paths in your ~/.bashrc file (this assumes you are using python 2.7, etc)
	export PYTHONPATH=/usr/local/lib/python2.7/dist-packages
	export LD_LIBRARY_PATH=/usr/lib/fglrx

Step 2. Get glfw3 (http://www.glfw.org/download.html) compile from source. 
	# grab some dependencies
	$ sudo apt-get install libxrandr-dev x11proto-xf86vidmode-dev xorg-dev libglu1-mesa-dev cmake
	# unzip glfw-3, cd to the dir, make sure to enable shared libs by using the following cmake line,
	$ cmake ../ -DBUILD_SHARED_LIBS=true
	# build a debian package
	$ sudo checkinstall -D --install=no --fstrans=no
	# accept the defaults, this results in a .deb, install it.
	$ sudo dpkg -i glfw_3.0.3-1_amd64.deb
	$ sudo ldconfig

Step 3. Reload bashrc to get exported lib paths, then get gr-fosphor and compile it.
	$ source ~/.bashrc
	$ git clone git://git.osmocom.org/gr-fosphor
	# cd into ./gr-fosphor/
	$ mkdir build
	$ cd build/
	$ cmake ../
	$ make
	$ sudo make install
	$ sudo ldconfig

	# with the gnuradio block installed make the benchmark program too,
	$ cd ../lib/fosphor/
	$ make

Step 4. Test it!
	
	# Open gnuradio-companion from a terminal where you have export LD_LIBRARY_PATH=/usr/lib/fglrx set.
	$ export LD_LIBRARY_PATH=/usr/lib/fglrx
	# I made a bare-bones flowgraph for testing gr-fosphor, grab it:
	$ wget http://superkuh.com/fosphor-cfile.grc
	$ gnuradio-companion fosphor-cfile.grc
	# Enable or disable blocks by selecting and pressing "e". To save the .cfile enable the sink.

	# (alternately, test using "$ osmocom_fft -F". Make sure to set the sample rate from 250K to 2.4M !)

	# If you've made a .cfile with the provided flowgraph then run a benchmark with it.
	# Save about 500 MB worth of data. Run the benchmark program, "main" with the data,
	$ ./main /tmp/test.cfile

	# If you get,
	$ ./main /tmp/test.cfile
	[+] Selected device: Pitcairn
	XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
 	     after 28 requests (28 known processed) with 0 events remaining.
	# then you didn't export LD_LIBRARY_PATH=/usr/lib/fglrx correctly.
	# Did you launch gnuradio-companion from a terminal? Or a GUI? Try launching from a terminal.

	# If you get,
	$ ./main /tmp/test.cfile
	 [+] Selected device: Pitcairn
	X Error of failed request:  BadMatch (invalid parameter attributes)
	  Major opcode of failed request:  137 (GLX)
 	 Minor opcode of failed request:  5 (X_GLXMakeCurrent)
	  Serial number of failed request:  28
 	 Current serial number in output stream:  28
	# It probably means you aren't using AMD drivers 13.4. Did you try 13.11 beta6? Try 13.4.

	# If it works you'll get something like,

$ ./main /tmp/test.cfile
[+] Selected device: Pitcairn
100 Frames time: 505682 us
BW estimated: 103.679392 Msps
100 Frames time: 484577 us
BW estimated: 108.194984 Msps
100 Frames time: 483198 us
BW estimated: 108.503760 Msps
100 Frames time: 465448 us
BW estimated: 112.641584 Msps
100 Frames time: 466639 us
BW estimated: 112.354088 Msps
100 Frames time: 463925 us
BW estimated: 113.011368 Msps
100 Frames time: 465166 us
BW estimated: 112.709864 Msps
100 Frames time: 469323 us
BW estimated: 111.711552 Msps
100 Frames time: 465432 us
BW estimated: 112.645464 Msps
100 Frames time: 469404 us
BW estimated: 111.692272 Msps
100 Frames time: 471110 us
BW estimated: 111.287808 Msps
100 Frames time: 461735 us
BW estimated: 113.547376 Msps
100 Frames time: 465661 us
BW estimated: 112.590064 Msps
100 Frames time: 460798 us
BW estimated: 113.778272 Msps
100 Frames time: 462250 us
BW estimated: 113.420880 Msps
100 Frames time: 457200 us
BW estimated: 114.673664 Msps
100 Frames time: 466606 us
BW estimated: 112.362032 Msps
100 Frames time: 464735 us
BW estimated: 112.814400 Msps
100 Frames time: 467993 us
BW estimated: 112.029024 Msps
100 Frames time: 469840 us
BW estimated: 111.588632 Msps
100 Frames time: 461097 us
BW estimated: 113.704488 Msps
100 Frames time: 473736 us
BW estimated: 110.670928 Msps
100 Frames time: 472457 us
BW estimated: 110.970528 Msps
100 Frames time: 458962 us
BW estimated: 114.233416 Msps
100 Frames time: 466148 us
BW estimated: 112.472432 Msps
100 Frames time: 462190 us
BW estimated: 113.435600 Msps
100 Frames time: 461185 us
BW estimated: 113.682792 Msps
100 Frames time: 461815 us
BW estimated: 113.527712 Msps
100 Frames time: 444433 us
BW estimated: 117.967832 Msps
100 Frames time: 456770 us
BW estimated: 114.781616 Msps
100 Frames time: 460278 us
BW estimated: 113.906816 Msps
100 Frames time: 461796 us
BW estimated: 113.532384 Msps
100 Frames time: 469714 us
BW estimated: 111.618560 Msps
100 Frames time: 459799 us
BW estimated: 114.025472 Msps
100 Frames time: 459052 us
BW estimated: 114.211024 Msps
100 Frames time: 452165 us
BW estimated: 115.950592 Msps
100 Frames time: 466770 us
BW estimated: 112.322552 Msps
100 Frames time: 466786 us
BW estimated: 112.318712 Msps
100 Frames time: 455742 us
BW estimated: 115.040528 Msps
100 Frames time: 466987 us
BW estimated: 112.270360 Msps
100 Frames time: 462783 us
BW estimated: 113.290248 Msps
100 Frames time: 472741 us
BW estimated: 110.903856 Msps
100 Frames time: 476130 us
BW estimated: 110.114472 Msps
100 Frames time: 461636 us
BW estimated: 113.571736 Msps
100 Frames time: 469912 us
BW estimated: 111.571528 Msps
100 Frames time: 471704 us
BW estimated: 111.147664 Msps
100 Frames time: 470293 us
BW estimated: 111.481136 Msps
100 Frames time: 473220 us
BW estimated: 110.791592 Msps
100 Frames time: 449603 us
BW estimated: 116.611328 Msps
100 Frames time: 466404 us
BW estimated: 112.410696 Msps
100 Frames time: 465220 us
BW estimated: 112.696784 Msps
100 Frames time: 461345 us
BW estimated: 113.643368 Msps
100 Frames time: 475629 us
BW estimated: 110.230448 Msps
100 Frames time: 452052 us
BW estimated: 115.979576 Msps
100 Frames time: 463412 us
BW estimated: 113.136472 Msps
100 Frames time: 494160 us
BW estimated: 106.096808 Msps
100 Frames time: 468219 us
BW estimated: 111.974952 Msps
100 Frames time: 467245 us
BW estimated: 112.208368 Msps
100 Frames time: 458931 us
BW estimated: 114.241136 Msps
100 Frames time: 456676 us
BW estimated: 114.805248 Msps
100 Frames time: 460067 us
BW estimated: 113.959056 Msps
100 Frames time: 465122 us
BW estimated: 112.720528 Msps
100 Frames time: 470439 us
BW estimated: 111.446536 Msps
100 Frames time: 446834 us
BW estimated: 117.333960 Msps
100 Frames time: 466725 us
BW estimated: 112.333384 Msps
100 Frames time: 464439 us
BW estimated: 112.886296 Msps
100 Frames time: 466052 us
BW estimated: 112.495600 Msps