CentOS编译安装tree1.8.0

CentOS编译安装tree.1.8

安装相关依赖包

[root@centos8 ~]# yum install gcc make

查看当前版本信息

[root@centos8 ~]# yum info tree
Last metadata expiration check: 0:01:52 ago on Sun 20 Dec 2020 09:08:04 PM CST.
Installed Packages
Name         : tree
Version      : 1.7.0
Release      : 15.el8
Architecture : x86_64
Size         : 109 k
Source       : tree-1.7.0-15.el8.src.rpm
Repository   : @System
From repo    : anaconda
Summary      : File system tree viewer
URL          : http://mama.indstate.edu/users/ice/tree/
License      : GPLv2+
Description  : The tree utility recursively displays the contents of directories in a
             : tree-like format.  Tree is basically a UNIX port of the DOS tree
             : utility.

下载源码

[root@centos8 apps]# wget http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz
--2020-12-20 21:11:32--  http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz
Resolving mama.indstate.edu (mama.indstate.edu)... 139.102.70.201
Connecting to mama.indstate.edu (mama.indstate.edu)|139.102.70.201|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50286 (49K) [application/x-gzip]
Saving to: ‘tree-1.8.0.tgz’

tree-1.8.0.tgz               100%[============================================>]  49.11K  26.7KB/s    in 1.8s    

2020-12-20 21:11:34 (26.7 KB/s) - ‘tree-1.8.0.tgz’ saved [50286/50286]

解压缩

[root@centos8 apps]# tar -xf tree-1.8.0.tgz 

查看安装帮助

[root@centos8 apps]# ls
tree-1.8.0  tree-1.8.0.tgz
[root@centos8 apps]# cd tree-1.8.0/
[root@centos8 tree-1.8.0]# ls
CHANGES  doc     hash.c  INSTALL  LICENSE   README        TODO    tree.h  xml.c
color.c  file.c  html.c  json.c   Makefile  strverscmp.c  tree.c  unix.c
[root@centos8 tree-1.8.0]# cat INSTALL 
Installation instructions:

1. Edit the Makefile for your OS.  Comment out the Linux options and un-comment
   the options for your OS.
2. Type: make
3. Type: make install
4. Enjoy colorful directory trees.

  I cannot test on non-Linux machines, so please feel free to contribute
porting information, bug reports, compile options, patches, etc for porting to
other OS's to ice@mama.indstate.edu.

  I would also welcome any localization efforts, particularly translating the
man page to other languages.  And of course feel free to suggest options and
improvements you would like to see in tree.

修改配置文件

[root@centos8 tree-1.8.0]# vim Makefile
prefix = /apps/tree

编译

[root@centos8 tree-1.8.0]# make
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o unix.o unix.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o html.o html.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o xml.o xml.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o json.o json.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o hash.o hash.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o color.o color.c
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o file.o file.c
gcc  -o tree tree.o unix.o html.o xml.o json.o hash.o color.o file.o

安装

[root@centos8 tree-1.8.0]# make install
install -d /apps/tree/bin
install -d /apps/tree/man/man1
if [ -e tree ]; then \
    install tree /apps/tree/bin/tree; \
fi
install doc/tree.1 /apps/tree/man/man1/tree.1

修改PATH

#方法一:新增文件
[root@centos8 bin]# echo 'PATH=/apps/tree/bin:$PATH' > /etc/profile.d/tree.sh
#方法二:软连接
[root@centos8 bin]# ln -s /apps/tree/bin/tree /usr/local/bin

验证

[root@centos8 bin]# hash -d tree
[root@centos8 bin]# tree --version
tree v8.8.8 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro 

添加man帮助

[root@centos8 bin]# man tree
No manual entry for tree
[root@centos8 bin]# vim /etc/man_db.conf
MANDATORY_MANPATH                       /apps/tree/man
[root@centos8 bin]# man tree

运行命令

[root@centos8 bin]# tree /apps/tree/bin
/apps/tree/bin
└── tree

0 directories, 1 file
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容