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

记录: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日

相关内容

热门资讯

美股收盘:三大指数集体收涨 纳... 财联社12月20日讯(编辑 夏军雄)美东时间周五,在甲骨文和英伟达走强的带动下,人工智能(AI)概念...
贵阳有轨电车T2线主体硬件基本... 转自:贵州日报 本报讯(记者 冷赛楠)近日,“天眼问政”栏目收到网友留言:贵阳有轨电车T2线从比亚迪...
大山“用水三变” 转自:贵州日报 “以前靠山上小水源灌田,纯靠天吃饭。现在水龙头就在边上,要浇地直接打开就行。”69岁...
危房抢险施工公告 转自:贵州日报 贵阳市云岩区鸿雁巷17、19、20号及弯弓街6号住户:为消除贵阳市云岩区鸿雁巷17、...
“请3休8”带旺元旦假期云南旅...   本报讯 首席记者李思凡报道 “请3休8”带旺元旦游。12月19日,飞猪发布的数据显示,2026年...