#27703 - tomer - Tue Oct 19, 2004 7:26 pm
this is my MakeFile:
CFLAGS = -c -O2
THUMBMODEL = -mthumb -mthumb-interwork
LIST = main.o screen.o
CC= D:\GBA\DEVKIT\bin\gcc.exe
all: myRom.gba
myRom.gba: myRom.elf
objcopy -O binary myRom.elf myRom.gba
myRom.elf: $(LIST)$(CC) -o myRom.elf $(LIST)
$(LIST): %.o: %.c $(CC)$(CFLAGS) $(THUMBMODEL) $<
and this is the output:
-"No rule to make target '-c', needed by main.o. STOP"
what does it mean? and how is it fixed?
Plus, does it support IWRAM? and what flags should I use for speed?
Cheers,Tomer
#27704 - sajiimori - Tue Oct 19, 2004 7:52 pm
Make is line-oriented, so you can't put the body of a make rule on the same line. Put the prerequisites to the right of the colon and the body on the following line(s). The error comes from the fact that your list of prerequisites includes "-c", so it's trying to build that file and obviously failing to do so.
Make doesn't know anything about IWRAM or optimization -- it's just a build automation tool. Pass -O2 or -O3 to gcc for decent optimization, and search the forum for more info on putting things in different memory areas.
#27705 - tomer - Tue Oct 19, 2004 8:07 pm
what?
#27706 - sajiimori - Tue Oct 19, 2004 8:25 pm
Read a makefile tutorial to get up-to-speed on the vocabulary.
#27707 - poslundc - Tue Oct 19, 2004 8:34 pm
Best thread ever.
Dan.
Edit: I had just come from reading bash.org and for a moment wasn't sure if I'd left.
#27710 - tomer - Tue Oct 19, 2004 9:03 pm
Look!
I know how they work
i'm only trying to compile two fucjing files: main.c and screen.s
and I think that makefiles are complaining too much.
I used to use Visual HAM IDE. But, then I relized it uses only a debug
library, which probably makes things slower.
that's it. two files.
so if you wanna answer, then answer well pleaze.
Cheers, tomer
#27711 - Touchstone - Tue Oct 19, 2004 9:19 pm
You could argue if he answered your question well or not, but he answered it correctly anyways.
What he meant was that you can't have the commands that should be executed for a target on the same line as the target definition. Your makefile should look like this:
Code: |
myRom.elf: $(LIST)
$(CC) -o myRom.elf $(LIST)
%.o: %.c
$(CC) $(CFLAGS) $(THUMBMODEL) $<
|
And if the screen source is an assembler file you'd have to add a generic .o from .s target aswell.
_________________
You can't beat our meat
#27713 - tomer - Tue Oct 19, 2004 9:26 pm
ok
I am trying this code
Code: |
CFLAGS = -c -O2
THUMBMODEL = -mthumb -mthumb-interwork
CLIST = main.o
SLIST = crt0.o screen.o
CC = D:\GBA\DEVKIT\arm-agb-elf\bin\gcc
all: myRom.gba
myRom.gba: myRom.elf
objcopy -O binary myRom.elf myRom.gba
myRom.elf: $(CLIST)
$(CC) -o myRom.elf $(CLIST)
myRom.elf: $(SLIST)
$(CC) -o myRom.elf $(SLIST)
$(LIST): %.o: %.c
$(CC) $(CFLAGS) $(THUMBMODEL) $<
$(SLIST): %.o: %.s
|
the output says:
Code: |
makefile:17: warning: overriding commands for target `myRom.elf'
makefile:14: warning: ignoring old commands for target `myRom.elf'
D:\GBA\DEVKIT\arm-agb-elf\bin\gcc -o myRom.elf crt0.o screen.o
ld: cannot open crti.o: No such file or directory
make: *** [myRom.elf] Error 1 |
#27714 - sajiimori - Tue Oct 19, 2004 10:39 pm
Use a batch file. That way you won't have to learn anything.
#27727 - Krakken - Wed Oct 20, 2004 3:36 am
sajiimori wrote: |
Use a batch file. That way you won't have to learn anything. |
And why is not learning anything ever been good? It just makes you more ignorant to the subject.
#27728 - yaustar - Wed Oct 20, 2004 3:46 am
Note: Complete beginner at Make files so this post is more of me testing my knowledge then providing a correct anwer. Thanks :)
I think that the error is caused by this code:
Code: |
myRom.elf: $(CLIST)
$(CC) -o myRom.elf $(CLIST)
myRom.elf: $(SLIST)
$(CC) -o myRom.elf $(SLIST) |
Setting two rules for myRom.elf to be dependent on different sets of files so it chooses one over the other...
It also makes no sense in creating a myRom.elf TWICE by compiling two different sets of files :S
As for the crti.o error.. er...
edit: would this be correct?
Code: |
CFLAGS = -c -O2
THUMBMODEL = -mthumb -mthumb-interwork
CLIST = main.o screen.o crt0.o
CC = D:\GBA\DEVKIT\arm-agb-elf\bin\gcc
all: myRom.gba
myRom.gba: myRom.elf
objcopy -O binary myRom.elf myRom.gba
myRom.elf: $(CLIST)
$(CC) -o myRom.elf $(CLIST)
$(LIST): %.o: %.c
$(CC) $(CFLAGS) $(THUMBMODEL) $< |
_________________
[Blog] [Portfolio]
#27729 - sajiimori - Wed Oct 20, 2004 4:58 am
Krakken: Learning is not for everybody, in particular those who have decided they already know. ;)
yaustar: Your solution is a working makefile, but if any of the .o files can only be built from .s files, the built-in make rule for .s files will be applied. The built-in rule is often sufficient though, especially for assembly files because there aren't a lot of compiler options to tweak.
#27730 - yaustar - Wed Oct 20, 2004 5:05 am
Thats a first... I actually got something [half?] right ;)[/i]
_________________
[Blog] [Portfolio]
#27731 - Abscissa - Wed Oct 20, 2004 5:16 am
In tomer's defense, makefiles *are* rather unintuitive and difficult to learn and work with. I consider myself knowledgeable about how they work but I still get fed up with them from time to time...
#27733 - sajiimori - Wed Oct 20, 2004 5:30 am
Oh I would never blame anybody for not understanding makefiles. I still don't understand them, when it comes down to it.
But why would tomer need defending anyway? He already knows how makefiles work.
#27746 - YopYop - Wed Oct 20, 2004 10:15 am
Code: |
CC=gcc
LD=ld
AS=as
CFLAGS += -I C:\gbadev\devkitadv\arm-agb-elf\include -I C:\gbadev\lib -g -O2 -mthumb-interwork -Wall -fverbose-asm
LDFLAGS += -L C:\gbadev\devkitadv\arm-agb-elf\lib\interwork -L. -Tlnkscript -Ttext 0x08000000 -Tbss 0x03000000
ASFLAGS += -mthumb-interwork
EXEC = proto.bin
SHELL = sh.exe
TARGET_ELF = out.elf
.CFILES= $(wildcard *.c)
.OFILES= crt0.o $(.CFILES:.c=.o)
all: $(EXEC)
$(EXEC): $(TARGET_ELF)
objcopy -v -O binary $(TARGET_ELF) $(EXEC)
$(TARGET_ELF): $(.OFILES)
$(LD) $(LDFLAGS) $^ -o $(TARGET_ELF) -lm
|
Here is my makefile you can take it as example.
You have to change the include dir in CFLAGS and the lib dir in LDFLAGS.
It will take all your c files compile them in o files. Then take all the o files and crt0.o and link them in proto.bin
#27909 - Peter - Sat Oct 23, 2004 4:57 pm
tomer wrote: |
I used to use Visual HAM IDE. But, then I relized it uses only a debug
library, which probably makes things slower.
|
Here I would like to point to this post :)