Bulk surveillance?
Yes and no.
Depends which project you were talking about. Collecting the phone metadata was in fact legal and how they did it was very legal. Yes, its a bit of an irony. But the law was clear on the fact that the metadata is not considered personal and private data. Meaning there is no expectation of privacy. However this is a case where you can take two public data sets and then create some form of private/restricted data. If you paid attention, the NSA didn't join the metadata data sets en masse to other data sets.
There's more, but most here would not try to understand it.