uart_temp/Makefile

64 lines
1.2 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
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
2024-07-15 00:48:18 +08:00
LDFLAGS := --iram-size 0x100 --xram-size 0x400 --code-size 0xffff
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
2024-07-14 01:16:44 +08:00
all: main.hex
2023-12-29 00:57:13 +08:00
clean:
2024-07-15 00:48:18 +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)
2024-07-15 00:48:18 +08:00
-$(CC) $(LDFLAGS) $^ -o $@
2023-12-29 00:57:13 +08:00
2024-07-14 01:16:44 +08:00
main.hex: $(TARGET)
-$(PACKIHX) $(TARGET) > main.hex
2023-12-29 00:57:13 +08:00
2024-07-15 00:48:18 +08:00
flash:
-sudo chmod 777 $(COM)
2024-07-15 01:01:03 +08:00
-./reset_mcu.sh $(COM)
2024-07-14 01:16:44 +08:00
-stcgal -P stc89 -p $(COM) main.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