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 > Setting up devkitarm, osx Makefile

#48396 - justinGBA - Tue Jul 19, 2005 7:57 pm

I am stuck and i do not understand the layout of the makefile..

For reference, this one looks nice...

Code:

# === Project details (add your own stuff here) ===
PROJ? ? := foo

INCLUDE? :=
LIBPATHS :=

LIBS? ? :=
COBJS? ?:= $(PROJ).o
SOBJS? ?:=
OBJS? ? := $(COBJS) $(SOBJS)

# --- boot type ---
MB = 0
ifeq ($(MB),1)
EXT? ? ?:= mb.gba
SPECS? ?:= -specs=gba_mb.specs
else
EXT? ? ?:= gba
SPECS? ?:= -specs=gba.specs
endif

# --- Compiling ---
CROSS:= arm-elf-
AS= $(CROSS)as
CC= $(CROSS)gcc
LD= $(CROSS)gcc
OBJCOPY= $(CROSS)objcopy

MODEL? ?:= -mthumb-interwork -mthumb
CBASE? ?:= $(INCLUDE) -O2 -Wall -mthumb-interwork

ASFLAGS := -mthumb-interwork
CFLAGS? := $(CBASE) -mthumb
LDFLAGS := $(SPECS) $(MODEL) $(LIBPATHS) $(LIBS)? -Wl,-Map,$(PROJ).map

# === Building steps ===
build: $(PROJ).$(EXT)

# --- convert to binary ---
$(PROJ).$(EXT) : $(PROJ).elf
? ?@$(OBJCOPY) -v -O binary $< $@
? ?-@gbafix $@

# --- link ---
$(PROJ).elf : $(OBJS)
? ?$(LD) $(OBJS) $(LDFLAGS) -o $@

# --- compile ---
$(COBJS) : %.o : %.c
? ?$(CC) $(CFLAGS) -c $< -o $@

# === Clean ===
.PHONY : clean
clean :
? ?@rm -fv $(OBJS)
? ?@rm -fv $(PROJ).$(EXT)
? ?@rm -fv $(PROJ).elf

#EOF


now all my devkit arm stuff is in...

/Developer/GameBoy\ Advance/devkitARM
/Developer/GameBoy\ Advance/libgba

how do i let the make file know where the tools are so it builds?

sorry im new to unix style programming

TIA

#51051 - pizzach - Mon Aug 15, 2005 10:29 pm

Hoookay. I'm going to do some guesses here. Hopefully the gba gods don't get mad at me. But maybe they'll supply a bit if help if I'm wrong.

I'm not seeing any thing for path. So I would try putting it in before the "arm-elf-" in the "CROSS:= arm-elf-".

So it would turn into
CROSS:= /Developer/GameBoy\ Advance/devkitARM/bin/arm-elf-

Notice that I added the bin directory.

Basically anytime you see $(CROSS) it is replaced with whater the closs variable is when the make file in run. (Don't know how obvious that was or if I phrased it right.)


as is the gba assembler aka arm-elf-as
Um...haven't used it yet.

gcc is the gba compiler aka arm-elf-gcc

File conversion thingies it does:
filename.c--->filename.o
filename.o and other files--->filename.elf

objcopy um....pulls the stuff together into the final product. aka arm-elf-objcopy
file conversion thingies it does:
filename.elf--->filename.gba which is useable in an emulator.

#51065 - tepples - Tue Aug 16, 2005 12:56 am

'as' is the assembler; it turns .s files into .o files. But in general, it's better to call 'gcc' directly even for .s files unless you have a good reason not to. For one thing, 'gcc' can run the C preprocessor on input files, letting you use #define style macros within assembly language files.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.