assembly + C makefile error (no rule to make target)

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update

So it turns it it really didn't like me calling it adelay.asm and renaming to adelay.S sorted it out (tested it out in Proteus and it does as expected). But as i said, i've compiled stuff using the .asm filetype before and simply referencing them as .S so how come not this time?

--

I'm trying to use the accurate delay library here:

https://www.avrfreaks.net/index.p...

When i add the "adelay.S" file into the makefile, i get the following error during:

make: *** No rule to make target "make.elf", needed by 'elf'. Stop."

This isn't triggered when only the C file is compiled/linked. If i only include the adelay header and don't call the delay function the error isn't triggered.

I plucked some code that i know compiles fine by itself and i know it works because i tested it in Proteus ISIS.

#include 
#include 

/* This example flashes the LED's on STK500, it handles GCC
   tendency to trash empty delay loops by inserting volatile inline asm. */
   
void wait (void) 
{
	asm volatile ("nop"::);
}

int main (void) 
{
	unsigned char i;
	unsigned long j;
	
	DDRB = 0xFF;			// Configure PORTB as output
	
	for(;;) 
	{
		for (i=0x01; i<0x80; i<<=1) 
		{
			PORTB = ~i;
			
			/* Delay */
			for (j=0; j<20000; j++) wait();
			Delay_ms(1);
		}
		
		for (i=0x80; i>0x01; i>>=1) 
		{
			PORTB = ~i;
			
			/* Delay, the delay loops defined in avr/delay.h, could also be used */
			for (j=0; j<20000; j++) wait();
		}
	}
}

Note the additional "Delay_ms();".

The makefile is:

# Hey Emacs, this is a -*- makefile -*-
#
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
# Additional material for this makefile was submitted by:
#  Tim Henigan
#  Peter Fleury
#  Reiner Patommel
#  Sander Pool
#  Frederik Rouleau
#  Markus Pfaff
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
#                4.07 or greater).
#
# make program = Download the hex file to the device, using avrdude.  Please
#                customize the avrdude settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#


# MCU name
MCU = atmega8

# Output format. (can be srec, ihex, binary)
FORMAT = ihex

# Target file name (without extension).
TARGET = main


# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c


# List Assembler source files here.
# Make them always end in a capital .S.  Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC = adelay.S



# Optimization level, can be [0, 1, 2, 3, s]. 
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
<...snip...>

The rest of the makefile is unchanged relative to the original (i didn't see the point of posting it, it's a basic template).

The file is called adelay.asm to stop it being deleted when i clean, but that's not important? (i've compiled other source that's been called .asm rather than .S)

Any idea what's causing this - i assume it's a simple error?

I'm assuming i've not written the makefile correctly, but i can't see how else it should be.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

make has an implied rule (a so-called inference rule) to compile a file
ending in .s into an object file with suffix .o. If you insist on renaming
your input file into something.asm, there's no implied rule for this, so it
doesn't have a clue about what to do.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.