美文网首页
Ubuntu 16.04安装使用GNU GLOBAL 阅读lin

Ubuntu 16.04安装使用GNU GLOBAL 阅读lin

作者: Wood木木 | 来源:发表于2020-12-17 14:30 被阅读0次

    Ubuntu 16.04安装使用GNU GLOBAL

    最近想看Linux内核代码,本来想搭建一个LXR服务器。结果搜了网上的教程,看了官方的文档,配置了好半天,apache一直提示403 Forbidden错误。万念俱灰之下想到之前的公司里好像是用GNU GLOBAL搭建的服务器。遂百度之。发现搭建GLOBAL比LXR简单的多,而且同样功能强大,适合个人或者小团队阅读代码。既然LXR这条路走不通,那咱就换条路走走。果断用GLOBAL替代LXR。

    Ubuntu的apt-get自带GLOBAL,可惜版本是 5.7.1版有点老。为了与时俱进,下载官方最新版手动安装。

    安装

    安装编译依赖的库:

    sudo apt build-dep global
    sudo apt install libncurses5-dev libncursesw5-dev
    

    移驾至 gnu global官方下载最新的 tar包并解开。

    ./configure --with-sqlite3   #gtags可以使用Sqlite3作为数据库,在编译时需要加这个参数
    make -j4     #四线程并行编译
    make check
    sudo make install
    sudo make install check
    

    安装完成

    假定接下来我们要生成Linux Kernel的解析html。

    执行

    git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
    

    当然也可以直接下载linux kernel tar包到本地后解压缩。

    进入Linux Kernel所在的目录

    执行

    gtags –v    #生成tag文件。
    

    当然,也可以加上--sqlite3参数,下面是—help给出的参数帮助信息。

          Use Sqlite 3 API to make tag files. By default, BSD/DB 1.85 API is used.
          To use this option, you need to invoke configure script with
          --with-sqlite3 in the build phase.
    

    tag文件生成后,执行 htags命令生成HTML文件

    htags -DfFnva -t '这里填入你想要的主页title'
    

    然后我很傻很天真的又安装了一遍apache,把整个目录mv到了/var/www/html/下面。

    打开主页,发现成功了,进行serach,发现显示perl代码[图片上传失败...(image-e1b2bc-1608186514616)]

    各种设置后,发现在/cgi-bin/global.cgi文件里,最上面有这么一段话。

    #! /usr/bin/perl
    #------------------------------------------------------------------
    # YOU ARE COMING TO THE DESTINATION ALMOST.PLEASE DO A LITTLE EFFORT.
    #
    # How to setup search form of htags
    # =================================
    #
    # You should start HTTP server so that thisscript is executed as a CGI script.
    # Setup procedure for it depends on theHTTP server which you are using.
    #
    # Use of htags-server(1) is recommended.It's simple.
    #      $ htags -Df
    #      $ htags-server
    #      Please access at http://127.0.0.1:8000
    #      Python2 http/cgi server
    #      Serving HTTP on 127.0.0.1 port 8000 ...
    # You can see the output of htags through'http://127.0.0.1:8000'.
    #
    # If you are using Apache, 'HTML/.htaccess'might be helpful for you.
    #------------------------------------------------------------------
    

    GLOBAL很良心的自带了web server组件,这简直太省事了。如果你要用Apache的话,'HTML/.htaccess' 可能会对你有帮助。我觉得这句话后面可以加一个“呵呵”。

    安装python或者ruby,这里我选python、

    sudo apt install python
    

    如果直接运行htags-server,我发现外网无法访问我的GLOBAL web服务器,看了下帮助文件,执行以下代码:

    htags-server –b ip地址 端口号
    

    如果不填端口号,默认端口8000,如果你要在80端口打开服务,好像要sudo,否则报错,不知何故。

    更多帮助信息,请参考—help或查阅官方文档。

    </article>

    相关文章

      网友评论

          本文标题:Ubuntu 16.04安装使用GNU GLOBAL 阅读lin

          本文链接:https://www.haomeiwen.com/subject/sorzgktx.html