adding c files to example makefile

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

Hey there all.

I'm having some problems with using Makefiles. Despite my attempts to comprehend the manual I am still confused.

Basically i just want to modify the example makefile from the winavr distribution so it can compile multipul C files - Just not too sure what to change.

(the makefile i'm talking about is looks like this: (abbreviated)

PRG = main
OBJ = main.o
MCU_TARGET = atmega8
OPTIMIZE = -O2

DEFS =
LIBS =

# You should not have to change anything below here.

CC = avr-gcc

# Override is only needed by avr-lib build system.

override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).map

OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump

all: $(PRG).elf lst text eeprom

$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
(etc..........................)

basically i have a timer.c file (and it's header) and I want the makefile to use this so it can find my timer routines :)

Any help would be appreciated.

odd.

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

figured it out ppl... at least it is working thus far...

(from Makefile...)

OBJ = main.o timer.o

something like that :)

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

No, no, no. You should NOT have to modify the OBJ variable. If you're using the sample makefile that comes with WinAVR (found in the \sample directory) then all you should have to modify is the SRC variable.

Alternatively, you can use MFile, written by Joerg Wunsch:

This is a GUI-based makefile generator for use with AVR GCC (for Windows, or on Linux / FreeBSD). The makefile template the the Windows version uses, is essentially the WinAVR sample makefile.

admin's test signature