Make linking legacy gadget conditional