Makefile 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. TARGET = main
  2. MCU ?= msp430g2553
  3. #MCU ?= msp430fr2111
  4. #DEBUGGER ?= rf2500
  5. DEBUGGER ?= tilib
  6. TOOLCHAIN = /usr
  7. CC = $(TOOLCHAIN)/bin/msp430-gcc
  8. AS = $(TOOLCHAIN)/bin/msp430-as
  9. LD = $(TOOLCHAIN)/bin/msp430-ld
  10. OC = $(TOOLCHAIN)/bin/msp430-objcopy
  11. OD = $(TOOLCHAIN)/bin/msp430-objdump
  12. OS = $(TOOLCHAIN)/bin/msp430-size
  13. CFLAGS += -g
  14. CFLAGS += -Os
  15. CFLAGS += -Wall
  16. CFLAGS += -mmcu=$(MCU)
  17. LFLAGS += -g
  18. LFLAGS += -mmcu=$(MCU)
  19. C_SRC = ./main.c
  20. INCLUDE = -I./
  21. OBJS = $(C_SRC:.c=.o)
  22. .PHONY: all
  23. all: $(TARGET).bin
  24. %.o: %.S
  25. $(CC) -x assembler-with-cpp $(ASFLAGS) $< -o $@
  26. %.o: %.c
  27. $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
  28. $(TARGET).elf: $(OBJS)
  29. $(CC) $^ $(LFLAGS) -o $@
  30. $(TARGET).bin: $(TARGET).elf
  31. $(OC) -S -O binary $< $@
  32. $(OS) $<
  33. .PHONY: clean
  34. clean:
  35. rm -f $(OBJS)
  36. rm -f $(TARGET).elf
  37. rm -f $(TARGET).bin
  38. .PHONY: flash
  39. flash:
  40. mspdebug $(DEBUGGER) 'erase' 'load $(TARGET).elf' 'exit'