openwrt中的makefile,cp和$(cp)之间的区别是什么?

openwrt中的makefile,cp和$(cp)之间的区别是什么?,makefile,embedded,openwrt,Makefile,Embedded,Openwrt,我遵循一个教程,在openwrt中编译我自己的包 在/package/helloworld目录中: .../packege/helloworld$ ls src Makefile .../packege/helloworld$ ls src hello.c main.c Makefile .../packege/helloworld$vi Makefile #helloworld makefile include $(TOPDIR)/rules.mk PKG_NAME:=helloworld

我遵循一个教程,在openwrt中编译我自己的包

在/package/helloworld目录中:

.../packege/helloworld$ ls
src Makefile
.../packege/helloworld$ ls src
hello.c main.c Makefile
.../packege/helloworld$vi Makefile

#helloworld makefile
include $(TOPDIR)/rules.mk

PKG_NAME:=helloworld
PKG_RELEASE:=1
PKG_VERSION:=0.1

PKG_BUILD_DEPENDS:=

include $(INCLUDE_DIR)/package.mk

define Package/helloworld
  SECTION:=utils
  CATEGORY:=Utilities
  DEPENDS:=@TARGET_etrax
  TITLE:=Yet Another Helloworld Application
endef

define Package/helloworld/description
 This is helloworld :p
endef

define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
    $(TARGET_CONFIGURE_OPTS) \
    CFLAGS="$(TARGET_CFLAGS)"
endef

define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin/
endef

$(eval $(call BuildPackage,helloworld))
关于这个Makefile,我有两个问题:

  • 我发现有一些命令,比如mkdir、$(CP)、$(MAKE)。我将$(CP)更改为CP,编译进行得很顺利。所以我不明白为什么会有这两种格式

  • 参数,如$(PKG\u BUILD\u DIR),$(INSTALL\u DIR)在openwrt中定义在哪里?我刚刚找到定义$(TOPDIR)的地方,但没有找到其他地方

  • 谢谢

  • 这些格式并不不同,cp是一种,$(cp)是一种生成文件结构,用于“获取make变量cp的值”。因此,在Linux下,它应该扩展到cp(即应该在某个地方用该值初始化),并且很可能扩展到Windows下的复制(这都取决于特定的设置,因为cp复制不完全相同)。$(MKDIR)和其他系统工具也是如此

    1.1$(MAKE)实际上是另一回事-这是一个特殊的MAKE变量,它通过从命令行传递的参数/标志扩展为MAKE工具名。阅读

  • 这些都是控制在何处构建和在何处安装的变量。见说明