C-跨编译基于Gnulib的项目



我试图将该项目交叉到mingw。

该项目使用自动工具作为构建系统,并取决于Libcurl,Cunit,Jansson和一些Gnulib模块。

我有x86_64-w64-mingw32的所有依赖关系,并在/home/user/mingw64

下安装

我运行:

$ gnulib-tool --update
$ autoreconf -fi
$ CURL_CFLAGS="-I/home/user/mingw64/usr/local/include" 
CURL_LIBS="-L/home/user/mingw64/usr/local/lib -lcurl" 
JANSSON_CFLAGS="-I/home/user/mingw64/usr/local/include" 
JANSSON_LIBS="-L/home/user/mingw64/usr/local/lib -ljansson" 
CUNIT_CFLAGS="-I/home/user/mingw64/usr/local/include" 
CUNIT_LIBS="-L/home/user/mingw64/usr/local/lib -lcunit" 
./configure --host=x86_64-w64-mingw32
$ make

我得到了这个错误:

make  all-recursive
make[1]: Entering directory '/home/user/projects/shill'
Making all in po
make[2]: Entering directory '/home/user/projects/shill/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/user/projects/shill/po'
Making all in lib
make[2]: Entering directory '/home/user/projects/shill/lib'
make[2]: *** No rule to make target 'lib/errno.h', needed by 'all'.  Stop.
make[2]: Leaving directory '/home/user/projects/shill/lib'
Makefile:1897: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/user/projects/shill'
Makefile:1429: recipe for target 'all' failed
make: *** [all] Error 2

errno.h是Gnulib模块的一部分。因此,我认为问题来自makefile.am中的这一部分:

# Find gnulib headers.
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = 
  -DLOCALEDIR='"$(localedir)"' 
  -Ilib -I$(top_srcdir)/lib 
  -Isrc -I$(top_srcdir)/src 

,但我无法弄清楚解决方案。我准确地遵循了Gnulib手册中描述的说明。

我设法找到了这个问题的解决方法。显然autotools并不像我想的那样容易。

  1. 我必须再生gnulib模块,这次指定 --makefile-name参数。即。

    $ gnulib-tool ... --makefile-name=gnulib.mk ...
    
  2. 我从configure.ac中的Automake生成的文件中删除了lib/Makefile。因此,而不是:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
           po/Makefile.in
           lib/Makefile])
    

    现在我有:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
               po/Makefile.in])
    
  3. 我在Makefile.am中删除了libSUBDIRS。IE。而不是:

    # Subdirectories to descend into.
    SUBDIRS = po lib
    

    我有:

    # Subdirectories to descend into.
    SUBDIRS = po
    
  4. 我在lib目录中创建了一个新文件,称为local.mk,此内容:

    include lib/gnulib.mk
    # Allow "make distdir" to succeed before "make all" has run.
    dist-hook: $(noinst_LIBRARIES)
    .PHONY: dist-hook
    
  5. ,并将其包含在Makefile.am

    include $(top_srcdir)/lib/local.mk
    
  6. 最后,我必须运行此命令:

    $ ./build-aux/prefix-gnulib-mk --lib-name=libshill lib/gnulib.mk
    

就是这样。

最新更新