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 > linkscript, crt0 and other things that frighten newbies

#17143 - teezeCrost - Tue Mar 02, 2004 10:07 am

hey everyone. Just trying to hammer down a few concepts here. I think I'm getting ahead of myself, but can someone give me a brief rundown on what the following mak file snippet does?

Code:

# -------------------------------------------
# Define the flags for the compilers;
# -------------------------------------------
CFLAGS  = -I $(INCDIR2) -I $(INCDIR) -I $(SRCDIR) -mthumb-interwork -c -g -O2 -Wall -fverbose-asm
SFLAGS  = -I $(INCDIR2) -I $(INCDIR) -mthumb-interwork
LDFLAGS = -L $(LIBDIR) -L $(LIBDIR2) -T LinkScript


also, what is linkscript and crt0.o? (in laymen's terms)

what determines what gets listed with the .o files in the mak file?

Lastly, what are thumb and arm? I probably don't need to worry about them yet, but it'd be nice to know.

Thanks to anyone who can toss me a clue!
_________________
If you think you think outside the box, you're trapped in one.
-teezeCrost

#17146 - Cearn - Tue Mar 02, 2004 10:57 am

teezeCrost wrote:

I'm assuming you are using DevKit advance here. If not plz say so.
Code:

# -------------------------------------------
# Define the flags for the compilers;
# -------------------------------------------
CFLAGS  = -I $(INCDIR2) -I $(INCDIR) -I $(SRCDIR) -mthumb-interwork -c -g -O2 -Wall -fverbose-asm
SFLAGS  = -I $(INCDIR2) -I $(INCDIR) -mthumb-interwork
LDFLAGS = -L $(LIBDIR) -L $(LIBDIR2) -T LinkScript



CFLAGS: options for the compiler (gcc)
SFLAGS: options for the assembler (as)
LDFLAGS: options for the linker (ld)

You can find out what all the flags mean in the manuals at www.gnu.org. Or you could them in CHM format from http://htmlhelp.berlios.de/books/chm.php. These should be of great help figuring out what you can do with the different GNU tools.
If you want some info on the flags right now: "-I" sets the search paths for include files; "-c" tells the compiler to compile only; "-L" sets the search paths for libraries (.a files); these should suffice for simple things.
Quote:
also, what is linkscript and crt0.o? (in laymen's terms)

See the devrs FAQ http://www.devrs.com/gba/files/gbadevfaqs.php. They concern initialization stuff and where all your code goes. crt0.S (which is assembled to crt0.o) also sets-up the interrupt handler (but you can also write one yourself).
Quote:

what determines what gets listed with the .o files in the mak file?

That can be kinda complicated and also depends on which which make you're using (GNU make or MSVC's NMAKE for example). You can find lots of mak file examples on this forum or the gbadev demos. Study them to see how they work. I could give you one of mine and explain how that works if you want.
Quote:

Lastly, what are thumb and arm? I probably don't need to worry about them yet, but it'd be nice to know.

Again, see the forum faq or the devrs faq. The ARM CPU has two instruction sets: one with 32bit instructions (arm) and one with 16bit instructions (thumb). There are several topics throughout the forum on this subject.
Yes, I know this all a bit brief, but I hope it'll give you some idea of what these things are about.

#17183 - teezeCrost - Wed Mar 03, 2004 1:08 am

that gives me a good start. Thanks for taking the time!
so are those flags all the flags that exist, or just the ones to be used when you hit build?
thanks again.
_________________
If you think you think outside the box, you're trapped in one.
-teezeCrost

#17192 - Cearn - Wed Mar 03, 2004 10:14 am

The latter. The total number of flags is huge. For a complete list, check out the documentation links I gave you. You can also get a summary of the available flags by using something like
Code:

[command] --help > [file]

in the command line. This will dump a list of flags of [command] into [file]. Getting the real docs is better though.