This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Makefile

By: a guest on Nov 5th, 2010  |  syntax: C++  |  size: 2.18 KB  |  views: 141  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ###############################################################################
  2. # Makefile for the project SD_Card
  3. # by CC Dharmani, Chennai (India)
  4. # www.dharmanitech.com
  5. ###############################################################################
  6.  
  7. ## General Flags
  8. PROJECT = SD_Card
  9. MCU = atmega168
  10. TARGET = SD_Card.elf
  11. CC = avr-gcc.exe
  12.  
  13. ## Options common to compile, link and assembly rules
  14. COMMON = -mmcu=$(MCU)
  15.  
  16. ## Compile options common for all C compilation units.
  17. CFLAGS = $(COMMON)
  18. CFLAGS += -Wall -gdwarf-2 -std=gnu99         -DF_CPU=8000000UL -Os -g -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
  19. CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
  20.  
  21. ## Assembly specific flags
  22. ASMFLAGS = $(COMMON)
  23. ASMFLAGS += $(CFLAGS)
  24. ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
  25.  
  26. ## Linker flags
  27. LDFLAGS = $(COMMON)
  28. LDFLAGS +=  -Wl,-Map=SD_Card.map
  29.  
  30. ## Intel Hex file production flags
  31. HEX_FLASH_FLAGS = -R .eeprom
  32.  
  33. HEX_EEPROM_FLAGS = -j .eeprom
  34. HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
  35. HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
  36.  
  37.  
  38. ## Objects that must be built in order to link
  39. OBJECTS = FAT32.o SD_main.o SD_routines.o SPI_routines.o UART_routines.o
  40.  
  41. ## Objects explicitly added by the user
  42. LINKONLYOBJECTS =
  43.  
  44. ## Build
  45. all: $(TARGET) SD_Card.hex SD_Card.eep SD_Card.lss size
  46.  
  47. ## Compile
  48. FAT32.o: FAT32.c
  49.         $(CC) $(INCLUDES) $(CFLAGS) -c  $<
  50.  
  51. SD_main.o: SD_main.c
  52.         $(CC) $(INCLUDES) $(CFLAGS) -c  $<
  53.  
  54. SD_routines.o: SD_routines.c
  55.         $(CC) $(INCLUDES) $(CFLAGS) -c  $<
  56.  
  57. SPI_routines.o: SPI_routines.c
  58.         $(CC) $(INCLUDES) $(CFLAGS) -c  $<
  59.  
  60. UART_routines.o: UART_routines.c
  61.         $(CC) $(INCLUDES) $(CFLAGS) -c  $<
  62.  
  63. ##Link
  64. $(TARGET): $(OBJECTS)
  65.         $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
  66.  
  67. %.hex: $(TARGET)
  68.         avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
  69.  
  70. %.eep: $(TARGET)
  71.         -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
  72.  
  73. %.lss: $(TARGET)
  74.         avr-objdump -h -S $< > $@
  75.  
  76. size: ${TARGET}
  77.         @echo
  78.         @avr-size -C --mcu=${MCU} ${TARGET}
  79.  
  80. ## Clean target
  81. .PHONY: clean
  82. clean:
  83.         -rm -rf $(OBJECTS) SD_Card.elf dep/* SD_Card.hex SD_Card.eep SD_Card.lss SD_Card.map
  84.  
  85.  
  86. ## Other dependencies
  87.         -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
clone this paste RAW Paste Data