chen
2024-11-12 cb6f4698ce2a52378d26249028ee33094b3db49f
gcc/Makefile
对比新文件
@@ -0,0 +1,169 @@
PROJ_NAME = uwb_simple_example
# Build folder
ODIR      = ./objects
# Detect Unix-style shell
ifeq ($(findstring /,$(PWD)),/)
RM        = rm -f
FixPath   = $1
MKDIR     = mkdir -p
MV        = mv -f
$(info Unix-Style)
else
SHELL    := cmd.exe
RM        = del /Q
FixPath   = $(subst /,\,$1)
MKDIR     = mkdir
MV        = copy
$(info Windows)
endif
# Configure tool names
CC        = arm-none-eabi-gcc
CXX       = arm-none-eabi-g++
AS        = arm-none-eabi-as
OBJCOPY   = arm-none-eabi-objcopy -O binary -S
SIZE      = arm-none-eabi-size
# Define CPU target
#  - Use Cortex-M1 if tools do not provide named support for Cortex-M0
#  - Compiling for Cortex-M1 will produce code compatible with Cortex-M0
CPUTARGET = -mcpu=Cortex-M0 -mthumb -mthumb-interwork
#
# CM0MCU compiler options
#
CCFLAGS   = $(CPUTARGET) -std=c99 -O2 -g -DUWB_EN
CCFLAGS  += -ffunction-sections -fdata-sections
LDFLAGS   = $(CPUTARGET) -T ../../../../../devices/MK800X/Source/GCC/gcc_arm.ld
# Use newlib-nano
LDFLAGS  += --specs=nano.specs
LDFLAGS  += --specs=nosys.specs
# print float
#LDFLAGS  += -u_printf_float
# Link for code size
LDFLAGS  += -Wl,--gc-sections
# Create map file
LDFLAGS  += -Wl,-Map=$(PROJ_NAME).map
ASFLAGS   = $(CPUTARGET) --keep
# Source code
SRC       = ../../../board.c \
            ../pin_config.c \
            ../../../../src/uwb_examples/uwb_simple_example/main.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_init/simple_ds_twr_init.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_init_sts/simple_ds_twr_init_sts.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_resp/simple_ds_twr_resp.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_ds_twr_resp_sts/simple_ds_twr_resp_sts.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_rx/simple_rx.c \
            ../../../../src/uwb_examples/uwb_simple_example/simple_tx/simple_tx.c \
            ../../../../../components/algo/src/steering_vector/cmp_svec.c \
            ../../../../../components/crc/crc.c \
            ../../../../../components/libc/libc.c \
            ../../../../../components/wsf/sources/platform/pal_flash.c \
            ../../../../../components/wsf/sources/platform/pal_sys.c \
            ../../../../../components/wsf/sources/platform/pal_uart.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_assert.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_buf.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_bufio.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_heap.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_msg.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_nvm.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_os.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_queue.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_timer.c \
            ../../../../../components/wsf/sources/port/baremetal/wsf_trace.c \
            ../../../../../devices/MK800X/Source/startup_MK800X.c \
            ../../../../../devices/MK800X/Source/system_MK800X.c \
            ../../../../../drivers/mk_adc.c \
            ../../../../../drivers/mk_aes.c \
            ../../../../../drivers/mk_calib.c \
            ../../../../../drivers/mk_clock.c \
            ../../../../../drivers/mk_dma.c \
            ../../../../../drivers/mk_dual_timer.c \
            ../../../../../drivers/mk_flash.c \
            ../../../../../drivers/mk_gpio.c \
            ../../../../../drivers/mk_io.c \
            ../../../../../drivers/mk_misc.c \
            ../../../../../drivers/mk_power.c \
            ../../../../../drivers/mk_reset.c \
            ../../../../../drivers/mk_rtc.c \
            ../../../../../drivers/mk_sleep_timer.c \
            ../../../../../drivers/mk_trace.c \
            ../../../../../drivers/mk_uart.c \
            ../../../../../drivers/mk_uwb.c \
            ../../../../../drivers/mk_wdt.c \
# Include path
INC       = -I../../../../../CMSIS/Include \
            -I../../.. \
            -I.. \
            -I../../../../../components/algo/inc \
            -I../../../../../components/crc \
            -I../../../../../components/libc \
            -I../../../../../components/wsf/include \
            -I../../../../../components/wsf/include/platform \
            -I../../../../../devices/MK800X/Include \
            -I../../../../../drivers \
# Include library
LIB       = ../../../../../components/algo/lib/lib_aoa.a \
            ../../../../../components/algo/lib/lib_ranging.a \
            ../../../../../drivers/lib/lib_lsp.a \
            ../../../../../drivers/lib/lib_mac_phy.a \
            -lm \
ODIR_     = $(call FixPath, $(ODIR))
OBJS      = $(patsubst %.c, $(ODIR)/%.o, $(notdir $(SRC)))
OBJS_     = $(call FixPath, $(OBJS))
ifneq ($(ODIR), $(wildcard $(ODIR)))
$(shell $(MKDIR) $(ODIR_))
endif
$(info $(ODIR))
$(info $(OBJS))
SOURSE_DIR = $(dir $(SRC))
vpath %.c $(SOURSE_DIR)
.PHONY: all clean
################################################################################
#
# Rule deck
#
all: $(PROJ_NAME).bin $(PROJ_NAME).elf $(OBJS)
$(ODIR)/%.o: %.c
      $(info $< $@)
      $(CC) -c $(CCFLAGS) $(INC) $< -o $@
%.elf: $(OBJS)
      $(CC) $(LDFLAGS) $^ -Xlinker "-(" $(LIB) -Xlinker "-)" -o $(PROJ_NAME).elf
      $(SIZE) $@
%.bin: %.elf
      $(OBJCOPY) $(PROJ_NAME).elf $(PROJ_NAME).bin
################################################################################
#
# Clean - remove all .bin, .elf, .map
#
clean:
      $(RM) $(OBJS_) *.bin *.elf *.map
download:
      -./pyjlink -f $(PROJ_NAME).bin
# EOF