Carsten Emde | da0df92 | 2012-03-18 22:37:33 +0100 | [diff] [blame] | 1 | |
| 2 | SOURCES := $(wildcard [0-9]*x[0-9]*.S) |
| 3 | |
| 4 | BIN := $(patsubst %.S, %.bin, $(SOURCES)) |
| 5 | |
| 6 | IHEX := $(patsubst %.S, %.bin.ihex, $(SOURCES)) |
| 7 | |
| 8 | CODE := $(patsubst %.S, %.c, $(SOURCES)) |
| 9 | |
| 10 | all: $(BIN) $(IHEX) $(CODE) |
| 11 | |
| 12 | clean: |
| 13 | @rm -f *.o *.bin.ihex *.bin *.c |
| 14 | |
| 15 | %.o: %.S |
| 16 | @cc -c $^ |
| 17 | |
Christoph Niedermaier | 8bed5a5 | 2018-11-05 09:48:35 +0100 | [diff] [blame] | 18 | %.bin.nocrc: %.o |
Carsten Emde | da0df92 | 2012-03-18 22:37:33 +0100 | [diff] [blame] | 19 | @objcopy -Obinary $^ $@ |
| 20 | |
Christoph Niedermaier | 8bed5a5 | 2018-11-05 09:48:35 +0100 | [diff] [blame] | 21 | %.crc: %.bin.nocrc |
| 22 | @list=$$(for i in `seq 1 127`; do head -c$$i $^ | tail -c1 \ |
| 23 | | hexdump -v -e '/1 "%02X+"'; done); \ |
| 24 | echo "ibase=16;100-($${list%?})%100" | bc >$@ |
| 25 | |
| 26 | %.p: %.crc %.S |
| 27 | @cc -c -DCRC="$$(cat $*.crc)" -o $@ $*.S |
| 28 | |
| 29 | %.bin: %.p |
| 30 | @objcopy -Obinary $^ $@ |
| 31 | |
| 32 | %.bin.ihex: %.p |
Carsten Emde | da0df92 | 2012-03-18 22:37:33 +0100 | [diff] [blame] | 33 | @objcopy -Oihex $^ $@ |
| 34 | @dos2unix $@ 2>/dev/null |
| 35 | |
| 36 | %.c: %.bin |
| 37 | @echo "{" >$@; hexdump -f hex $^ >>$@; echo "};" >>$@ |