build: improve libbsd dependency handling