| 1 | ###############################################################################
|
|---|
| 2 | # Makefile for the project FSC
|
|---|
| 3 | ###############################################################################
|
|---|
| 4 |
|
|---|
| 5 | ## General Flags
|
|---|
| 6 | PROJECT = FSC
|
|---|
| 7 | MCU = atmega32
|
|---|
| 8 | TARGET = FSC.elf
|
|---|
| 9 | CC = avr-gcc
|
|---|
| 10 |
|
|---|
| 11 | CPP = avr-g++
|
|---|
| 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 -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=FSC.map
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | ## Intel Hex file production flags
|
|---|
| 32 | HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
|
|---|
| 33 |
|
|---|
| 34 | HEX_EEPROM_FLAGS = -j .eeprom
|
|---|
| 35 | HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
|
|---|
| 36 | HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | ## Objects that must be built in order to link
|
|---|
| 40 | OBJECTS = ad7719_adc.o application.o atmega_adc.o FSC.o muxer_fsc.o spi_master.o timer.o w5100_spi_interface.o
|
|---|
| 41 |
|
|---|
| 42 | ## Objects explicitly added by the user
|
|---|
| 43 | LINKONLYOBJECTS =
|
|---|
| 44 |
|
|---|
| 45 | ## Build
|
|---|
| 46 | all: $(TARGET) FSC.hex FSC.eep FSC.lss size
|
|---|
| 47 |
|
|---|
| 48 | ## Compile
|
|---|
| 49 | ad7719_adc.o: ad7719_adc.c
|
|---|
| 50 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 51 |
|
|---|
| 52 | application.o: application.c
|
|---|
| 53 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 54 |
|
|---|
| 55 | atmega_adc.o: atmega_adc.c
|
|---|
| 56 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 57 |
|
|---|
| 58 | FSC.o: FSC.c
|
|---|
| 59 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 60 |
|
|---|
| 61 | muxer_fsc.o: muxer_fsc.c
|
|---|
| 62 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 63 |
|
|---|
| 64 | spi_master.o: spi_master.c
|
|---|
| 65 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 66 |
|
|---|
| 67 | timer.o: timer.c
|
|---|
| 68 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 69 |
|
|---|
| 70 | w5100_spi_interface.o: w5100_spi_interface.c
|
|---|
| 71 | $(CC) $(INCLUDES) $(CFLAGS) -c $<
|
|---|
| 72 |
|
|---|
| 73 | ##Link
|
|---|
| 74 | $(TARGET): $(OBJECTS)
|
|---|
| 75 | $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
|
|---|
| 76 |
|
|---|
| 77 | %.hex: $(TARGET)
|
|---|
| 78 | avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
|
|---|
| 79 |
|
|---|
| 80 | %.eep: $(TARGET)
|
|---|
| 81 | -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
|
|---|
| 82 |
|
|---|
| 83 | %.lss: $(TARGET)
|
|---|
| 84 | avr-objdump -h -S $< > $@
|
|---|
| 85 |
|
|---|
| 86 | size: ${TARGET}
|
|---|
| 87 | @echo
|
|---|
| 88 | @avr-size ${TARGET}
|
|---|
| 89 |
|
|---|
| 90 | ## Clean target
|
|---|
| 91 | .PHONY: clean
|
|---|
| 92 | clean:
|
|---|
| 93 | -rm -rf $(OBJECTS) FSC.elf dep/* FSC.hex FSC.eep FSC.lss FSC.map
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | ## Other dependencies
|
|---|
| 97 | -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
|---|
| 98 |
|
|---|