Skip to content
Snippets Groups Projects
Makefile 1.63 KiB
Newer Older
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
DEVICE     = atxmega128a3u
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
PROGRAMMER = -c avrispmkII
OBJECTS    = main.o clock.o debug.o bus.o status.o utils.o messages.o orders.o thermometer_cold.o thermometer_hot.o median_filter.o leds.o main_timer.o
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
PORT		= usb

# For computing fuse byte values for other devices and options see
# the fuse bit calculator at http://www.engbedded.com/fusecalc/


# Tune the lines below only if you know what you are doing:

LFLAGS =
#LFLAGS = -Wl,-u,vfprintf -lprintf_flt
AVRDUDE = avrdude -v -v $(PROGRAMMER) -p $(DEVICE)  -P $(PORT) 
COMPILE = avr-gcc -Wall -Os -mmcu=$(DEVICE)

.PHONY: clean all

Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
.INTERMEDIATE: commitid.h id.h message.o main.o
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed

# symbolic targets:
all:	main.hex

clean:
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
		rm -f *.o *.elf *.hex commitid.h id.h
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed

commitid.h: .git/refs/heads
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
	cog -r *.c *.h
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
	./define_commit_id.py > $@

Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
		$(COMPILE) -c $< -o $@

.S.o:
		$(COMPILE) -x assembler-with-cpp -c $< -o $@
		# "-x assembler-with-cpp" should not be necessary since this is the
		# default
		# file type for the .S (with capital S) extension. However, upper case
		# characters are not always preserved on Windows. To ensure WinAVR
		# compatibility define the file type manually.

flash:	all
		$(AVRDUDE) -B 60 -e -U flash:w:main.hex:i
		#	$(AVRDUDE) -U flash:w:main.hex:i

fuse:
		$(AVRDUDE) $(FUSES)

# file targets:
main.elf: $(OBJECTS)
		$(COMPILE) $(LFLAGS) -o main.elf $(OBJECTS)
		    
main.hex: main.elf
		rm -f main.hex
		avr-objcopy -j .text -j .data -O ihex main.elf main.hex
		avr-size --format=avr --mcu=$(DEVICE) main.elf #configOutput.elf
		# If you have an EEPROM section, you must also create a hex file
		# for the
		# EEPROM and add it to the "flash" target.