#------------------------------------------
# Makefile
#
# Makefile for buildfirmware and buildDSP
#
# Build and executes tools to generate binary
# firmware from ADI's headers and .bnm files.
#
# ADI's firmware header is not free software,
# buildfirmware is therefore in public domain.
# .bnm files are not open sourced, but can be
# considered as data files for buildDSP, and
# buildDSP is published under the GNU GPL license.

CONFIGDIR=/etc/analog
INSTALLER = $(shell which install)
CFLAGS=-O2 -pipe -Wall -pedantic

all:  DSPcode.bin #firmware.bin

firmware.bin : buildFirmware
	./buildFirmware

buildFirmware : Firmware8051.h HexRecord.h firmware.c
	gcc $(CFLAGS) firmware.c -o buildFirmware

DSPcode.bin : buildDSP sagem/eagle/rtbld0.bnm sagem/eagle/rtbld1.bnm \
		sagem/eagle/rtbld2.bnm sagem/eagle/rtbld3.bnm \
		sagem/eagle/rtbld4.bnm
	./buildDSP -d sagem/eagle DSPcode.bin

buildDSP : builddsp.c
	gcc $(CFLAGS) builddsp.c -o buildDSP

install : firmware.bin DSPcode.bin
	mkdir -p $(CONFIGDIR)
	$(INSTALLER) -c -m 0664 -o root -g root *.bin $(CONFIGDIR)

uninstall:
	rm -f  $(CONFIGDIR)/DSPcode.bin
	rm -f $(CONFIGDIR)/firmware.bin

clean :
	rm -f firmware.bin buildFirmware buildDSP DSPcode.bin

