Guest User

Untitled

a guest
Jan 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 2.57 KB | None | 0 0
  1. #
  2. # Makefile for msp430
  3. #
  4. # 'make' builds everything
  5. # 'make clean' deletes everything except source files and Makefile
  6. # You need to set TARGET, MCU and SOURCES for your project.
  7. # TARGET is the name of the executable file to be produced
  8. # $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all genera
  9. # The TXT file is used for BSL loading, the ELF can be used for JTAG use
  10. #
  11. TARGET     = test1
  12. MCU        = msp430g2452
  13. # List all the source files here
  14. # eg if you have a source file foo.c then list it here
  15. SOURCES = main.c
  16. # Include are located in the Include directory
  17. INCLUDES = -IInclude
  18. # Add or subtract whatever MSPGCC flags you want. There are plenty more
  19. ################################################################################
  20. CFLAGS   = -mmcu=$(MCU) -g -O0 -Wall -Wunused $(INCLUDES)
  21. ASFLAGS  = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
  22. LDFLAGS  = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map
  23. ################################################################################
  24. CC       = msp430-gcc
  25. LD       = msp430-ld
  26. AR       = msp430-ar
  27. AS       = msp430-gcc
  28. GASP     = msp430-gasp
  29. NM       = msp430-nm
  30. OBJCOPY  = msp430-objcopy
  31. RANLIB   = msp430-ranlib
  32. STRIP    = msp430-strip
  33. SIZE     = msp430-size
  34. READELF  = msp430-readelf
  35. MAKETXT  = srec_cat
  36. CP       = cp -p
  37. RM       = rm -f
  38. MV       = mv
  39. ################################################################################
  40. # the file which will include dependencies
  41. DEPEND = $(SOURCES:.c=.d)
  42. # all the object files
  43. OBJECTS = $(SOURCES:.c=.o)
  44. all: $(TARGET).elf $(TARGET).hex $(TARGET).txt
  45. $(TARGET).elf: $(OBJECTS)
  46.         echo "Linking $@"
  47.         $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
  48.         echo
  49.         echo ">>>> Size of Firmware <<<<"
  50.         $(SIZE) $(TARGET).elf
  51.         echo
  52. %.hex: %.elf
  53.         $(OBJCOPY) -O ihex $< $@
  54. %.txt: %.hex
  55.         $(MAKETXT) -O $@ -TITXT $< -I
  56. %.o: %.c
  57.         echo "Compiling $<"
  58.         $(CC) -c $(CFLAGS) -o $@ $<
  59. # rule for making assembler source listing, to see the code
  60. %.lst: %.c
  61.         $(CC) -c $(CFLAGS) -Wa,-anlhd $< > $@
  62. # include the dependencies unless we're going to clean, then forget about them.
  63. ifneq ($(MAKECMDGOALS), clean)
  64. -include $(DEPEND)
  65. endif
  66. # dependencies file
  67. # includes also considered, since some of these are our own
  68. # (otherwise use -MM instead of -M)
  69. %.d: %.c
  70.         echo "Generating dependencies $@ from $<"
  71.         $(CC) -M ${CFLAGS} $< >$@
  72. .SILENT:
  73. .PHONY: clean
  74. clean:
  75.         -$(RM) $(OBJECTS)
  76.         -$(RM) $(TARGET).*
  77.         -$(RM) $(SOURCES:.c=.lst)
  78.         -$(RM) $(DEPEND)
Add Comment
Please, Sign In to add comment