It must be "crafted" at an animal pen (any animal pen) by feeding a fully grown pet. The pet will stop producing dung and other resources if it runs out of food.