Question

When I am using some code licensed with the MIT license, but it's not in seperate files, is it OK mark it like this?

/* Here starts code licensed under the MIT License (../MIT.txt) */
// code
/* Here is the end of code licensed under the MIT License (../MIT.txt) */

Where in ../MIT.txt file, it would contain the MIT License text and the original author's copyright notices.

Also, when most of code is MIT licensed and I'm only changing some sections of the functions can I mark those parts with the same method as above but with my own license? Yes, it's going to be a lot of kilobytes of comments.

Was it helpful?

Solution

When you use MIT-licensed code in a non-MIT-licensed project, simply marking the MIT-licensed parts of the source code is not a good strategy. The license allows you to do just about anything with the code – including sublicensing the code –, under this one restriction:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Note that the MIT license should also be displayed to the end user of your software. Where you display your copyright to the user, you should also add something like

This program includes code from the FooBar library, used under the following license:

The "FooBar" library  
Copyright (c) <year> <copyright holders>

<license body>

In addition, you might want to explicitly mark the sections in the code that were taken from an MIT-licensed source. From my understanding, this is not required, but it would be ethical.

When you modify an MIT-licensed source, you should not mark your contributions with a separate license, because this requires an user of the source to follow both the original license and your license. Instead, choose one of the following options:

  • License your contributions under the same license as the rest of the code. You can edit the copyright notice to reflect that you contributed to the source, without marking what exactly you changed.
  • Re-license the MIT-licensed source under your license, in a manner permitted by the MIT license. See above.

Notes:

  • I'm a programmer, not a lawyer.
  • The term “MIT license” is fairly ambiguous. This answer assumes the Expat License, but is also applicable to the X11 License.

OTHER TIPS

That's insane. DON'T DO THAT.

If you are working in some one else's code that has an MIT license, then your changes should have the MIT license. If you can't for some reason use the same license as the rest of the project, then you shouldn't be fooling with it. If you have an ethical or whatever disagreement with the licensing of a project, then DON'T WORK ON THAT PROJECT.

It is TOTALLY unreasonable for you to place a veritable copyright compliance minefield throughout each source file. It's NOT reasonable for you to expect users of the code to review every line of every source file in order to determine what the licensing of the thing is.

If you simply MUST do things differently, then pull your code out to separate files, so that someone evaluating the code for their use would have a CHANCE of knowing what license the code was under.

Also: If it came down to a courtroom, I'm unclear how your shenanigans would fare. An unobservant person could legitimately claim to have not noticed your bits being licensed differently, and an unscrupulous one could potentially use the confusion to do things you didn't intend.

If you wanted to do this (and you didn't care about the possible backlash) you should at the very least:

  • Add a license file, as you suggest.
  • Point out in the readme file very clearly that the code is licensed as "foo" (whatever the original license is) except where bracketed by "some special start string" and "some special end string" which is MIT licensed. These strings must be unique and never misspelled, so that users could conceivably remove them using a simple script if they don't want your code.

To avoid excessive backlash, you should probably also do this:

  • Provide the user with a link or script to get the code without your differently licensed changes.
  • Make sure the code works (or, at least, all tests pass) if your code is removed.
  • Put your code in separate files or wrap the original project (using for example a Git submodule) to guarantee that you're not modifying the original code.

The biggest issue with this is probably how your code would mesh with the rest of it. You can't modify even a single line of the original code and re-license it, so how are you going to do sane changes? For example, you can't statically link GPL code without changing your license to GPL. There are probably hosts of other issues with specific licenses, and you're very likely just creating problems for yourself and others. If you care about other users enough (assuming you're not selling the compiled project) to release your changes, why do you not care enough to use the original license?

A much simpler solution which has no guarantee of success is to calmly and reasonably explain to the original author(s) why you would like the software to use the MIT license, and whether they would be willing to dual license it.

Licensed under: CC-BY-SA with attribution
scroll top