summaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@bpcsapce.com>2023-01-24 14:58:52 -0600
committerBrett Weiland <brett_weiland@bpcsapce.com>2023-01-24 14:58:52 -0600
commita5984050eb556741ef40792d6335b7f65fa1eb4f (patch)
treeaaf870b1558d6b40369f481443c4ce768f9b76be /src/makefile
parentb666668d0e6b67e4632e65486cae814ab5abbc39 (diff)
started fixing makefile, created test function
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/makefile b/src/makefile
index 7191432..51a9541 100644
--- a/src/makefile
+++ b/src/makefile
@@ -1,7 +1,6 @@
#compile options
TOOLCHAIN_DIR=/home/indigo/packs/avr8-gnu-toolchain-linux_x86_64
CC=$(TOOLCHAIN_DIR)/bin/avr-gcc
-LD=$(TOOLCHAIN_DIR)/bin/avr-ld
INC=$(TOOLCHAIN_DIR)/avr/include
OUT=compiled_payload.elf
DEVICE=atmega2560
@@ -21,16 +20,19 @@ BAUD=115200
#baudrate
RUNTIME_BAUDRATE=9600
+SRCFILES := $(wildcard *.c)
+OBJFILES := $(patsubst %.c,build/%.o,$(SRCFILES))
-make:
- #$(CC) -mmcu=$(DEVICE) -I $(INC) -c debug_serial.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 debug_serial.c
- #$(CC) -mmcu=$(DEVICE) -I $(INC) -c main.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c
- #$(CC) -mmcu=$(DEVICE) -I $(INC) -c debug_serial.o -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 i2c.c
- #$(LD) -mavr6 -o $(OUT) -s main.o debug_serial.o #TODO wish I knew how to make -mavr6 dependent on DEVICE
- #TODO no debug.c if debug disabled
- $(CC) -mmcu=$(DEVICE) -I $(INC) -o $(OUT) -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c pcf_clock_driver.c -Wall
+
+make: $(OBJFILES)
+ echo $(SRCFILES)
+ $(CC) -DDEBUG_BUILD=$(DEBUG) -mmcu=$(DEVICE) -o $(OUT) $(OBJFILES)
compiledb make --dry-run > /dev/null
+build/%.o: %.c
+ if [ ! -d "build" ]; then mkdir -p build; fi
+ $(CC) $(CCOPTS) -c -I $(INC) -mmcu=$(DEVICE) -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 -o $@ $<
+
reset:
doas avrdude -c usbtiny -p $(PARTNO)
@@ -41,8 +43,8 @@ eeprom_write:
eeprom:
./compile_eeprom.py
-eeprom_install:
- $(CC) -mmcu=atmega2560 -I $(INC) -o $(OUT) -DFLASH_EEPROM -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c -Wall
+#eeprom_install:
+ #$(CC) -mmcu=atmega2560 -I $(INC) -o $(OUT) -DFLASH_EEPROM -DDEBUG_BUILD=$(DEBUG) -DBAUD=$(RUNTIME_BAUDRATE) -DF_CPU=$(F_CPU) -Wall -O1 main.c debug.c i-DDEBUG_BUILD=$(DEBUG)2c.c ssd1306_display_driver.c uart.c br24t_eeprom_driver.c paint.c -Wall
doas avrdude -B 1 -v -p ATmega2560 -c usbtiny -U flash:w:$(OUT):e
@@ -56,5 +58,5 @@ screen:
doas screen $(DEBUG_PORT) $(RUNTIME_BAUDRATE)
clean:
- rm -f *.o *.elf compiled_eeprom
+ rm -f *.o *.elf compiled_eeprom build/*