-
-PROGRAM=firmware
-SRC=firmware.c rs485.c
-OBJ=$(SRC:.c=.o)
-
-
-MCU=atmega328p
-# AVRDUDE_MCU=$(MCU)
-AVRDUDE_MCU=atmega328p
-AVRDUDE_PROGRAMMER=arduino
-
-CFLAGS=-Wall -Os -mmcu=$(MCU) -DUSE_LOGGING=1 -DF_CPU=16000000UL -std=gnu99
-LDFLAGS=
-AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER) -P /dev/ttyUSB0 -b 57600
-
-FORMAT=ihex
-
-CC=avr-gcc
-OBJCOPY=avr-objcopy
-OBJDUMP=avr-objdump
-AVRDUDE=avrdude
-
WEB_DIR=/home/kas/html/board/
WEB_FILES=pcb-back.png pcb-front.png schematics.png handlebar.png
GERBER_FILES=\
board.outline.gbr \
board.plated-drill.cnc
-all: $(PROGRAM).hex $(PROGRAM).eep
+all:
+ @echo "Usage: make [clean|web|gerber|fab|board.pcb]"
clean:
rm -f board.cmd board.jpg board.net board.new.pcb board.pcb- \
board.png board.ps board.sch~ pcb-back.png pcb-front.png \
- schematics.png *.gbr *.cnc \
- $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s \
- eeprom.raw version.c
+ schematics.png *.gbr *.cnc
web: $(WEB_FILES)
test -d $(WEB_DIR) && install -m 644 $(WEB_FILES) $(WEB_DIR)
echo "You may also want to do git tag gerber-fab-$$D" '
.PHONY: gerber
-
-program: $(PROGRAM).hex $(PROGRAM).eep
- $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
-
-program_flash: $(PROGRAM).hex
- $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i
-
-program_eeprom: $(PROGRAM).eep
- $(AVRDUDE) $(AVRDUDE_FLAGS) eeprom:w:$(PROGRAM).eep:i
-
-dump_eeprom:
- $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:eeprom.raw:r
- od -tx1 eeprom.raw
-
-objdump: $(PROGRAM).elf
- $(OBJDUMP) --disassemble $<
-
-.PRECIOUS : $(OBJ) $(PROGRAM).elf
-
-%.hex: %.elf
- $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
- $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
- --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-%.elf: $(OBJ)
- $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
-
-%.o: %.c lights.h Makefile
- $(CC) -c $(CFLAGS) $< -o $@
-
-%.s: %.c lights.h Makefile
- $(CC) -S -c $(CFLAGS) $< -o $@
-
-%.o: %.S
- $(CC) -c $(CFLAGS) $< -o $@
-
-clean:
-
-version.c:
- ./version.pl > version.c
-
-.PHONY: all clean dump_eeprom program program_flash program_eeprom objdump \
- version.c
-
--- /dev/null
+
+PROGRAM=firmware
+SRC=firmware.c rs485.c
+OBJ=$(SRC:.c=.o)
+
+MCU=atmega328p
+# AVRDUDE_MCU=$(MCU)
+AVRDUDE_MCU=atmega328p
+AVRDUDE_PROGRAMMER=arduino
+
+CFLAGS=-Wall -Os -mmcu=$(MCU) -DUSE_LOGGING=1 -DF_CPU=16000000UL -std=gnu99
+LDFLAGS=
+AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER) -P /dev/ttyUSB0 -b 57600
+
+FORMAT=ihex
+
+CC=avr-gcc
+OBJCOPY=avr-objcopy
+OBJDUMP=avr-objdump
+AVRDUDE=avrdude
+
+all: $(PROGRAM).hex $(PROGRAM).eep
+
+program: $(PROGRAM).hex $(PROGRAM).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
+
+program_flash: $(PROGRAM).hex
+ $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i
+
+program_eeprom: $(PROGRAM).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) eeprom:w:$(PROGRAM).eep:i
+
+dump_eeprom:
+ $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:eeprom.raw:r
+ od -tx1 eeprom.raw
+
+objdump: $(PROGRAM).elf
+ $(OBJDUMP) --disassemble $<
+
+.PRECIOUS : $(OBJ) $(PROGRAM).elf
+
+%.hex: %.elf
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+%.elf: $(OBJ)
+ $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
+
+%.o: %.c lights.h Makefile
+ $(CC) -c $(CFLAGS) $< -o $@
+
+%.s: %.c lights.h Makefile
+ $(CC) -S -c $(CFLAGS) $< -o $@
+
+%.o: %.S
+ $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ rm -f *.o $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf
+
+version.c:
+ ./version.pl > version.c
+
+.PHONY: all clean dump_eeprom program program_flash program_eeprom objdump \
+ version.c
+