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

Abd*_*ADI 7 c autotools cross-compiling gnulib

我正在尝试将此项目交叉编译为MinGW.

该项目使用autotools作为构建系统,并依赖于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
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

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
Run Code Online (Sandbox Code Playgroud)

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 \
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚解决方案.我完全按照gnulib手册中的说明进行操作.

Abd*_*ADI 5

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

  1. 我必须重新生成gnulib模块,这次指定 --makefile-name参数。IE。

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

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
           po/Makefile.in
           lib/Makefile])
    
    Run Code Online (Sandbox Code Playgroud)

    我现在有:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
               po/Makefile.in])
    
    Run Code Online (Sandbox Code Playgroud)
  3. 我删除了中的lib表格。IE。代替:SUBDIRSMakefile.am

    # Subdirectories to descend into.
    SUBDIRS = po lib
    
    Run Code Online (Sandbox Code Playgroud)

    我有:

    # Subdirectories to descend into.
    SUBDIRS = po
    
    Run Code Online (Sandbox Code Playgroud)
  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
    
    Run Code Online (Sandbox Code Playgroud)
  5. 并将其包含在Makefile.am.

    include $(top_srcdir)/lib/local.mk
    
    Run Code Online (Sandbox Code Playgroud)
  6. 最后我不得不运行这个命令:

    $ ./build-aux/prefix-gnulib-mk --lib-name=libshill lib/gnulib.mk
    
    Run Code Online (Sandbox Code Playgroud)

就是这样。