Go Down

Topic: target pattern contains no `%'. Makefile problem (Read 19666 times) previous topic - next topic

Robomaniac

I am trying to program the serial Arduino board using AVR studio 4 with the Makefile and trying to load the Blink LED program using a parallel port programmer. My previous attempts using the Arduino software failed and even after I loaded the bootloader directly using Ponyprog, I could get the board to work. The board should be OK as I uploaded some other software for a blinking LED and it worked.

When I try to build the .hex file from the blink.c and makefile I get the error:

makefile:178: *** target pattern contains no `%'.  Stop.

This refers to the following code (lines 177-179)

# Link: create ELF output file from object files.
$(TARGET).elf: $(OBJ)
     $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)

What is wrong and how can I change the code on 178 to build the .hex file?

mellis

Some Googling suggests that this errors happens when your target file name contains a colon ":".  It sounds like AVR Studio is using an absolute paths, including drive letters.  If you can get it to try the compilation using relative paths instead, it might work.  Alternatively, you could try running make from the command line.  

Robomaniac

Quote
Alternatively, you could try running make from the command line.  


How can I do that - I am new to programming  :-/

The following is taken from another makefile (for a different project) which works with AVR studio :

# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
     @echo
     @echo $(MSG_LINKING) $@
     $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)


However substituting the first 4 lines  with the first two lines of the Arduino makefile simply returns the same error!!

mellis

If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type "make" and press enter.  

Do you have AVR studio on a different drive than your source code or the Arduino core?  

Also, you might want to write another post describing your problems getting the Arduino environment working.  If we can figure out what's wrong, that might be an easier option than using AVR studio.

Robomaniac

Quote
If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type "make" and press enter.  


Yes the Makefile is in the same directory. I am trying some different option (exporting makefile) and try to post my progress.

Quote
Do you have AVR studio on a different drive than your source code or the Arduino core?  


No AVR studio is on the same drive

Quote
Also, you might want to write another post describing your problems getting the Arduino environment working.  If we can figure out what's wrong, that might be an easier option than using AVR studio.


I cannot understand what is really wrong, but I will try to find out any logical explanation and create a new post.

Robomaniac

#5
Jul 18, 2007, 05:54 pm Last Edit: Jul 18, 2007, 05:56 pm by Robomaniac Reason: 1
Quote
If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type "make" and press enter.  


I did this but i got the same error in the command window,  presumably I have something wrong in the file paths.

mellis

Hmm... can you post the Makefile?  Or at least any of the lines you needed to edit to configure it?

Robomaniac

I am still getting the same error when i type "make" at the cmd line. when I chang the path in the makefile in the Arduino line from c:foldername/    to  /foldername/

I get a different error

make: *** No rule to make target `blinky.o', needed by `blinky.elf'.  Stop.

Any ideas?

mellis

Try using a relative path like ../../../folder-name/.

Robomaniac

Quote
Hmm... can you post the Makefile?  Or at least any of the lines you needed to edit to configure it?


PORT = COM2
TARGET = blinky
ARDUINO = c:/ROBOTS/arduino-0008/lib/targets/arduino

SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c $(ARDUINO)/WInterrupts.c
CXXSRC = $(TARGET).cpp $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
MCU = atmega8
F_CPU = 16000000


The highlighted lines are the ones I changed.

mellis

Yea, the problem is probably this line:

ARDUINO = c:/ROBOTS/arduino-0008/lib/targets/arduino

Try the relative path and see if that helps.

Robomaniac

I changed the line to

ROBOTS/arduino-0008/lib/targets/arduino

but got a new error

make: *** No rule to make target `ROBOTS/arduino-0008/lib/targets/arduino/pins_a
rduino.o', needed by `blinky.elf'.  Stop.

presumably I need to look for the files in different folders. I will do that but I have to leave for the moment. Thanks


mellis

Try include the appropriate number of ../ 's.  E.g. if your code and Makefile are in c:\source\blinky, you'd want:

../../ROBOTS/arduino-0008/lib/targets/arduino

Robomaniac

Quote
Try include the appropriate number of ../ 's.  E.g. if your code and Makefile are in c:\source\blinky, you'd want:

../../ROBOTS/arduino-0008/lib/targets/arduino


It didn't work. I repeated the process on another win XP based computer and again I got the same errors.

Now I started again from the very beginning:

1) Unzipped arduino-0008 to C: drive
2) created new file "test"
3) copied blink.cpp from c:\arduino-0008\examples\Digital\Blink\applet  to c:\test\
4) copied makefile from c:\arduino-0008\lib\targets\arduino to c:\test\
5) modified makefile highlighted lines and saved
         
PORT = LPT1
TARGET = blink
ARDUINO = ../arduino-0008/lib/targets/arduino

SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
MCU = atmega8

6) run cmd.exe changed directory to c:\test\
7) run "make"
8) got several warnings but no errors !  If I put the files inside a folder in another folder and entering the appropriate number of ../../foldername  I still got errors.

But at last I have the .hex file - Thanks  :)
     
     

mellis

So it works with one ../ in the path, but not with two (../../)?  What errors do you get in the latter case?  What warnings do you get in the former?

Go Up