linux上可以使用sdcc進行單片機開發(fā)
ubuntu使用
apt-get install sdcc
即可安裝。
附一個比較通用的Makefile
PRJ := test
SRC := $(wildcard *.c)
HEX := $(PRJ).hex
IHX := obj/$(PRJ).ihx
OBJ := $(foreach i, $(SRC), obj/$(i:.c=.rel))
MCU := -mmcs51
CC := sdcc $(MCU)
AS := asx8051 #可能是sdas8051
LD := sdcc
PACKIHX := packihx
CFLAG :=
ASFLAG := -los
LDFLAG :=
all: obj $(HEX)
obj:
@mkdir obj
$(HEX): $(IHX)
@echo "Create hex file ..."
@$(PACKIHX) $< > $@
$(IHX): $(OBJ)
@echo -ne "Linking ..."
@$(LD) $(LDFLAG) $^ -o $@
@echo "OK"
obj/%.rel: %.c
@echo -ne "Compiling $< ..."
@$(CC) -c $(CFLAG) $< -o $@
@echo "OK"
.PHONY: clean
clean:
@echo "Clear project ..."
@-rm -f obj/*
@echo "OK"