make launcher suitable for mac environment

readlink -f doesn't work on mac, so i used code salvaged from the internets to simulate the functionality on mac