66 lines
1.2 KiB
Makefile
66 lines
1.2 KiB
Makefile
# detect OS
|
|
ifeq ($(OS),Windows_NT)
|
|
RM = del /q
|
|
else
|
|
UNAME_S := $(shell uname -s)
|
|
ifeq ($(UNAME_S),Linux)
|
|
RM = rm -rf
|
|
endif
|
|
ifeq ($(UNAME_S),Darwin)
|
|
RM = rm -rf
|
|
endif
|
|
# UNAME_P := $(shell uname -p)
|
|
# ifeq ($(UNAME_P),x86_64)
|
|
# CCFLAGS += -D AMD64
|
|
# endif
|
|
# ifneq ($(filter %86,$(UNAME_P)),)
|
|
# CCFLAGS += -D IA32
|
|
# endif
|
|
# ifneq ($(filter arm%,$(UNAME_P)),)
|
|
# CCFLAGS += -D ARM
|
|
# endif
|
|
endif
|
|
|
|
# set CC TOOL
|
|
CC := sdcc
|
|
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 COM3 .\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
|