sam7fc/Makefile

79 lines
2.1 KiB
Makefile
Raw Normal View History

2008-02-03 21:41:39 +01:00
TOOLCHAIN = /opt/arm-toolchain
OPENOCD = /opt/arm-toolchain/openocd
AS = $(TOOLCHAIN)/bin/arm-elf-as
CC = $(TOOLCHAIN)/bin/arm-elf-gcc
LD = $(TOOLCHAIN)/bin/arm-elf-ld
NM = $(TOOLCHAIN)/bin/arm-elf-nm
SIZE = $(TOOLCHAIN)/bin/arm-elf-size
OBJCOPY = $(TOOLCHAIN)/bin/arm-elf-objcopy
OBJDUMP = $(TOOLCHAIN)/bin/arm-elf-objdump
INCDIRS = include $(TOOLCHAIN)/lib/gcc/arm-elf/4.1.1/include $(TOOLCHAIN)/arm-elf/include
LIBDIRS = $(TOOLCHAIN)/arm-elf/lib $(TOOLCHAIN)/lib/gcc/arm-elf/4.1.1
# ------
BUILD = build
TARGET = sam7fc
ASFLAGS = -mcpu=arm7tdmi -Wa,-adhlns=$(BUILD)/$(*D)/$(*F).lst,--gdwarf-2 -Iinclude
CFLAGS = -gdwarf-2 -mcpu=arm7tdmi -Os -std=gnu99
CFLAGS += -Wa,-adhlns=$(BUILD)/$(*D)/$(*F).lst
CFLAGS += -nostdinc $(patsubst %,-I%,$(INCDIRS))
2008-02-04 19:06:40 +01:00
CFLAGS += -MD -MP -MF $(BUILD)/$(*D)/$(*F).d
2008-02-03 21:41:39 +01:00
CFLAGS += -Wall
2008-02-04 01:51:29 +01:00
#CFLAGS += -Wextra
2008-02-03 21:41:39 +01:00
#CFLAGS += -Wcast-align -Wimplicit -Wunused
2008-02-04 19:19:27 +01:00
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow
CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return
2008-02-03 21:41:39 +01:00
#CFLAGS += -Wcast-qual -Wnested-externs
2008-02-04 19:19:27 +01:00
#CFLAGS += -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wstrict-prototypes
2008-02-03 21:41:39 +01:00
LDFLAGS = -nostartfiles -t ldscript.ld -Wl,-Map=$@.map,--cref
LDFLAGS += $(patsubst %,-L%,$(LIBDIRS))
LDFLAGS += -lc -lgcc
# ------
SRC := $(wildcard *.c) $(wildcard src/*.c) $(wildcard src/*/*.c)
AS_SRC := $(wildcard *.s) $(wildcard src/*.s)
all: $(BUILD)/$(TARGET).elf
@$(SIZE) -x $<
$(BUILD)/$(TARGET).elf: $(patsubst %,$(BUILD)/%,$(AS_SRC:.s=.o) $(SRC:.c=.o))
@echo " Linking file: $@"
@$(shell mkdir -p $(BUILD)/$(*D))
2008-02-04 01:51:29 +01:00
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) > /dev/null
2008-02-03 21:41:39 +01:00
@$(OBJCOPY) -O binary $@ $@.bin
@$(OBJCOPY) -O ihex $@ $@.hex
@$(OBJDUMP) -h -S -C $@ > $@.lss
@$(NM) -n $@ > $@.sym
$(BUILD)/%.o: %.c
@echo " Building file: $<"
@$(shell mkdir -p $(BUILD)/$(*D))
@$(CC) -c $(CFLAGS) $< -o $@
$(BUILD)/%.o: %.s
@echo " Building file: $<"
@$(shell mkdir -p $(BUILD)/$(*D))
@$(CC) -c $(ASFLAGS) $< -o $@
clean:
rm -rf $(BUILD)
openocd:
$(shell $(OPENOCD) -f scripts/openocd.cfg)
2008-02-05 20:04:07 +01:00
install:
./scripts/download.sh
2008-02-04 19:06:40 +01:00
-include $(shell find $(BUILD) -name *.d 2> /dev/null)