2015-06-25 141 views
6

我有一些爲Linux編寫的C代碼,它依賴於套接字和arpa/inet.h以及libusb.h,並且我想編譯這是MinGW下的Windows。 (請注意,當前的項目只有一個非常簡單的Makefile,根本不依賴於autotools)。在MinGW上開始使用gnulib並且對自動工具不熟悉(足夠)

它看起來像使用gnulib將是一種很好的方式能夠在MinGW下編譯這個Windows,並且我已經開始朝這個方向發展,但是似乎如果你不熟悉你所進入的autotools深的雜草真的很快。

因此,這裏是我已經試過:

$ gnulib-tool --import getsockname,getsockopt,setsockopt,socket,socketlib,sockets,socklen,sys_socket,arpa_inet,inet_ntop,inet_pton,netinet_in 

它運行,並讓我在結束了以下消息:

Don't forget to 
    - add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac, 
    - mention "lib" in SUBDIRS in Makefile.am, 
    - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am, 
    - mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am, 
    - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC, 
    - invoke gl_INIT in ./configure.ac. 

好吧,我沒有configure.ac,也沒有一個Makefile。上午,所以我創造了他們(以上按指令)如下:

$ cat Makefile.am 
SUBDIRS = lib 
ACLOCAL_AMFLAGS = -I m4 
EXTRA_DIST = m4/gnulib-cache.m4 

而且......

$ cat configure.ac 
AC_INIT([configure.ac]) 
AC_CONFIG_FILES([lib/Makefile]) 
AC_PROG_CC 
gl_EARLY 
gl_INIT 

現在,在這一點上,gnulib文檔似乎假設您非常熟悉autotools,因此他們忽略了所有關於下一步需要使用autotools的指示。

從我已經能夠從閱讀各種論壇弄清楚,似乎接下來的步驟是運行:

$ aclocal 
$ autoconf 
$ automake 
$ configure 

但是......當我跑的automake我:

$ automake 
configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found. 
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE, 
configure.ac: that aclocal.m4 is present in the top-level directory, 
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal). 
lib/Makefile.am:30: library used but `RANLIB' is undefined 
lib/Makefile.am:30: The usual way to define `RANLIB' is to add `AC_PROG_RANLIB 

' lib/Makefile.am:30:至configure.ac' and run autoconf'再次。

嗯......這可能只是我在我的Makefile.am中缺少的一些東西(因爲我不完全確定Makefile.am應該怎麼做)...所以回去一步..我應該能夠運行得到了上述在autoconf的步驟中創建的配置文件:通過谷歌搜索周圍好像gl_EARLY和gl_INIT應該由行照顧

$ ./configure 

checking for gcc... gcc 
checking whether the C compiler works... yes 
checking for C compiler default output file name... a.exe 
checking for suffix of executables... .exe 
checking whether we are cross compiling... no 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ISO C89... none needed 
./configure: line 2497: gl_EARLY: command not found 
./configure: line 2498: gl_INIT: command not found 
rm: cannot lstat `conftest.exe': Permission denied 

從我讀過什麼添加到Makefile.am文件(ACLOCAL_AMFLAGS = -I m4),但在這一點上,我不完全確定我正在做這個autotools的一部分。任何人都可以指出我在這裏做錯了嗎?

回答

3
  1. 添加AC_CONFIG_MACRO_DIR([m4])configure.ac,它會在m4目錄中找到gnulib宏
  2. 添加AM_INIT_AUTOMAKE
  3. AC_CONFIG_FILES應該不僅含有gnulib Makefile文件,但是你的Makefile太
  4. 您可以重新生成具有單一通話的所有東西到autoreconf