求助makefile 中的include 引用变量,之前并没有定义,怎么回事啊?

lnasliu   2009-2-27 11:25 楼主
makefile include $(NXPMCU_SOFTWARE)/makerule/$(CSP)/make.$(CSP).$(TOOL)后面两个变量引用是什么意思?
附:所有的makefile文件内容
我是初学makefile
麻烦哪位能否帮我把下面这段解释一下?
ifeq ($(TOOL), keil)
MEXT        =.map
MAPFILE     =$(EXECNAME)
C_ENTRY     =
ENTRY       =
CFLAGS      +=-g
AFLAGS      +=-g
LDSCRIPT    =linker/ldscript_rom_rvw.ld
endif

########################################################################
# $Id:: makefile 1031 2008-08-06 22:28:49Z wellsk                      $
#
# Project: Bootable/FLASHable example makefile
#
# Description:
#  Makefile
#
########################################################################
# Software that is described herein is for illustrative purposes only  
# which provides customers with programming information regarding the  
# products. This software is supplied "AS IS" without any warranties.  
# NXP Semiconductors assumes no responsibility or liability for the
# use of the software, conveys no license or title under any patent,
# copyright, or mask work right to the product. NXP Semiconductors
# reserves the right to make changes in the software without
# notification. NXP Semiconductors also make no representation or
# warranty that such application will be suitable for the specified
# use without further testing or modification.
########################################################################

EXECNAME    =kickstart

########################################################################
#
# Pick up the default build rules
#
########################################################################

include $(NXPMCU_SOFTWARE)/makerule/$(CSP)/make.$(CSP).$(TOOL)

########################################################################
#
# Arm compiler/linker specific stuff
#
# ARM examples enter via __main and are linked at address 0x0000
#
########################################################################

ifeq ($(TOOL), ads)
MEXT        =.map
MAPFILE     =$(EXECNAME)
C_ENTRY     =
ENTRY       =
CFLAGS      +=-g
AFLAGS      +=-g
LDSCRIPT    =linker/ldscript_rom_$(TOOL).ld
endif

ifeq ($(TOOL), rvw)
MEXT        =.map
MAPFILE     =$(EXECNAME)
C_ENTRY     =
ENTRY       =
CFLAGS      +=-g
AFLAGS      +=-g
LDSCRIPT    =linker/ldscript_rom_$(TOOL).ld
endif

ifeq ($(TOOL), keil)
MEXT        =.map
MAPFILE     =$(EXECNAME)
C_ENTRY     =
ENTRY       =
CFLAGS      +=-g
AFLAGS      +=-g
LDSCRIPT    =linker/ldscript_rom_rvw.ld
endif

########################################################################
#
# Gcc compiler/linker specific stuff
#
########################################################################

ifeq ($(TOOL), gnu)
MEXT        =.map
MAPFILE     =$(EXECNAME)
C_ENTRY     =
ENTRY       =
CFLAGS      +=-gdwarf-2
AFLAGS      +=
LDSCRIPT    =linker/ldscript_rom_$(TOOL).ld
endif

########################################################################
#
# Pick up the assembler and C source files in the directory  
#
########################################################################
include $(NXPMCU_SOFTWARE)\makerule\common\make.rules.ftypes

########################################################################
#
# Rules to build the executable
#
########################################################################

default: release

release:       
        @$(MAKE) TOOL=$(TOOL) debug
        @$(MAKE) TOOL=$(TOOL) bin
        @$(MAKE) TOOL=$(TOOL) hex

debug: $(OBJS) lpc_libs
        $(LD) $(OBJS) $(LDFLAGS) $(LK) $(SCAN) $(MAP) $(MAPFILE)$(MEXT) \
        $(LDESC) $(LDSCRIPT) $(ENTRY) $(C_ENTRY) -o $(EXECNAME)$(EXT)

bin:
        $(ELFTOBIN) $(EXECNAME)$(EXT) $(EXECNAME).bin

hex:
ifeq ($(TOOL), ads)
        $(ELFTOREC) $(EXECNAME)$(EXT) -o $(EXECNAME).$(REC)
endif

ifeq ($(TOOL), rvw)
        $(ELFTOREC) $(EXECNAME)$(EXT) -o $(EXECNAME).$(REC)
endif

ifeq ($(TOOL), ghs)
        $(ELFTOREC) $(EXECNAME)$(EXT) -o $(EXECNAME).$(REC)
endif

ifeq ($(TOOL), gnu)
        $(ELFTOREC) $(EXECNAME)$(EXT) $(EXECNAME).$(REC)
endif

ifeq ($(TOOL), iar)
        $(ELFTOREC) $(EXECNAME)$(EXT) $(EXECNAME).$(REC)
endif

########################################################################
#
# Pick up the compiler and assembler rules
#
########################################################################

include $(NXPMCU_SOFTWARE)/makerule/common/make.rules.build

.PHONY: default release debug bin   

回复评论 (2)

变量可以来自于shell里面的环境变量。
如果这个makefile不是顶层的makefile,他们还可能来自于其他的makefile定义。
点赞  2009-3-5 20:48
也可能来自命令行啊
比如你这样编译

make clean all NXPMCU_SOFTWARE=nxp
点赞  2009-4-14 15:28
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复