2016-11-29 96 views
7

我想將此project交叉編譯到MinGW。將基於gnulib的項目交叉編譯到MinGW

該項目使用autotools作爲構建系統,取決於libcurlCUnit,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 manual中描述的說明。

+1

在一些Makefile中有一行像'all:... lib/errno.h ...'(或者是一個在變量替換後展開的行),這是你的問題的近因。 –

+0

@RossRidge所有的'Makefile's都是由autotools自動生成的,所以即使我能找到錯誤並修復它,也是行不通的。 'Makefile'將被重新生成並覆蓋修復。 –

+0

所以修改源代碼來修復它。 –

回答

3

我設法找到解決此問題的解決方法。顯然autotools並不像我想的那麼容易。

  1. 我不得不再生gnulib模塊,這次指定 --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. Makefile.am刪除lib形式SUBDIRS。即。相反的:

    # 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 
    

就是這樣。

+0

做得好,開始在Stackoverflow上!很花時間在這裏記錄什麼對你有用,繼續保持! –