rgb16mpm/Makefile

60 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

2012-03-02 17:35:35 +01:00
# ############################
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
PRG = rgb16mpm
MCU_TARGET = atmega32
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
# ############################
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
BUILD_DIR = build
SRC = $(wildcard *.c)
OUTPUTS = .hex .bin _eeprom.hex _eeprom.bin
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
CFLAGS = -Os -g -Wall -mmcu=$(MCU_TARGET)
2019-08-11 11:34:34 +02:00
CFLAGS += -pipe -MMD -MP -MF $(BUILD_DIR)/$(*D)/$(*F).d
2012-03-02 17:35:35 +01:00
LDFLAGS = -Wl,-Map,$(BUILD_DIR)/$(*D)/$(*F).map,--cref
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
# ############################
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
.PHONY: all clean install
all: $(patsubst %,$(BUILD_DIR)/$(PRG)%, .elf $(OUTPUTS))
@$(SIZE) -x -A $<
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
.SECONDARY: $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
$(BUILD_DIR)/%.elf: $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
@echo " Linking file: $@"
@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
@$(OBJDUMP) -h -S $@ > $(subst elf,lst,$@)
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
$(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
@echo " Building file: $<"
@$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
@$(CC) $(CFLAGS) -o $@ -c $<
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
@$(OBJCOPY) -j .text -j .data -O binary $< $@
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
$(BUILD_DIR)/%_eeprom.hex: $(BUILD_DIR)/%.elf
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
$(BUILD_DIR)/%_eeprom.bin: $(BUILD_DIR)/%.elf
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
# ############################
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
clean:
rm -rf $(BUILD_DIR)
2011-11-14 20:23:01 +01:00
2012-03-02 17:35:35 +01:00
install: $(BUILD_DIR)/$(PRG).hex
2012-02-20 21:34:22 +01:00
# avrdude -p m32 -c dragon_isp -P usb -U flash:w:$(PRG).hex
2012-03-02 17:35:35 +01:00
mpmboot -d /dev/ttyUSB0 -a 0x11 -w flash:$<