go away spammer

Author Topic: Makefile help  (Read 1657 times)

0 Members and 1 Guest are viewing this topic.

Offline GWER57Topic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 2
Makefile help
« on: December 13, 2009, 07:16:39 PM »
Hi, I've read the tutorials on doing serial communications. But i cant find where to put uart.c and rprintf.c in my makefile. I think its supposed to be near SRCS but that is what i cant find. >:(

Makefile:
###############################################################################
# Makefile for the project Clcok-Program
###############################################################################

## General Flags
PROJECT = Clcok-Program
MCU = atmega328p
TARGET = Clcok-Program.elf
CC = avr-gcc.exe

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS +=  -Wl,-Map=Clcok-Program.map


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings


## Include Directories
INCLUDES = -I"C:\Users\Grant\Desktop\Grant Wenzinger Engineering And Robotics\Engineering Projects\Clock\Program\Clcok-Program\..\..\..\..\..\..\..\..\AVRlib"

## Objects that must be built in order to link
OBJECTS = Clcok-Program.o

## Objects explicitly added by the user
LINKONLYOBJECTS =

## Build
all: $(TARGET) Clcok-Program.hex Clcok-Program.eep Clcok-Program.lss size

## Compile
Clcok-Program.o: ../Clcok-Program.c
   $(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
    $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
   avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
   -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
   avr-objdump -h -S $< > $@

size: ${TARGET}
   @echo
   @avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
   -rm -rf $(OBJECTS) Clcok-Program.elf dep/* Clcok-Program.hex Clcok-Program.eep Clcok-Program.lss Clcok-Program.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

Any help would be greatly appreciated.  ;D
GTW

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: Makefile help
« Reply #1 on: December 14, 2009, 12:13:56 AM »
you can append the object files (any file with an .o)
to the OBJECTS variable
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

Offline GWER57Topic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 2
Re: Makefile help
« Reply #2 on: December 15, 2009, 06:23:17 AM »
Yeah but i want to know where to put the include files such as uart.c, rprintf.c, etc.
GTW

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: Makefile help
« Reply #3 on: December 16, 2009, 07:29:53 AM »
This is what I meant ...

OBJECTS = Clcok-Program.o uart.o rprintf.o

If you use GNU make, which is used by most freeware toolchains, there exists implicit rules to convert a .c to a .o file.
http://www.gnu.org/software/automake/manual/make/Implicit-Rules.html

So with this implicit rule in place the make command will know how to generate that "uart.o" by trying to find a "uart.c" in the current directory.
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

 


Get Your Ad Here

data_list