dirname "$0"
gets the directory name of file containing the command.
"`dirname "$0"`"/../../waf
appends /../../waf
to the result obtained by dirname "$0"
.
So it you obtained /some/arbitray/path
from the previous command, this would return /some/arbitray/path/../../waf
exec "`dirname "$0"`"/../../waf "$@"
replaces the shell with the command obtained above and passes the arguments that were passed to the script containing the original command.
As an example, if your command was in a file contained in a directory /d1/d2/d3/d4/d5
and you executed it by saying:
sh myfile foo bar "foo bar"
then the command being executed would be:
/d1/d2/d3/d4/d5/../../waf foo bar "foo bar"