為什麼 Ruby 的設定腳本偵測不到我的執行檔和頭檔?

為什麼 Ruby 的設定腳本偵測不到我的執行檔和頭檔?

我正在嘗試編譯 Ruby,並真正了解這樣做時發生的情況。我Makefiles以前使用過並編寫過,但沒有autoconf使用過 的configure.in文件,所以也許我得到的結果是設計使然的:

$ git clone https://github.com/ruby/ruby.git
...
$ cd ruby
$ git clean -fdx
$ autoconf 
$ ./configure
...
checking for dot... no
checking for doxygen... no
checking for pkg-config... no
...
checking direct.h usability... no
checking direct.h presence... no
checking for direct.h... no
...
checking for daemon... (cached) no

然而,所有這些至少都已安裝:

$ dot -V
dot - graphviz version 2.26.3 (20100126.1600)
$ doxygen --version
1.7.4
$ pkg-config --version
0.26
$ sudo updatedb
$ locate /direct.h
/usr/src/linux-headers-3.0.0-16-generic/include/config/pci/direct.h
/usr/src/linux-headers-3.0.0-17-generic/include/config/pci/direct.h
$ daemon --version
daemon-0.6.4

我意識到每個問題可能都有不同的原因,但是為什麼腳本沒有偵測到它們configure

我正在運行帶有最新補丁的 Ubuntu 11.10。

$ uname -a
Linux username 3.0.0-17-generic #30-Ubuntu SMP Thu Mar 8 20:45:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

嘗試過另一台主機。從config.log

configure:6408: checking for dot
configure:6424: found /usr/bin/dot
configure:6438: result: no
configure:6445: checking for doxygen
configure:6461: found /usr/bin/doxygen
configure:6475: result: no
configure:6483: checking for pkg-config
configure:6504: found /usr/bin/pkg-config
configure:6530: result: no

什麼?找到了,但還是沒去?

configure:11880: checking direct.h usability
configure:11880: gcc -c  -O3 -ggdb    conftest.c >&5
conftest.c:135:20: fatal error: direct.h: No such file or directory
compilation terminated.
configure:11880: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
...
| #endif
| #include <direct.h>
configure:11880: result: no
configure:11880: checking direct.h presence
configure:11880: gcc -E  conftest.c
conftest.c:102:20: fatal error: direct.h: No such file or directory
compilation terminated.
configure:11880: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| /* end confdefs.h.  */
| #include <direct.h>
configure:11880: result: no
configure:11880: checking for direct.h
configure:11880: result: no

時髦的測試腳本 - 也許它需要位於某種預設路徑中?

configure:15175: checking for daemon
configure:15175: result: no

結果這不是檢查可執行文件,而是檢查使用的 C 函數AC_CHECK_FUNCS

答案1

我對 Ruby 幾乎一無所知。不過,我確實對建置系統有相當多的了解。我會在這裡竭盡全力提出建議你在 Ruby 建置系統中發現了一個真正的錯誤

這是我的推理:

  1. 我在完全不同的系統(甚至 Cygwin/Windows 7)上得到了與您相同的結果,都使用您指定的 git 儲存庫和庫存 Ruby 1.9 原始碼

  2. 你之所以能看到found: /usr/bin/dot你的,configure.log 是因為它確實在路上找到了它。這在生成的腳本中很容易看到configure,特別是如果您將其第一行修改為#!/bin/sh -x獲取 shell 偵錯輸出:

    + test -z /bin
    + for ac_exec_ext in ''\'''\''' '$ac_executable_extensions'
    + test -f /bin/dot
    + test -x /bin/dot
    + ac_cv_prog_DOT=
    + printf '%s\n' 'configure:6424: found /bin/dot'
    + break 2
    + IFS='     
    
  3. 您看到的原因result: no是,正如您在上面的程式碼片段中看到的那樣,ac_cv_prog_DOT被設定為空字串,並且配置中的以下行僅反映了該缺失值:

    + DOT=
    + test -n ''
    + printf '%s\n' 'configure:6438: result: no'
    + printf '%s\n' no
    no
    
  4. 設定為空字串的原因是(這就是問題的關鍵)configure.in在第 371 行指定了空字串:

    AC_CHECK_PROG(DOT, dot)
    AC_CHECK_PROG(DOXYGEN, doxygen)
    

    我相信這是對 AC_CHECK_PROG 巨集的錯誤調用,GNU Autoconf 文檔指定拍攝次數必需的參數,不是兩個:

    ― Macro: AC_CHECK_PROG (variable, prog-to-check-for, value-if-found, [value-if-not-found], [path = ‘$PATH’], [reject])
    
    Check whether program prog-to-check-for exists in path. If it
    is found, set variable to value-if-found, otherwise to
    value-if-not-found, if given. Always pass over reject (an
    absolute file name) even if it is the first found in the search
    path; in that case, set variable using the absolute file name
    of the prog-to-check-for found that is not reject. If variable
    was already set, do nothing. Calls AC_SUBST for variable. The
    result of this test can be overridden by setting the variable
    variable or the cache variable ac_cv_prog_variable.
    

    沒有預設值。保留它實際上意味著“如果找到點,則將 DOT 設為空字串”

  5. 我相信犯這個錯誤的原因是因為該行的原始定義使用了不同的宏, AC_CHECK_TOOL只需要兩個參數。

    2010 年 11 月 11 日簽入 svn.ruby-lang.org

    AC_CHECK_TOOL 變成 AC_CHECK_PROG

  6. 這可能已經被破壞了一段時間,並且一些 ChangeLog 評論似乎表明他們在 方面遇到了麻煩DOXYGEN,例如:

    Fri Mar 26 19:55:41 2010  Akinori MUSHA  <[email protected]>
    
        * Makefile.in (DOXYGEN): Define a missing variable DOXYGEN.  Build
          has been failing when doxygen(1) is found by configure but the
          variable is not defined by the system and make(1) does not allow
          an empty command. ("@$(DOXYGEN)" was the cause)
    

最後,我可能全都錯了。但我很確定 configure正在找到這些工具,並且已指示將相應的 Makefile 變數設為空字串。

很想聽聽其他人對這項分析的看法。

相關內容