📄 makefile
字号:
##---------------------------------------------------------------------
#
# $Copyright 2001 Joseph J. Lemieux ALL RIGHTS RESERVED. $
#
# $Filename: C:\OSEKBook\src\CH05\bld\Makefile $
#
######################################################################
#
# Makefile for generating program.elf
#
# To build the file using only changed files to target RAM
# "make build_ram"
# To build the file using only changed files to target FLASH
# "make build_flash"
# To make all files to target RAM:
# "make rebuild_ram"
# To make all files to target FLASH:
# "make rebuild_flash"
#
######################################################################
#
# Definitions for default source and build root directories:
#
# All user source files should reside in a tree under $(SRC).
# Build files should reside in a tree under $(BLD).
# Include files should reside in a tree under $(INC).
# Application configuration files are in the $(CFG) directory.
# Intermediary object files will reside in $(BUILD_DIR).
# Binary files will be stored in $(BIN).
# Compile listings are stored in $(LST).
#
SOURCE =..\src
BLD =.
INC =..\inc
CFG = ..\cfg
BUILD_DIR = ..\obj
BIN = ..\bin
LST = ..\lst
#
# Define virtual paths to check if an explicit path is not
# defined for a given file name.
#
vpath %.o ../obj/
vpath %.c ../src/
vpath %.s ../src/
vpath %.h ../inc/
vpath %.cfg ../cfg/
#
# Include application specific make. This file includes the definition
# of the target environment and the rules for files to be created.
#
include $(BLD)\program.mk
#
# Include OS specific make file. This file should contain all the
# definitions for the implementation specific make of the system. This
# is intended to allow the user to utilize the same make file for the
# application for different OS configurations.
#
include $(BLD)\os.mk
#
# Define compiler, assembler, and linker executables.
#
# CHANGE_ME start
#
# This section defines the location of the embedded toolset used. If you have
# a different toolchain than the Diab toolchain, change the following lines
# to point to the proper toolset and to use the proper command lines and options for
# assembly and C programs
#
TOOLSET = c:\programs\tools
CC = $(TOOLSET)\dcc
AS = $(TOOLSET)\das
AR = $(TOOLSET)\dar
LD = $(TOOLSET)\dld
DUMP = $(TOOLSET)\ddump
#
# Define command lines for assembly and C compile.
#
ASMPRE = $(CC) -E $< > $(BUILD_DIR)\$(*F).ppc
ASMLINE = $(AS) $(AFLAGS) -D TARGET_MEMORY=$(TARGET_ENV) -o $(BUILD_DIR)\$@ $(BUILD_DIR)\$(*F).ppc > $(LST)\$(*F).lst
ASMPOST = @del $(BUILD_DIR)\$(*F).ppc
COMPLINE = $(CC) $(CFLAGS) -o $(BUILD_DIR)\$@ $(SOURCE)\$< > $(LST)\$(*F).lst
#
# Define compiler, assembler, and linker flags.
# Please refer to toolchain documentation for a description.
#
CFLAGS = -c -g\
-XO\
-Xstruct-best-align=0\
-Xansi\
-Xlint\
-Xkill-reorder=1\
-Xkill-reorder=8\
-Wa,-L\
-Xpass-source\
-Xsmall-data=2048\
-Xsmall-const=2048\
-Xstring-align=1\
-t$(DTARGET)E$(DFP)\
-I$(INC)\
-I$(CFG)\
-I$(BLD)\
-I$(OS_INC)\
-I$(OS_TGT)
AFLAGS = -L -t$(DTARGET)E$(DFP) -I$(INC) -I$(CFG)
LFLAGS = -t$(DTARGET)E$(DFP) -Xsupress-dot -limpl -m2 -lc
#
# end change_me
#
#
# Define the standard headers that will be used in all programs. If any of these headers
# change, the entire program will be re-compiled.
#
STDHDRS = typedefs.h $(OS_INCS) os.h init.h
#
# Build rules.
#
#
# rebuild program to place in RAM
#
rebuild_ram: clean build_ram
#
# rebuild program to place in FLASH
#
rebuild_flash: clean build_flash
#
# Clean all files from the build directory only without rebuilding.
#
clean:
del /Q $(BUILD_DIR)\*.*
#
# Remake program to place in RAM
# CHANGE_ME start
# oil.lk file is generated by the OSEK/VDX implementation and defines the files
# that must be linked into the application to include OSEK/VDX functionality. Either
# replace with an implementation specific link file, or create your own. The .dld
# extension on program.dld is specific to the DIAB toolchain and will need to be changed.
# Likewise, the target of a .elf file may need to be changed.
#
build_ram: $(OBJECTS) $(BLD)\program.lk $(BLD)\oil.lk $(BLD)\target.lk $(BLD)\makefile
copy $(BLD)\program.lk $(BLD)\program.dld
type $(BLD)\oil.lk >>$(BLD)\program.dld
type $(BLD)\target.lk >>$(BLD)\program.dld
@$(BLANK)
@echo ==== Linking ====
@$(BLANK)
$(LD) $(LFLAGS) >$(BIN)\program.map -Wm $(BLD)\program.dld -o $(BIN)\program.elf
$(DUMP) -Rv $(BIN)\program.elf -o $(BIN)\program.s19
#
# Remake program to place in FLASH
#
build_flash: $(OBJECTS) $(BLD)\progflsh.lk $(BLD)\oil.lk $(BLD)\target.lk $(BLD)\makefile
copy $(BLD)\progflsh.lk $(BLD)\program.dld
type $(BLD)\oil.lk >>$(BLD)\program.dld
type $(BLD)\target.lk >>$(BLD)\program.dld
@$(BLANK)
@echo ==== Linking ====
@$(BLANK)
$(LD) $(LFLAGS) >$(BIN)\program.map -Wm $(BLD)\program.dld -o $(BIN)\program.elf
$(DUMP) -Rv $(BIN)\program.elf -o $(BIN)\program.s19
# end change_me
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -