Harry Potter and the Half-Blood Prince is another work whose source code is entirely available for public view, yet it's definitely under copyright and you will get in big trouble for commercially copying it.
Making it public and releasing it from copyright are two separate things.
In order to clone the IBM BIOS, they had to write totally new software that did the same things, but prove in court that the writers of this software did not lift or copy any part of the original.
This process is covered in detail in the first few episodes of Halt and Catch FireHalt and Catch Fire.