交叉编译samba-3.3.14遇到的错误

错误1

checking that the C compiler understands negative enum values... configure: error: in `/home/floyd.peng/wndr4700-db-buildroot.git/build_dir/target-powerpc_eglibc-2.13/samba':
configure: error: cannot run test program while cross compiling

出现该错误,我们的Makefile中有类似这样的语句

(cd $(PKG_BUILD_DIR)/source;./configure --target="$(ARCH)" --host="$(GNU_TARGET_NAME))

我们需要添加一个环境变量samba_cv_CC_NEGATIVE_ENUM_VALUES到configure中

SAMBA_CONF_ENV:=samba_cv_CC_NEGATIVE_ENUM_VALUES=yes 
(cd $(PKG_BUILD_DIR)/source; $(SAMBA_CONF_ENV) ./configure --target="$(ARCH)" --host="$(GNU_TARGET_NAME))

错误2

Linking bin/smbd
/home/floyd.peng/wndr4700-db-buildroot.git/staging_dir/toolchain-powerpc_gcc-4.5.1_eglibc-2.13/lib/gcc/powerpc-openwrt-linux-gnu/4.5.1/http://www.cnblogs.com/http://www.cnblogs.com/powerpc-openwrt-linux-gnu/bin/ld: cannot find -ltalloc
collect2: ld returned 1 exit status
make[3]: *** [bin/smbd] Error 1

解决办法,将$(PKG_BUILD_DIR)/source/bin中的libtalloc.so和libtalloc.a拷贝到交叉编译器中的lib目录下

错误3

mkdir: cannot create directory `///usr/local/samba': Permission denied
Failed to make directory ///usr/local/samba
make[3]: *** [installdirs] Error 1

通过--prefix指定正确的安装路径

./configure --prefix=/usr

错误4

mkdir: cannot create directory `///usr/lib/vfs': Permission denied
Failed to make directory ///usr/lib/vfs
make[3]: *** [installmodules] Error 

解决方法,在Makefile中的compile模块的$(MAKE)中添加

MODULESDIR="$(PKG_INSTALL_DIR)/usr/lib

附,package/samba下的Makefile参考

include $(TOPDIR)/rules.mk

PKG_NAME:=samba
PKG_VERSION:=3.3.14
PKG_RELEASE:=1

PKG_GIT_TREEISH:=samba-v3.3.14-floyd

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(INCLUDE_DIR)/package.mk

define Package/samba
  SECTION:=net
  CATEGORY:=Network
  TITLE:=SAMBA
  URL:=http://www.samba.org
endef
define Build/Prepare
    test x$(GIT_HOME) != x
    test -d $(GIT_HOME)/samba.git
    (cd $(GIT_HOME)/samba.git; git-cat-file -e $(PKG_GIT_TREEISH))
    (cd $(BUILD_DIR); git-archive --format=tar --prefix=$(PKG_NAME)/ --remote=$(GIT_HOME)/samba.git $(PKG_GIT_TREEISH) | tar -xvf -)
    $(call Build/Patch/Default)
endef

SAMBA_CONF_ENV:=amba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
                samba_cv_USE_SETREUID=yes \
                samba_cv_HAVE_DEVICE_MAJOR_FN=yes \
                samba_cv_HAVE_DEVICE_MINOR_FN=yes \
                samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes \
                samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
                samba_cv_HAVE_IFACE_IFCONF=yes \
                samba_cv_HAVE_MMAP=yes \
                samba_cv_HAVE_FCNTL_LOCK=yes \
                samba_cv_HAVE_SECURE_MKSTEMP=yes \
                samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
                samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes \
                samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
                samba_cv_HAVE_KERNEL_SHARE_MODES=yes \
                samba_cv_HAVE_POSIX_CAPABILITIES=yes \
                samba_cv_HAVE_UNSIGNED_CHAR=yes \
                samba_cv_SIZEOF_DEV_T=yes \
                samba_cv_SIZEOF_INO_T=yes \
                samba_cv_have_longlong=yes \
                samba_cv_fpie=no \
                samba_cv_HAVE_LINUX_SPLICE=yes \
                libreplace_cv_HAVE_GETADDRINFO=yes \
                ac_cv_file__proc_sys_kernel_core_pattern=yes

SAMBA_CONF_ARGS:= --prefix=/usr \
          --disable-cups \
                 --disable-static \
              --enable-shared \
              --enable-shared-libs \
              --disable-pie \
              --disable-relro \
              --disable-dnssd \
              --disable-avahi \
              --disable-fam \
              --disable-swat \
              --without-cluster-support \
              --without-cifsupcall \
              --without-ads \
              --without-ldap \
              --with-included-popt \
              --with-included-iniparser \
              --with-aio-support \
              --with-cifsmount \
              --without-winbind \
              --with-readline

define Build/Configure
    (cd $(PKG_BUILD_DIR)/source; $(SAMBA_CONF_ENV) ./configure --target="$(ARCH)" --host="$(GNU_TARGET_NAME)" $(SAMBA_CONF_ARGS))
endef
define Build/Compile
    rm -rf $(PKG_INSTALL_DIR)
    mkdir -p $(PKG_INSTALL_DIR)
    $(MAKE) -C $(PKG_BUILD_DIR)/source \
                $(TARGET_CONFIGURE_OPTS) \
                CROSS="$(TARGET_CROSS)" \
                CFLAGS="$(TARGET_CFLAGS) -I$(DEP_BUILD_DIR)/include -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
                LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
                CODEPAGEDIR="/usr/share/samba" \
                all
    (cd $(PKG_BUILD_DIR)/source/bin ; \
                mv -f make_smbcodepage.old make_smbcodepage ; touch make_smbcodepage ; \
                mv -f make_unicodemap.old make_unicodemap ; touch make_unicodemap ; \
        );
    mkdir -p $(PKG_INSTALL_DIR)/usr/share/samba
    mkdir -p $(PKG_INSTALL_DIR)/var/log
    $(MAKE) -C $(PKG_BUILD_DIR)/source \
                BASEDIR="$(PKG_INSTALL_DIR)/usr" \
                BINDIR="$(PKG_INSTALL_DIR)/usr/bin" \
                SBINDIR="$(PKG_INSTALL_DIR)/usr/bin" \
                LIBDIR="$(PKG_INSTALL_DIR)/usr/lib" \
             MODULESDIR="$(PKG_INSTALL_DIR)/usr/lib" \
             LOCALEDIR="$(PKG_INSTALL_DIR)/usr/share/locale" \
                VARDIR="$(PKG_INSTALL_DIR)/var/log/samba" \
                MANDIR="$(PKG_INSTALL_DIR)/usr/share/man" \
                CONFIGDIR="$(PKG_INSTALL_DIR)/etc/samba" \
                PRIVATEDIR="$(PKG_INSTALL_DIR)/etc/samba" \
                SWATDIR="$(PKG_INSTALL_DIR)/usr/swat" \
                LOCKDIR="$(PKG_INSTALL_DIR)/var/run/samba" \
                SAMBABOOK="$(PKG_INSTALL_DIR)/usr/swat/using_samba" \
                CODEPAGEDIR="$(PKG_INSTALL_DIR)/usr/share/samba" \
                install
endef

define Package/samba/install
    install -d -m0755 $(1)/usr/sbin
    install -d -m0755 $(1)/usr/bin
    install -m0755 $(PKG_BUILD_DIR)/source/bin/smbpasswd $(1)/usr/bin/smbpasswd
    install -d -m0755 $(1)/usr/sbin
    install -m0755 $(PKG_BUILD_DIR)/source/bin/smbd $(1)/usr/sbin/smbd
    install -m0755 $(PKG_BUILD_DIR)/source/bin/nmbd $(1)/usr/sbin/nmbd
    install -d -m0755 $(1)/usr/share/samba
    install -d -m0755 $(1)/etc/modules.d
    install -m0755 ./files/50-samba-mod $(1)/etc/modules.d/
endef
$(eval $(call BuildPackage,samba))
posted @ 2012-11-23 08:31  Ray.floyd  阅读(4090)  评论(0编辑  收藏  举报