MakeFile, Yagarto and C++

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MakeFile, Yagarto and C++

759 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by madcreator on Mon Feb 18 16:10:27 MST 2013
Hi, I'm trying to get the FatFs library working with my Lpcxpresso1769 but it's quite difficult...

I'm almost there but I need to compile C++ file to have the .o and get the functions in my project, I'm bad with makefile and cross compilation is hard to understand...

Here is my make file, does anyone know how to had the ''functionality" to compile and link c++ files ???



ARCH = arm-none-eabi

# Tool definitions
CC      = $(ARCH)-gcc
C++      = $(ARCH)-g++
LD      = $(ARCH)-ld
AR      = $(ARCH)-ar
AS      = $(ARCH)-as
CP      = $(ARCH)-objcopy
OD= $(ARCH)-objdump
SIZE= $(ARCH)-size
RM= rm
Q= # @./quiet "$@"

# Flags
CFLAGS   = -W -Wall -Os  --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb
CFLAGS  += -ffunction-sections -fdata-sections
ASFLAGS  =
LDFLAGS  = --gc-sections
CPFLAGS  =
ODFLAGS  = -x --syms
PRFLAGS ?=


# Source files
LINKER_SCRIPT = LPC17xx.ld
CSRCS  = startup_LPC17xx.c $(wildcard *.c)
CSRCS += ./source/main.c \
 ./source/uart.c \
 ./SDLIB/src/FatFS/ff.c \
./SDLIB/src/FatFS/diskio.c \
./SDLIB/src/FatFS/cc932.c \




OBJS   = $(CSRCS:.c=.o) $(ASRCS:.s=.o)

.PHONY: all size clean nuke

all: main.hex 

size: main.elf
@$(SIZE) $<

%.hex: %.elf
$Q $(CP) $(CPFLAGS) -O ihex $< ./build/$*.hex

%.bin: %.elf
$Q $(CP) $(CPFLAGS) -O binary $< ./build/$*.bin

main.elf: $(LINKER_SCRIPT) $(OBJS) 
$Q $(LD) -Map $(@:.elf=.map) $(LDFLAGS) -T $^ -o $@ 
$Q $(OD) $(ODFLAGS) $@ > $(@:.elf=.dump)
@$(SIZE) $@

%.o: %.c
@$(CC) -MM $< -MF $*.d -MP
$Q $(CC) -c $(CFLAGS) $< -o $@

clean:
@-rm -f *.elf
@-\
for D in "." "**"; do \
  rm -f $$D/*.o $$D/*.d $$D/*.lst $$D/*.dump $$D/*.map; \
done

nuke: clean
-rm -f *.hex *.bin

-include $(CSRCS:.c=.d)


run : 
/opt/lpc21isp/lpc21isp ./build/main.hex /dev/cu.SLAB_USBtoUART  115200 20000

BT : 
/opt/lpc21isp/lpc21isp ./build/main.hex /dev/cu.SLAVE-DevB  115200 2000


For information I work with Yagarto and Netbeans. Here is the website of the library : http://elm-chan.org/fsw/ff/00index_e.html



Thanks for your help !

(if you have any advice on this makefile, feel free to give them )

Madcreator
0 Kudos
Reply
0 Replies