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

9
我正在尝试将这个项目交叉编译到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手册中描述的指示进行了操作。


1
在某些Makefile中,可能会有一行代码像这样:all: ... lib/errno.h ...(或者是在变量替换后扩展得到的那样),这可能是造成问题的直接原因。 - Ross Ridge
1
@RossRidge 所有的 Makefile 都是由 autotools 自动产生的,因此即使我能找到错误并修复它,也不会起作用。Makefile 将被重新生成并覆盖修复操作。 - Abdelhakim AKODADI
通过修改源代码来修复它。 - Ross Ridge
不好意思,我无法帮助你,因为我没有源代码。 - Ross Ridge
1
@RossRidge 所有的源代码都可以在 Github 上获取。 - Abdelhakim AKODADI
显示剩余3条评论
1个回答

5

我成功地找到了解决这个问题的方法。显然,autotools并不像我想象的那么简单。

  1. I had to regenerate gnulib modules, this time specifying the --makefile-name parameter. ie.

    $ gnulib-tool ... --makefile-name=gnulib.mk ...
    
  2. I removed lib/Makefile from automake generated files in configure.ac. So instead of:

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

    Now I have:

    dnl Put automake generated files results here
    AC_CONFIG_FILES([Makefile
               po/Makefile.in])
    
  3. I removed lib form SUBDIRS in Makefile.am. ie. Instead of:

    # Subdirectories to descend into.
    SUBDIRS = po lib
    

    I have:

    # Subdirectories to descend into.
    SUBDIRS = po
    
  4. I created a new file in lib directory called local.mk with this content:

    include lib/gnulib.mk
    
    # Allow "make distdir" to succeed before "make all" has run.
    dist-hook: $(noinst_LIBRARIES)
    .PHONY: dist-hook
    
  5. And included it in Makefile.am.

    include $(top_srcdir)/lib/local.mk
    
  6. Finally I had to run this command:

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

就是这样了。


做得好,Stackoverflow上的一个良好开端!你花时间在这里记录下对你有用的内容真是太棒了。继续保持! - Prof. Falken

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接