uart_temp/Makefile
2024-01-14 23:11:38 +08:00

60 lines
1.1 KiB
Makefile

# detect OS
ifeq ($(OS),Windows_NT)
RM := del /q
COM := COM3
else
RM =: rm -rf
UNAME_S := $(shell cat /etc/*-release | grep 'DISTRIB_ID' | sed 's/DISTRIB_ID=\(\w*\)/\1/g')
ifeq ($(UNAME_S),Ubuntu)
CC := sdcc
COM := /dev/ttyUSB0
endif
ifeq ($(UNAME_S),Deepin)
CC := ablrun sdcc
COM := /dev/ttyUSB0
endif
endif
# set CC TOOL
PACKIHX := packihx
CFLAGS := -DUSE_FLOATS=1
# set DIR
INCDIR = include
SRCDIR = src
OBJDIR = obj
TARGET = obj/main.ihx
INC := ./include
SRC := $(wildcard $(SRCDIR)/*.c)
# OBJ := $(SRC:%.c=%.rel)
OBJ := $(patsubst src/%.c, obj/%.rel, $(SRC))
.PHONY: all clean
all: uart_temp.hex
clean:
-$(RM) obj\*
$(OBJ):obj/%.rel:src/%.c
-$(CC) $(CFLAGS) -I $(INC) -c $^ -o $@
$(TARGET): $(OBJ)
-$(CC) $^ -o $@
uart_temp.hex: $(TARGET)
-$(PACKIHX) $(TARGET) > uart_temp.hex
flash:
-stcgal -P stc89 -p $(COM) -d uart_temp.hex
#led.bin:led.hex
# objcopy -I ihex -O binary led.hex led.bin
#led.hex:main.ihx
# packihx main.ihx > led.hex
# led.bin:main.ihx
# makebin main.ihx led.bin