+# Compilador
CC=sdcc
-LD=sdcc
-CFLAGS=-DDEBUG
+#CFLAGS=-DDEBUG
+
+# Assembler
+AS=asx8051
+ASFLAGS=-plosgff
+
+# Linker
+LD=aslink
+LDFLAGS=-cn
+
+# Shell
+SHELL=bash
+
+# Archivos
+cmodules=main dp8390 eth arp ip udp elp
+amodules=leds
+modules=$(cmodules) $(amodules)
all: el.hex
+debug.h: types.h leds.h
+
reg51.h: reg51sdcc.h
netdev.h: types.h
dp8390.h: types.h reg51.h netdev.h
-dp8390.rel: dp8390.c dp8390.h
- $(CC) $(CFLAGS) -c dp8390.c
+eth.h: types.h
+
+ip.h: types.h
+
+arp.h: types.h eth.h ip.h
+
+udp.h: types.h
+
+elp.h: types.h
+
+dp8390.asm: dp8390.c dp8390.h debug.h eth.h
+dp8390.rel: dp8390.asm
+
+eth.asm: eth.c eth.h netdev.h debug.h
+eth.rel: eth.asm
+
+arp.asm: arp.c arp.h netdev.h debug.h
+arp.rel: arp.asm
+
+ip.asm: ip.c ip.h netdev.h debug.h
+ip.rel: ip.asm
+
+udp.asm: udp.c udp.h ip.h netdev.h debug.h
+udp.rel: udp.asm
+
+elp.asm: elp.c elp.h leds.h udp.h netdev.h debug.h
+elp.rel: elp.asm
+
+main.asm: main.c leds.h reg51.h netdev.h eth.h ip.h udp.h elp.h debug.h
+main.rel: main.asm
-eth.rel: eth.c eth.h netdev.h types.h
- $(CC) $(CFLAGS) -c eth.c
+leds.rel: leds.asm
-ip.rel: ip.c ip.h netdev.h types.h
- $(CC) $(CFLAGS) -c ip.c
+el.hex: $(addsuffix .rel, $(modules))
+ @echo -e \
+ "-myuxi\n"\
+ "-Y\n"\
+ "-b CSEG = 0x0000\n"\
+ "-b ISEG = 0x0080\n"\
+ "-b BSEG = 0x0000\n"\
+ "-k /usr/share/sdcc/lib/small\n"\
+ "-k /usr/share/sdcc/lib/small\n"\
+ "-l mcs51\n"\
+ "-l libsdcc\n"\
+ "-l libint\n"\
+ "-l liblong\n"\
+ "-l libfloat\n"\
+ "$(addsuffix .rel\n, $(modules))"\
+ "-e\n" | \
+ $(LD) $(LDFLAGS)
+ @packihx main.ihx > el.hex
+ @$(RM) main.ihx
-udp.rel: udp.c udp.h ip.h netdev.h types.h
- $(CC) $(CFLAGS) -c udp.c
+%.asm:
+ $(CC) $(CFLAGS) -c $<
-main.rel: main.c netdev.h eth.h ip.h udp.h
- $(CC) $(CFLAGS) -c main.c
+%.rel:
+ $(AS) $(ASFLAGS) $<
-el.hex: main.rel dp8390.rel eth.rel ip.rel udp.rel
- $(LD) $(LDFLAGS) -o el.hex main.rel dp8390.rel eth.rel ip.rel udp.rel
clean:
- @rm -vf el.hex *.rel *.asm *.lst *.map *.lnk *.mem *.sym
+ @rm -vf el.hex *.rel $(addsuffix .asm, $(cmodules)) *.lst *.map *.lnk *.mem *.sym *.rst
.PHONY: clean