# Makefile - simple control for compiling lfxmit using sdcc.
#  Copyright (C) 2022 by Jed Marti
#   This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see https://www.gnu.org/licenses/.

.SUFFIXES:	
.SUFFIXES:	.c .rel .ihx .hex

.c.rel:
	sdcc -c $< -I. 

RM = rm -rf

OBJS =	a2d.rel arithmetic.rel \
	bits.rel bytevector.rel\
	chain.rel cmd.rel \
	digio.rel dmalloc.rel download.rel ds1085.rel \
	files.rel floats.rel floatvector.rel for.rel fs.rel functions.rel \
	i2c.rel if.rel init51.rel ints.rel \
	let.rel lex.rel logical.rel \
	more.rel morse.rel \
	parse.rel pause.rel print.rel progn.rel program.rel \
	relations.rel run.rel \
	serial.rel sleep.rel spi.rel strings.rel symtab.rel \
	vector.rel \
	while.rel

all:	$(OBJS) lfxmit.hex

clean:
	$(RM) *.src
	$(RM) *.lst
	$(RM) *.rel
	$(RM) *.hex
	$(RM) *.rst
	$(RM) *.sym
	$(RM) *.asm

load:
	FLASHUtilCL DownloadUSB -RE lfxmit.hex "" 0 1

# **A**
a2d.rel:	config.h a2d.c
arithmetic.rel:	lfxmit.h serial.h strings.h storage.h arithmetic.c

# **B**
bits.rel:	lfxmit.h serial.h storage.h bits.c
bytevector.rel:	lfxmit.h serial.h storage.h bytevector.c

# **C**
chain.rel:	lfxmit.h fs.h serial.h storage.h chain.c
cmd.rel:	lex.h lfxmit.h serial.h strings.h cmd.c

# **D**
digio.rel:	config.h lfxmit.h storage.h digio.c
dmalloc.rel:	config.h lfxmit.h storage.h serial.h dmalloc.c
download.rel:	config.h lex.h lfxmit.h serial.h fs.h download.c
ds1085.rel:	config.h lfxmit.h serial.h storage.h ds1085.h ds1085.h ds1085.c

# **E**

# **F**
files.rel:	config.h fs.h lfxmit.h storage.h serial.h files.c
floats.rel:	config.h storage.h floats.c
floatvector.rel:	lfxmit.h serial.h storage.h floatvector.c
for.rel:	lfxmit.h storage.h serial.h for.c
fs.rel:	lfxmit.h serial.h spi.h fs.h strings.h fs.c
functions.rel:	lfxmit.h serial.h storage.h functions.c

# **I**
i2c.rel:	config.h i2c.h ds1085.h serial.h i2c.c
if.rel:	config.h lfxmit.h serial.h storage.h if.c
init51.rel:	config.h lfxmit.h init51.c
ints.rel:	config.h storage.h ints.c

# **L**
let.rel:	lfxmit.h storage.h serial.h let.c
lex.rel:	config.h lfxmit.h lex.h serial.h fs.h storage.h
logical.rel:	config.h lfxmit.h serial.h storage.h logical.c

# **M**
more.rel:	lfxmit.h config.h serial.h lex.h fs.h more.c
morse.rel:	lfxmit.h config.h lfxmit.h serial.h morse.h lex.h strings.h morse.c

# **P**
parse.rel:	lfxmit.h storage.h serial.h parse.c
pause.rel:	lfxmit.h config.h serial.h pause.c
print.rel:	lfxmit.h serial.h storage.h print.c
progn.rel:	lfxmit.h storage.h progn.c
program.rel:	lfxmit.h lex.h serial.h storage.h strings.h program.c

# **R**
relations.rel:	config.h lfxmit.h serial.h storage.h relations.c
run.rel:	lfxmit.h serial.h storage.h run.c

# **S**
serial.rel:	config.h serial.h serial.c
sleep.rel:	config.h lfxmit.h serial.h storage.h sleep.c
spi.rel:	config.h spi.h serial.h spi.c
strings.rel:	strings.h strings.c
symtab.rel:	lfxmit.h config.h storage.h serial.h

# **V**
vector.rel:	lfxmit.h serial.h storage.h vector.c

# **W**
while.rel:	lfxmit.h serial.h storage.h while.c

lfxmit.rel:	config.h lfxmit.h serial.h storage.h i2c.h spi.h fs.h lex.h lfxmit.c
lfxmit.hex:	lfxmit.rel $(OBJS)
	sdcc -L --xram-size=4096 $(OBJS) lfxmit.rel -o lfxmit.ihx
	packihx lfxmit.ihx >lfxmit.hex
