gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Programmers Notepad 2

#70468 - Red XIII - Mon Feb 06, 2006 7:29 pm

Hi,I have this problem:

I use Programmers Notepad 2 coming with the DevkitPro.

Lets say for an example that I copy/paste the source code from "HelloWorld".

When I press Alt+1,shouldn't it create somewhere an .nds and an ds.gba file?

It showed this:

> "make"
"make": *** No targets specified and no makefile found. Stop.

> Process Exit Code: 2
> Time Taken: 00:01

I even tried a few things at the "Global Tools" in the options,but nothing happened.

My goal is to have the .nds and the ds.gba files created on my desktop,from any code I compile on my Programmers Notepad 2... What kind of edit to the "make" tool should I do?

Can anyone help with this newbie question?

EDIT: Thanks :D


Last edited by Red XIII on Mon Feb 06, 2006 10:02 pm; edited 1 time in total

#70479 - kusma - Mon Feb 06, 2006 8:53 pm

it sounds like you need to make yourself a makefile. a makefile usually contains actions to make various files from various inputs, like how to make an object file (..o) from a source file (.c/.cpp/.s...), how to make an .elf-file from a collection of object files, and/or how to make a rom file (.gba/.nds) from a .elf. the devkitpro examples contains some example makefiles, and the gnu make manual can be found at http://www.gnu.org/software/make/manual/make.html. writing your own makefiles are usually a bit akward at first, but once you get the hang of it, it's a really powerfull tool.

#70580 - Red XIII - Tue Feb 07, 2006 2:27 pm

This keeps getting harder and harder,but I won't give up.

My questions:

1)The "makefile" I need is a .bat,right? It can be created if I open the Notepad,write the actions that need to be made and save it somewhere (as make.bat),correct?

2)I'm hopeless,my head is gonna explode from all those tutorials I've read.The GNU make tutorial was ok,but I've read others more specified to DevkitARM.But I still need help. :/

3)I tried to edit the build.bat at Helloworld,but the only thing it wrote inside was
Code:
make clean
make
pause


Wtf? Isn't is supposed to be full of paths,.elf's,main.c's,like when I run it?

4)As I said before,my goal is to have the .nds and the ds.gba files created on my desktop,from any code I compile on my Programmers Notepad 2. Can anyone point me a few tips on what should my makefile contain?

I'll even post some paths:

F:\DSDevelopment\DevKitPro\devkitARM\bin
F:\DSDevelopment\DevKitPro\msys\bin

:(

#70607 - CyberSlag5k - Tue Feb 07, 2006 7:01 pm

From my understanding, makefiles and batch (.bat) files differ a little bit. Whereas a batch file will execute all of the commands in top-down order, a makefile will execute only those sets of commands which have out of date dependencies (beginning with the first set, often named "all").

Take a look at this thread, it may help you out.

Oh, and don't get discouraged. A lot of this may seem crazy, even a little backwards at time, but you'll get used to it. The best way is to just keep plowing through, one step at a time. It'll be second nature in no time.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#70612 - Red XIII - Tue Feb 07, 2006 7:49 pm

The sad thing is that till now 84 people have read this topic,but only 2 bothered to reply to some questions.

I have read ALL topics in forum.gbadev.org regarding the famous makefile,but to no result.I don't understand why is it so hard for an all-purpose makefile to come bundled with DevkitPro.Maybe I'll understand sometime.

Or maybe I'm an idiot.

The thing is that I know a little C++ coding,donloaded DevkitPro,PALib etc,full of joy,but I cannot start experimenting,cause a "makefile" jumps in the scene,and I dont know how to create it,Notepad,Command Line? etc. I'll try more,but the thing that bothers me is that less and less people feel generous enough to help others.

#70621 - wintermute - Tue Feb 07, 2006 8:49 pm

take a look at the examples bundled with devkitPro, assuming you installed them.

F:\DSDevelopment\examples\nds\templates\arm9

is set up for a single arm9 core which uses the default arm7 core from ndstool.

F:\DSDevelopment\examples\nds\templates\combined

is set up for a dual core application containing source for both processors.

Copy one of these folders and modify as appropriate for your project.

With the single core project all source files ( .c, .cpp) should be in the source folder ..../arm9/source. The makefile is designed so that include files (.h) are picked up from the include folder - ...../arm9/include - which you may need to create.

For the dual core project there is a top level makefile which calls the makefiles in the arm9 and arm7 folders. The makefiles there operate in the same way as the makefile for the single core project.

.bat files are unnecessary and should generally be avoided - they actually complicate the build process for multi source projects and cause problems with dependencies.

Placing your output files on the desktop should also be avoided. GNU tools are not particularly good at coping with spaces in paths and cluttering your desktop with random binaries doesn't really help organisation much.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#70650 - Red XIII - Wed Feb 08, 2006 12:28 am

Wintermute,please let's take this step by step.
Quote:
take a look at the examples bundled with devkitPro, assuming you installed them.

F:\DSDevelopment\examples\nds\templates\arm9

is set up for a single arm9 core which uses the default arm7 core from ndstool.

F:\DSDevelopment\examples\nds\templates\combined

is set up for a dual core application containing source for both processors.
Ok,I checked them out.

Quote:
Copy one of these folders
Did,copied to F:\combined
Quote:
and modify as appropriate for your project.
What modifications should I do in this case,considering the fact that my project is as simple as
Code:
#include <PA9.h>


int main(void)   {

   PA_Init();
   PA_InitVBL();
   
   PA_InitText(0,2);   

   PA_OutputSimpleText(0,0,0,"Makefile is so hard to understand");

   while(1)    { 
      PA_WaitForVBL();
   }
   
   return 0;
}

,and more importantly,where on should the mods be done?

Quote:
With the single core project all source files ( .c, .cpp) should be in the source folder ..../arm9/source. The makefile is designed so that include files (.h) are picked up from the include folder - ...../arm9/include - which you may need to create.
Whoa,hold on. A)You say that I should save in this case this code above and move it in ..../arm9/source , right? and B)I do need to create ...../arm9/include as it doen't exist,but what should be inside?

Quote:
For the dual core project there is a top level makefile which calls the makefiles in the arm9 and arm7 folders. The makefiles there operate in the same way as the makefile for the single core project.
Ok,got that.

Quote:
.bat files are unnecessary and should generally be avoided - they actually complicate the build process for multi source projects and cause problems with dependencies.
That's another problem,since Programmers Notetepad needs an executable file (.exe,.bat,.vbs...) to be assigned to the make tool,check it out yourself.Makefile is just a file,it's not executable,at least on my pc.

Quote:
Placing your output files on the desktop should also be avoided. GNU tools are not particularly good at coping with spaces in paths and cluttering your desktop with random binaries doesn't really help organisation much.
Ok,got that,I'll save somewhere else where there are no spaces.

Well?Plz?I'm in a good way,I guess,help me find the pure light XD

#70830 - CyberSlag5k - Thu Feb 09, 2006 12:48 am

Quote:

That's another problem,since Programmers Notetepad needs an executable file (.exe,.bat,.vbs...) to be assigned to the make tool,check it out yourself.Makefile is just a file,it's not executable,at least on my pc.


The makefile will contain the commands necessary to create your .gba file (which you will run on an emulator/cart/GBA).

How it works is like this. A batch file will execute commands one after another every time. So if your .bat file contained the following:

path=c:\devkitpro;
command1
command2

It would set the path to c:\devkit pro, run command1, and then run command2 in that order. Every single time you run that .bat file, it will do all 3 steps, whether they were necessary or not.

Makefiles, on the other hand, are a bit smarter. They are broken into rules (I believe they're called) that are dependant on specified files being up to date (as in each file has been modified at a time after that of each dependency).

Code:

all: first.gba

first.gba: first.elf
   arm-elf-objcopy -O binary first.elf first.gba

first.elf: main.c
   arm-elf-gcc -mthumb -mthumb-interwork -specs=gba_mb.specs -o first.elf main.c -lm


I've pretty much just pieced it together from examples I've found on the forums and whatnot, but it appears to work. Anyway, what's going on is it starts with the first rule "all" and checks its dependency. It is dependent on first.elf. First.elf is dependent on main.c. Now, if main.c has been updated AFTER first.elf has been updated, that bottom line is going to to be run. Now first.elf is up to date. Then we go up a step and we look at first.gba. It is obviously out of date as we just updated first.elf, so the arm-elf-objcopy line is run. Now we've made our way back to all and obviously there is nothing to be done there, so we're done.

That may be a bit off, but it's how I understand how Makefiles work. They allow you to only build what is necessary and nothing more. The one that I've included might work for you, if you're using the same version of devkitpro that I am, or it might not. It's up to you if you want to try it. As I said, I more or less put it together looking at some other examples, so I'm not sure if everything there is necessary (or even correct), but it meets my need and it looks pretty sensible. The bottom line is what links and compiles my code, it tells the compiler/linker that we're running in thumb mode but we might be switching between it and arm mode. The other command appares to convert the .elf to a binary format for our .gba file (though I'm just speculating there).

I hope your project is going better. I understand you are frustrated, but you also need to recognize that things aren't always easy and apparent. If you take your time, take things step by step, read the available materials, and ask questions when necessary, you will succeed. Also realize that there are many people here who are happy to help you, but you must remain respectful and patient. That help will be less forthcoming if you demand it or complain that it does not come swiftly enough.

Anyway, if things are still unclear, say so. I'm no master of Makefiles (which should be pretty obvious), but I'll do my best to at least get you to my level of understanding of their use and implementation.

EDIT:
Two things I left out. One, make sure that there is a tab (not spaces) before each command. Two, name your makefile either makefile or Makefile (no extension) and programmers notepad will recognize it. You can just modify it in notepad, though you may find yourself needing to establish the path that the commands may be found in. I just made a batch file that set the path and then calls the make command (which will automatically run on a file named m/Makefile if it is in your present directory).
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#70833 - sajiimori - Thu Feb 09, 2006 1:03 am

I think the FAQ has a link to a tutorial about makefiles.

Oh yeah, it was by me! Time flies. :)

#70845 - Red XIII - Thu Feb 09, 2006 1:53 am

Wellll...

Thanks for the replies,everyone!

I'm beginning to understand some really difficult stuff... And that's good.

Sorry about that "eager" part,it's just that I needed serious info,like even how to create a makefile,and I'm not talking about the contents,I'm talking about how to have the file created (solution=notepad) ,when 99% of the tutorials were about the contents... And I clearly couldn't find that 1%...

I'll lay back a few days and suck every info from every tutorials available...

I'll post sometime again,maybe when I'll be full with new questions :D

#70901 - wintermute - Thu Feb 09, 2006 1:08 pm

Red XIII wrote:
Wintermute,please let's take this step by step.
Quote:
take a look at the examples bundled with devkitPro, assuming you installed them.

F:\DSDevelopment\examples\nds\templates\arm9

is set up for a single arm9 core which uses the default arm7 core from ndstool.

F:\DSDevelopment\examples\nds\templates\combined

is set up for a dual core application containing source for both processors.
Ok,I checked them out.

Quote:
Copy one of these folders
Did,copied to F:\combined
Quote:
and modify as appropriate for your project.
What modifications should I do in this case,considering the fact that my project is as simple as
Code:
#include <PA9.h>


int main(void)   {

   PA_Init();
   PA_InitVBL();
   
   PA_InitText(0,2);   

   PA_OutputSimpleText(0,0,0,"Makefile is so hard to understand");

   while(1)    { 
      PA_WaitForVBL();
   }
   
   return 0;
}

,and more importantly,where on should the mods be done?


First open the .pnproj file and press ALT 1 or click Tools->make without modifying anything in the project. This should work if you haven't messed up the PN2 configuration when you fiddled with it earlier. You may need to revert any changes you made to the "Global Tools" see http://www.devkitpro.org/pn2.shtml for details of how it should be set up.

I was going to go into some detail about using PAlib with devkitPro but, having spent a couple of hours attempting to determine how their build systems are supposed to work, I'd advise staying away from it. I used their installer earlier and it crashed while doing some post install setup and none of the examples actually built so, while it may seem like an API library created to make things easier, it's obviously a non starter.

The WinDS devkit would seem to be a better bet if you want to get started on programming without learning too much about the complexities of the DS hardware. Look for it here -> http://s3.invisionfree.com/GBAWinS/index.php?act=site . At least their installer works.

Quote:

Quote:
With the single core project all source files ( .c, .cpp) should be in the source folder ..../arm9/source. The makefile is designed so that include files (.h) are picked up from the include folder - ...../arm9/include - which you may need to create.
Whoa,hold on. A)You say that I should save in this case this code above and move it in ..../arm9/source , right? and B)I do need to create ...../arm9/include as it doen't exist,but what should be inside?


header files for your project, if you're using any.


Quote:

Quote:
.bat files are unnecessary and should generally be avoided - they actually complicate the build process for multi source projects and cause problems with dependencies.
That's another problem,since Programmers Notetepad needs an executable file (.exe,.bat,.vbs...) to be assigned to the make tool,check it out yourself.Makefile is just a file,it's not executable,at least on my pc.


No, the Makefile is a script file which is processed by make. From your first post it looked like PN2 was already set up and working properly but couldn't find a Makefile to process. Either the Makefile was missing or you hadn't loaded a project file - this is the .pnproj file found in all the example directories.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#71022 - tepples - Fri Feb 10, 2006 1:00 am

The executable file to be "associated" with makefiles is make -f . Unfortunately, you can't associate dotless filenames (e.g. "makefile" or "GNUmakefile") to applications under Windows Explorer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.