make命令应用

记录:345

场景:在CentOS 7.9操作系统上,使用make命令编译C语言开发的软件源码;使用make install命令安装软件;解决直接使用C语言源码部署软件的需求。比如部署redis、PostgreSQL数据库等。

版本:

操作系统:CentOS 7.9

Redis版本:redis-6.2.7

1.基础环境

本例使用redis-6.2.7为例,应用make命令。

1.1下载redis-6.2.7.tar.gz

下载地址:http://download.redis.io/releases

下载命令:wget http://download.redis.io/releases/redis-6.2.7.tar.gz

解析:下载完成后,redis-6.2.7.tar.gz包在当前目录。

1.2 配置gcc环境

(1)安装gcc

安装命令:yum  install -y devtoolset-9-gcc devtoolset-9-gcc-c++  devtoolset-9-binutils gcc

(2)配置gcc

内容:echo 'source /opt/rh/devtoolset-9/enable'>>/etc/profile

生效:source /etc/profile

(3)查看gcc版本

命令:gcc --version

打印信息:gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

1.3解压redis-6.2.7.tar.gz

命令:tar -xzvf /home/apps/software/redis-6.2.7.tar.gz -C /home/apps/module/

解析:解压后,Redis相关内容在/home/apps/module/redis-6.2.7。

2.命令应用

(1)编译

编译命令:make -C /home/apps/module/redis-6.2.7

解析:编译redis后,在redis-6.2.7/src目录下生成.o文件、redis-server等文件,生成./deps文件夹。

(2)安装

安装命令:make install PREFIX=/home/apps/module/redis-6.2.7

解析:把redis-6.2.7指定安装在/home/apps/module/redis-6.2.7,会在此目录下生成bin目录,在bin目录下就是安装软件。

(3)清空

清空命令:make clean

解析:使用此命令把编译的内容清空。

(4)查看版本

命令:make -v

解析:查看make的版本,本例:GNU Make 3.82。

3.命令帮助手册

命令:make --help

解析:查看make支持全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.
  --warn-undefined-functions  Warn when an undefined user function is called.

This program built for x86_64-redhat-linux-gnu
Report bugs to <bug-make@gnu.org>

以上,感谢。

2022年11月27日

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值