# build radiance with pmap patches
# andreas noback 2024-03-17

# this radiance version is needed to replicate the results
# the patches (pmapPatch-20190302.patch) are provided by Lars O. Grobe 
# and suitable to a unique radiance version (around March 5th 2019)
# of the 5.3 development which is conserved here (radiance-HEAD.tgz)

# the Hagia Sophia model is published seperatly

# on debian you have the following dependencies:
sudo apt-get install ed git build-essential libx11-dev

# install into /usr/local/radiance
sudo mkdir /usr/local/radiance
sudo chmod go+w /usr/local/radiance

# extract radiance files
tar xzf radiance-HEAD.tgz

# get the supplemental files and extract them
# the tar file is based on the "ray" directory structure and includes libs, cal-files etc. and libtiff
wget https://www.radiance-online.org/download-install/radiance-source-code/archived-releases/radiance-5.2/rad5R2supp.tar.gz
tar xzf rad5R2supp.tar.gz

# apply the pmap patches
patch --directory=ray/  --strip=1 < pmapPatch-20190302.patch

cd ray
./makeall install
# set bin and lib path to /usr/local/radiance/bin /usr/local/radiance/lib
# optional: set -Ofast -march=native

# optional: copy man pages
mkdir /usr/local/radiance/man
cp -r doc/man/man* /usr/local/radiance/man/.

# set secure owner and permissions and set link (chose user+group as suitable for your system)
sudo mv /usr/local/radiance /usr/local/radiance-pmap_patch
sudo chmod -R go-w /usr/local/radiance-pmap_patch
sudo chown -R root:staff /usr/local/radiance-pmap_patch
sudo ln -s /usr/local/radiance-radiance-pmap_patch /usr/local/radiance

# get dxf2rad
wget ftp://ftp.schorsch.com/dxf2rad/dxf2rad_1.1_linux64.tar.bz
tar xjf dxf2rad_1.1_linux64.tar.bz
mkdir /usr/local/dxf2rad
cp dxf2rad_1.1_linux64/dxf2rad /usr/local/dxf2rad/dxf2rad

# add to ~/.bashrc
---
export EDITOR=vim

#radiance config
export RAYPATH=/usr/local/radiance/lib:./:./mat:./sky:./scene:./light
export PATH=$PATH:/usr/local/radiance/bin:/usr/local/dxf2rad
export MANPATH=$MANPATH:/usr/local/radiance/man
---
