将基于gnulib的项目交叉编译到MinGW

时间:2016-11-29 16:32:10

标签: c cross-compiling autotools gnulib

我正在尝试将此project交叉编译为MinGW。

该项目使用autotools作为构建系统,并依赖于libcurlCUnitJansson和一些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 manual中描述的说明。

1 个答案:

答案 0 :(得分:3)

我设法找到了解决此问题的方法。显然autotools并不像我想象的那么容易。

  1. 我不得不重新生成gnulib个模块,这次指定了。{li>

    --makefile-name参数。即

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

    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. 我在lib中删除了SUBDIRS表单Makefile.am。即。而不是:

    # 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
    
  7. 就是这样。