Openwrt SDK:拒绝Makefile权限

时间:2016-01-25 09:40:18

标签: makefile openwrt

我正在使用OpenWRT SDK编译用户包。 src文件位于OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686 / package / adapter / src中。

在/ adapter / src目录中,我还有Makefile:

adapter: adapter.o
    $(CC) $(LDFLAGS) adapter.o -o adapter
adapter.o: adapter.c
    $(CC) $(CFLAGS) -c adapter.c
clean:
    rm *.o adapter

在/ adapter / src目录中运行本地make工作正常。

然后我将以下Makefile添加到/ adapter目录:

include $(TOPDIR)/rules.mk
PKG_NAME:=adapter
PKG_RELEASE=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/adapter
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=adapter --prints a dummy message
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)
endef

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

$(eval $(call BuildPackage,adapter))

当我在顶级目录中运行make时,我收到以下错误:

zy@zy-OptiPlex-745:~/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686$ make V=99
Collecting package info: done
#
# configuration written to .config
#
make[1]: Entering directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686'
make[2]: Entering directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686'
make[3]: Entering directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/package/adapter'
mkdir -p /home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/build_dir/target-mips_34kc_musl-1.1.11/adapter
./src/* /home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/build_dir/target-mips_34kc_musl-1.1.11/adapter
bash: ./src/Makefile: Permission denied
make[3]: *** [/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/build_dir/target-mips_34kc_musl-1.1.11/adapter/.prepared_e0632caf1f416a667d5957a7f385ceb6] Error 126
make[3]: Leaving directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/package/adapter'
make[2]: *** [package/adapter/compile] Error 2
make[2]: Leaving directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686'
make[1]: *** [/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686/staging_dir/target-mips_34kc_musl-1.1.11/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/zy/openwrt/OpenWrt-SDK-ar71xx-generic_gcc-5.2.0_musl-1.1.11.Linux-i686'
make: *** [world] Error 2

以root身份运行make会产生相同的错误。有人可以提出建议吗?谢谢!

1 个答案:

答案 0 :(得分:0)

根据您的信息,我认为错误可能是由/ adapter目录中的Makefile引起的。

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

应该像这样修改:

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

$(CP)是一个变量,在rules.mk中定义 CP:=cp -fpR 所以你可以用它来复制一些东西。