make命令应用
创始人
2024-02-20 23:26:49
0

记录: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=DIRECTORYChange to DIRECTORY before doing anything.-d                          Print lots of debugging information.--debug[=FLAGS]             Print various types of debugging information.-e, --environment-overridesEnvironment variables override makefiles.--eval=STRING               Evaluate STRING as a makefile statement.-f FILE, --file=FILE, --makefile=FILERead FILE as a makefile.-h, --help                  Print this message and exit.-i, --ignore-errors         Ignore errors from recipes.-I DIRECTORY, --include-dir=DIRECTORYSearch 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, --reconDon't actually run any recipe; just print them.-o FILE, --old-file=FILE, --assume-old=FILEConsider 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, --stopTurns 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=FILEConsider 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 

以上,感谢。

2022年11月27日

相关内容

热门资讯

中证A500ETF摩根(560... 8月22日,截止午间收盘,中证A500ETF摩根(560530)涨1.19%,报1.106元,成交额...
A500ETF易方达(1593... 8月22日,截止午间收盘,A500ETF易方达(159361)涨1.28%,报1.104元,成交额1...
何小鹏斥资约2.5亿港元增持小... 每经记者|孙磊    每经编辑|裴健如 8月21日晚间,小鹏汽车发布公告称,公司联...
中证500ETF基金(1593... 8月22日,截止午间收盘,中证500ETF基金(159337)涨0.94%,报1.509元,成交额2...
中证A500ETF华安(159... 8月22日,截止午间收盘,中证A500ETF华安(159359)涨1.15%,报1.139元,成交额...
科创AIETF(588790)... 8月22日,截止午间收盘,科创AIETF(588790)涨4.83%,报0.760元,成交额6.98...
创业板50ETF嘉实(1593... 8月22日,截止午间收盘,创业板50ETF嘉实(159373)涨2.61%,报1.296元,成交额1...
港股异动丨航空股大幅走低 中国... 港股航空股大幅下跌,其中,中国国航跌近7%表现最弱,中国东方航空跌近5%,中国南方航空跌超3%,美兰...
电网设备ETF(159326)... 8月22日,截止午间收盘,电网设备ETF(159326)跌0.25%,报1.198元,成交额409....
红利ETF国企(530880)... 8月22日,截止午间收盘,红利ETF国企(530880)跌0.67%,报1.034元,成交额29.0...