108 lines
3 KiB
Makefile
108 lines
3 KiB
Makefile
|
|
# For Linux
|
||
|
|
RM = rm -f
|
||
|
|
RMDIR = rm -rf
|
||
|
|
DEVNULL = /dev/null
|
||
|
|
ECHOBLANKLINE = echo
|
||
|
|
|
||
|
|
#----------------
|
||
|
|
|
||
|
|
SYSCONFIG_TOOL ?= /home/ajit/ti/sysconfig_1.26.2/sysconfig_cli.sh
|
||
|
|
MSPM0_SDK_INSTALL_DIR ?= $(abspath ../../mspm0-sdk)
|
||
|
|
|
||
|
|
CC = "arm-none-eabi-gcc"
|
||
|
|
LNK = "arm-none-eabi-gcc"
|
||
|
|
|
||
|
|
SYSCONFIG_GUI_TOOL = $(dir $(SYSCONFIG_TOOL))sysconfig_gui$(suffix $(SYSCONFIG_TOOL))
|
||
|
|
SYSCFG_CMD_STUB = $(SYSCONFIG_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json
|
||
|
|
SYSCFG_GUI_CMD_STUB = $(SYSCONFIG_GUI_TOOL) --compiler gcc --product $(MSPM0_SDK_INSTALL_DIR)/.metadata/product.json
|
||
|
|
SYSCFG_FILES := $(shell $(SYSCFG_CMD_STUB) --listGeneratedFiles --listReferencedFiles --output . empty.syscfg)
|
||
|
|
|
||
|
|
SYSCFG_C_FILES = $(filter %.c,$(SYSCFG_FILES))
|
||
|
|
SYSCFG_H_FILES = $(filter %.h,$(SYSCFG_FILES))
|
||
|
|
SYSCFG_OPT_FILES = $(filter %.opt,$(SYSCFG_FILES))
|
||
|
|
|
||
|
|
OBJECTS = empty.obj $(patsubst %.c,%.obj,$(notdir $(SYSCFG_C_FILES)))
|
||
|
|
NAME = empty
|
||
|
|
|
||
|
|
CFLAGS += -I. \
|
||
|
|
$(addprefix @,$(SYSCFG_OPT_FILES)) \
|
||
|
|
-O2 \
|
||
|
|
@device.opt \
|
||
|
|
"-I$(MSPM0_SDK_INSTALL_DIR)/source/third_party/CMSIS/Core/Include" \
|
||
|
|
"-I$(MSPM0_SDK_INSTALL_DIR)/source" \
|
||
|
|
-mcpu=cortex-m0plus \
|
||
|
|
-march=armv6-m \
|
||
|
|
-mthumb \
|
||
|
|
-std=c99 \
|
||
|
|
-mfloat-abi=soft \
|
||
|
|
-ffunction-sections \
|
||
|
|
-fdata-sections \
|
||
|
|
-g \
|
||
|
|
-gstrict-dwarf \
|
||
|
|
-Wall \
|
||
|
|
--specs=nano.specs
|
||
|
|
|
||
|
|
LFLAGS += "-L$(MSPM0_SDK_INSTALL_DIR)/source/ti/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x" \
|
||
|
|
-nostartfiles \
|
||
|
|
-Tdevice.lds.genlibs \
|
||
|
|
-l:driverlib.a \
|
||
|
|
-Wl,-T,device_linker.lds \
|
||
|
|
"-Wl,-Map,$(NAME).map" \
|
||
|
|
"-L$(MSPM0_SDK_INSTALL_DIR)/source" \
|
||
|
|
-L.. \
|
||
|
|
-march=armv6-m \
|
||
|
|
-mthumb \
|
||
|
|
-static \
|
||
|
|
-Wl,--gc-sections \
|
||
|
|
"-L/usr/lib/gcc/arm-none-eabi/14.2.1/thumb/nofp" \
|
||
|
|
-lgcc \
|
||
|
|
-lc \
|
||
|
|
-lm \
|
||
|
|
--specs=nano.specs \
|
||
|
|
--specs=nosys.specs
|
||
|
|
|
||
|
|
all: $(NAME).out
|
||
|
|
|
||
|
|
.INTERMEDIATE: syscfg
|
||
|
|
$(SYSCFG_FILES): syscfg
|
||
|
|
@ echo generation complete
|
||
|
|
|
||
|
|
syscfg: empty.syscfg
|
||
|
|
@ echo Generating configuration files...
|
||
|
|
@ $(SYSCFG_CMD_STUB) --output $(@D) $<
|
||
|
|
|
||
|
|
|
||
|
|
# Helpful hint that the user needs to use a standalone SysConfig installation
|
||
|
|
$(SYSCONFIG_GUI_TOOL):
|
||
|
|
$(error $(dir $(SYSCONFIG_TOOL)) does not contain the GUI framework \
|
||
|
|
necessary to launch the SysConfig GUI. Please set SYSCONFIG_TOOL \
|
||
|
|
(in your SDK's imports.mak) to a standalone SysConfig installation \
|
||
|
|
rather than one inside CCS)
|
||
|
|
|
||
|
|
syscfg-gui: empty.syscfg $(SYSCONFIG_GUI_TOOL)
|
||
|
|
@ echo Opening SysConfig GUI
|
||
|
|
@ $(SYSCFG_GUI_CMD_STUB) $<
|
||
|
|
|
||
|
|
define C_RULE
|
||
|
|
$(basename $(notdir $(1))).obj: $(1) $(SYSCFG_H_FILES)
|
||
|
|
@ echo Building $$@
|
||
|
|
@ $(CC) $(CFLAGS) $$< -c -o $$@
|
||
|
|
endef
|
||
|
|
|
||
|
|
$(foreach c_file,$(SYSCFG_C_FILES),$(eval $(call C_RULE,$(c_file))))
|
||
|
|
|
||
|
|
empty.obj: src/main.c $(SYSCFG_H_FILES)
|
||
|
|
@ echo Building $@
|
||
|
|
@ $(CC) $(CFLAGS) $< -c -o $@
|
||
|
|
|
||
|
|
$(NAME).out: $(OBJECTS)
|
||
|
|
@ echo linking $@
|
||
|
|
@ $(LNK) $(OBJECTS) $(LFLAGS) -o $(NAME).out
|
||
|
|
|
||
|
|
clean:
|
||
|
|
@ echo Cleaning...
|
||
|
|
@ $(RM) $(OBJECTS) > $(DEVNULL) 2>&1
|
||
|
|
@ $(RM) $(NAME).out > $(DEVNULL) 2>&1
|
||
|
|
@ $(RM) $(NAME).map > $(DEVNULL) 2>&1
|
||
|
|
@ $(RM) $(SYSCFG_FILES)> $(DEVNULL) 2>&1
|