I do not know about Portugal. But in Brazil, software while ownership is governed by intellectual property legislation. It is different from the United States, for example, where software is governed by patent law.
Your case is governed by a law for computer programs, at 9609 .
Article four says, and I put emphasis on the relevant parts:
Art. 4º Unless otherwise stipulated , the rights relating to the computer program, developed and developed during the term of the contract or of the contract, will belong exclusively to the employer, contractor of services or public agency. statutory link, expressly intended for research and development, or in which the activity of the employee, contracted service or server is anticipated, or also derives from the very nature of the charges concerning such links. p>
That is, if you do not have a contract establishing your ownership of the developed software, the software is the one that hired you to do so.
If you make software that is not for a client - a "shelf" program, or a website of yours, then it's worth the lei 9610 , the copyright law itself. It states that in these cases the property is exclusive to the author.
I saw a recent issue of the question . The following question was added: What if I make changes to the code? If the code is your property, or if it is a modification made for your client because he asked for it, there are no problems. Otherwise you have committed a crime, even if your modifications are not executed on the machines of the holder of the rights to the code. This is a part in which I believe that all the laws of the West agree: changes to a code that you do not own is a form of piracy.