When I first started to use cc65 in the past, one issue was that compiling everything by hand was not very productive and creating a make file for your project was a must. My first makefiles where mostly a list of files that I wanted to compile, which is quite primitive. This required to update the makefile every time you wanted to add a new file to the project.
I have been inactive on those projects for easily 8~10 years and now that I'm working back on some new ones (kids are getting old enough ^^;;), my first issue is that I had to find a way to recompile the C runtime when required. For this, I did some research on how to compile everything in my folder without the need to write files one by one.
At first I was doing it mostly for the runtime but I then decided to make it easier for my source files and data too. This simplified how to manage my files and the way I define my include in my C files too.
Since I'm no expert in make file and did some research on my current needs, there is good chance that some way that I'm doing things may not be adequate. My goal is to have feedback regarding:
- where there could be errors or improper use so I can learn more on the subject
- see how hard is it to use since I think this file could actually help beginners using cc65 projects in C
The archive contains:
- famitone
- neslib
- all the files for the C runtime for version 2.17
- a modified example1.c from Shiru cc65 examples
If should compile without issues if you have 2.17 installed. If you use a different version, you can specify in the makefile the path of your libsrc and it will compile automatically. You just need to update LIBSRC_DIR.
How the folders are structured:
- libs is the folder wich contain libraries. You can add your own too. for now only famitone and neslib.
- src is where you put your source files. It can be either C or S files
- data is where you put your data in c/s/bin files. Technically you could put them in src file too but it's up to you how you want to structure your project.
There is no limit for src/data for sub-directory: it will search for your files and make the proper list. Same things for the includes, if a folder is found, it will create an include path and automatically add it in your includes: no need to have relative path in your C #include or the one in S files anymore. I saw that often in a few examples and it made it difficult to move files around so I decided to make it automated.
I may need to explain more details about the file later if people start using it. I think that it could be used for a pure assembly project too but I didn't try it yet. In that case the runtime part would be unnecessary. Maybe a flag could disable that part in that case or I could guess based on all files extension but that maybe overdoing it.
Common command with the make file:
all -> build both runtime and application
runtime -> build runtime only
run -> run your app with fceux (needs to be in your path)
debug -> start an emulator with debugging capability with your app
clean -> remove only the build folder of the app
clean-runtime -> remove only runtime build folder
clean-both -> remove both runtime build folder and app build folder
Debug right now launch nin.sh, which was as shell script for nintendulator while I was using it on linux and mac. It will require to be updated to your own needs.
My goal was first to make something useful for myself but since I saw a new question about the same issue I had then I decided to check how to make it easy for someone that may not know yet about makefile and cc65, remove that burden and that person could focus on learning the nes innards and the C code only.
It feels great to post on nesdev again and I hope this file will be useful for beginners. I think it should be useful too for people that had issues with the provided runtime in Shiru examples that is now not compatible with the latest version.
I think is all of Shiru's example that motivated me to make that makefile. Those examples helped me figure out where to look and how to do things so I'm grateful that Shiru shared them. Now I feel that sharing what I made from that is the least I can do.
I have been inactive on those projects for easily 8~10 years and now that I'm working back on some new ones (kids are getting old enough ^^;;), my first issue is that I had to find a way to recompile the C runtime when required. For this, I did some research on how to compile everything in my folder without the need to write files one by one.
At first I was doing it mostly for the runtime but I then decided to make it easier for my source files and data too. This simplified how to manage my files and the way I define my include in my C files too.
Since I'm no expert in make file and did some research on my current needs, there is good chance that some way that I'm doing things may not be adequate. My goal is to have feedback regarding:
- where there could be errors or improper use so I can learn more on the subject
- see how hard is it to use since I think this file could actually help beginners using cc65 projects in C
The archive contains:
- famitone
- neslib
- all the files for the C runtime for version 2.17
- a modified example1.c from Shiru cc65 examples
If should compile without issues if you have 2.17 installed. If you use a different version, you can specify in the makefile the path of your libsrc and it will compile automatically. You just need to update LIBSRC_DIR.
How the folders are structured:
- libs is the folder wich contain libraries. You can add your own too. for now only famitone and neslib.
- src is where you put your source files. It can be either C or S files
- data is where you put your data in c/s/bin files. Technically you could put them in src file too but it's up to you how you want to structure your project.
There is no limit for src/data for sub-directory: it will search for your files and make the proper list. Same things for the includes, if a folder is found, it will create an include path and automatically add it in your includes: no need to have relative path in your C #include or the one in S files anymore. I saw that often in a few examples and it made it difficult to move files around so I decided to make it automated.
I may need to explain more details about the file later if people start using it. I think that it could be used for a pure assembly project too but I didn't try it yet. In that case the runtime part would be unnecessary. Maybe a flag could disable that part in that case or I could guess based on all files extension but that maybe overdoing it.
Common command with the make file:
all -> build both runtime and application
runtime -> build runtime only
run -> run your app with fceux (needs to be in your path)
debug -> start an emulator with debugging capability with your app
clean -> remove only the build folder of the app
clean-runtime -> remove only runtime build folder
clean-both -> remove both runtime build folder and app build folder
Debug right now launch nin.sh, which was as shell script for nintendulator while I was using it on linux and mac. It will require to be updated to your own needs.
My goal was first to make something useful for myself but since I saw a new question about the same issue I had then I decided to check how to make it easy for someone that may not know yet about makefile and cc65, remove that burden and that person could focus on learning the nes innards and the C code only.
It feels great to post on nesdev again and I hope this file will be useful for beginners. I think it should be useful too for people that had issues with the provided runtime in Shiru examples that is now not compatible with the latest version.
I think is all of Shiru's example that motivated me to make that makefile. Those examples helped me figure out where to look and how to do things so I'm grateful that Shiru shared them. Now I feel that sharing what I made from that is the least I can do.