Regarding the definition of "legal" as far as the law is concerned in the EU;
1. Regardless of HOW you enter the EU, your stay is "legal" from the moment you register yourself with authorities (in this case by means of application for asylum, refugee status or tolerated stay etc, and in normal cases by means of a passport control official at port of entry), until the moment a decision is made regarding your case.
If a decision is made allowing you to stay, then the length of your legal stay is extended. If a decision is made ordering you to leave, then your stay becomes illegal if the deadline of that decision is reached and you fail to leave or appeal against the decision (depending on the type of decision made, sometimes filing an appeal may or may not legalize your stay). Also, such decisions are not applicable to individuals that are incarcerated or undergoing medical treatment.
2. Even if you enter through "normal" channels (i.e. passport control official at regulated port of entry) and you outstay your permit to stay without registering accordingly with authorities, then your stay becomes illegal. If you register with authorities (by means of an application for visa or residence extension or for a work permit, but there are dozens of other possibilities) then your stay becomes legal until a decision is made. A positive decision legalizes an extended stay, while a negative decisions obligates you to either leave or appeal within a preset deadline. As I said above, depending on the type of decision made, sometimes filing an appeal may or may not legalize your stay. Also, such decisions are not applicable to individuals that are incarcerated or undergoing medical treatment.
What this means is, even if you come to Europe on a boat, your stay in the EU is legal from the moment your name is registered with coast guard (if rescued at sea) or from the moment you apply for asylum (or some other form of residence).
Also, due attention should be paid to this very common mistake. There are no illegal immigrants (legality does not pertain a person) but there are foreigners staying illegally (legality pertains to the stay).