uart_temp/Makefile

62 lines
1.1 KiB
Makefile
Raw Normal View History

2024-01-13 01:29:24 +08:00
# detect OS
ifeq ($(OS),Windows_NT)
2024-01-14 23:11:38 +08:00
RM := del /q
2024-01-15 20:33:52 +08:00
CC := sdcc
2024-01-14 23:11:38 +08:00
COM := COM3
2024-01-13 01:29:24 +08:00
else
2024-01-14 23:23:35 +08:00
RM := rm -rf
2024-01-14 23:11:38 +08:00
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
2024-01-13 01:29:24 +08:00
endif
2024-01-14 23:11:38 +08:00
ifeq ($(UNAME_S),Deepin)
CC := ablrun sdcc
COM := /dev/ttyUSB0
2024-01-13 01:29:24 +08:00
endif
2024-01-14 23:23:35 +08:00
TEMP := $(shell sudo chmod 777 $(COM))
2024-01-13 01:29:24 +08:00
endif
2023-12-29 00:57:13 +08:00
# set CC TOOL
PACKIHX := packihx
2023-12-29 01:33:22 +08:00
CFLAGS := -DUSE_FLOATS=1
2023-12-29 00:57:13 +08:00
# 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:
2024-01-13 01:29:24 +08:00
-$(RM) obj\*
2023-12-29 00:57:13 +08:00
$(OBJ):obj/%.rel:src/%.c
2023-12-29 01:33:22 +08:00
-$(CC) $(CFLAGS) -I $(INC) -c $^ -o $@
2023-12-29 00:57:13 +08:00
$(TARGET): $(OBJ)
-$(CC) $^ -o $@
uart_temp.hex: $(TARGET)
-$(PACKIHX) $(TARGET) > uart_temp.hex
flash:
2024-01-14 23:23:35 +08:00
-stcgal -P stc89 -p $(COM) uart_temp.hex
2023-12-29 00:57:13 +08:00
#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