Saturday, May 28, 2011

Eclipse compatible Makefile for IAR embedded workbench C project

Well here we come to the trickiest bit.
I enclose a sample self designed makefile for a HelloWorld type C program, which consists of multiple files, namely HelloWorld and HelloNextWorld...



###############################################################################
# Makefile for the C versions on windows
#
#
# NOTES : the CC and LD must be on the PATH environment variable
# this is because of a bug in the IAR EW 2.3x
# that does not allow whitespace in windows paths
# define the C_INCLUDE and XLINK_DFLTDIR environment variables as well
#
#set path=%PATH%;C:/Program Files/IAR Systems/ew23/430/bin
#set C_INCLUDE =C:/Program Files/IAR Systems/ew23/430/inc
#set XLINK_DFLTDIR=C:/Program Files/IAR Systems/ew23/430/lib

## General Flags
PROJECT = hellomsp430std
MCU = msp430
TARGET = $(PROJECT).d43

CC = icc430.exe
LD = xlink.exe

SRCS = $(wildcard *.c)
OBJECTS= $(patsubst %.c,%.r43, $(SRCS))

## Compile options
CFLAGS = -e -K -gA -s0 -RCODE -r0 -t8

## Linker flags
LDFLAGS = -rt -I"C:/Program Files/IAR Systems/ew23/430/lib" -f lnk430F1611.xcl
##

## Objects to be built


## Build
all: $(TARGET)

## compile

##$(PROJECT).r43: $(PROJECT).c
%.r43: %.c
$(CC) $(INCLUDES) $(CFLAGS) $<

##Link
$(TARGET): $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) -o $(TARGET)

## Clean target
.PHONY: distclean
distclean: clean
@rm -f $(TARGET) $(PROJECT).lst $(PROJECT).map

.PHONY: clean
clean:
@rm -f $(OBJECTS)

###############################################################################

1 comment:

vishnu said...

Is it possible to use this same makefile with IAR Workbench for Renessas M16c