# Your target AVR microcontroller
MCU = attiny2313

# C compiler flags for optimization
CFLAGS = -Wall -Os -ffunction-sections -fdata-sections -mmcu=$(MCU)

# Linker flags
LDFLAGS = -Wl,--gc-sections

# Name of your project
TARGET = lab2.4.2

# Source files
SOURCES = main2.c lcd_lib.c

# Default rule
all: $(TARGET).hex

# Link object files to create an ELF file
$(TARGET).elf: $(SOURCES)
	avr-gcc $(CFLAGS) $(LDFLAGS) -o $@ $^

# Create HEX file from ELF file
$(TARGET).hex: $(TARGET).elf
	avr-objcopy -O ihex -R .eeprom $< $@

# Rule to show size
size: $(TARGET).elf
	avr-size --format=avr --mcu=$(MCU) $<

