add libdirs, refactor link recipe