2299 |
jacho |
1 |
############################################################################### |
|
|
2 |
# Makefile for the project LCD_zkouska |
|
|
3 |
############################################################################### |
|
|
4 |
|
|
|
5 |
## General Flags |
|
|
6 |
PROJECT = LCD_zkouska |
|
|
7 |
MCU = atmega8 |
|
|
8 |
TARGET = LCD_zkouska.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 -Os -std=gnu99 -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=LCD_zkouska.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 = LCD_zkouska.o |
|
|
41 |
|
|
|
42 |
## Objects explicitly added by the user |
|
|
43 |
LINKONLYOBJECTS = |
|
|
44 |
|
|
|
45 |
## Build |
|
|
46 |
all: $(TARGET) LCD_zkouska.hex LCD_zkouska.eep LCD_zkouska.lss size |
|
|
47 |
|
|
|
48 |
## Compile |
|
|
49 |
LCD_zkouska.o: ../LCD_zkouska.c |
|
|
50 |
$(CC) $(INCLUDES) $(CFLAGS) -c $< |
|
|
51 |
|
|
|
52 |
##Link |
|
|
53 |
$(TARGET): $(OBJECTS) |
|
|
54 |
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) |
|
|
55 |
|
|
|
56 |
%.hex: $(TARGET) |
|
|
57 |
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ |
|
|
58 |
|
|
|
59 |
%.eep: $(TARGET) |
|
|
60 |
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0 |
|
|
61 |
|
|
|
62 |
%.lss: $(TARGET) |
|
|
63 |
avr-objdump -h -S $< > $@ |
|
|
64 |
|
|
|
65 |
size: ${TARGET} |
|
|
66 |
@echo |
|
|
67 |
@avr-size -C --mcu=${MCU} ${TARGET} |
|
|
68 |
|
|
|
69 |
## Clean target |
|
|
70 |
.PHONY: clean |
|
|
71 |
clean: |
|
|
72 |
-rm -rf $(OBJECTS) LCD_zkouska.elf dep/* LCD_zkouska.hex LCD_zkouska.eep LCD_zkouska.lss LCD_zkouska.map |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
## Other dependencies |
|
|
76 |
-include $(shell mkdir dep 2>NUL) $(wildcard dep/*) |
|
|
77 |
|