CentOS7升级make

  make官网:Make - GNU Project - Free Software Foundation

  make源码下载地址:Index of /gnu/make

(1).实验环境

  4核8G  CentOS7.9.2009

  配置了阿里云yum源和阿里云epel源,关闭防火墙,关闭SELinux。

(2).yum安装

  CentOS7已于2024年6月30日停止维护,导致官方的软件源(mirrorlist.centos.org)无法访问,所以我们要更换国内的镜像源(例如阿里云或清华源)。

  1、我这里使用阿里云的SCL仓库。

[root@localhost ~]# cd /etc/yum.repos.d/
# 如果有SCL的yum源,则备份原文件(以防万一)
[root@localhost yum.repos.d]# mv CentOS-SCLo-scl.repo CentOS-SCLo-scl.repo.bak 2>/dev/null
[root@localhost yum.repos.d]# mv CentOS-SCLo-scl-rh.repo CentOS-SCLo-scl-rh.repo.bak 2>/dev/null
#创建指向阿里云的SCL的yum源文件
[root@localhost yum.repos.d]# vim CentOS-SCLo-scl.repo
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
 
[root@localhost yum.repos.d]# vim CentOS-SCLo-scl-rh.repo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
 
#下载GPG密钥,这个是官网地址
[root@localhost yum.repos.d]# curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo
#导入密钥到RPM库
[root@localhost yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
#清除缓存并重新加载
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache

  2、yum安装前可以看下阿里云的SCL仓库支持版本:https://mirrors.aliyun.com/centos/7/sclo/x86_64/,make就支持devtoolset-7~devtoolset-11版本。

#安装devtoolset-11版的make
[root@localhost yum.repos.d]# yum -y install devtoolset-11-make

  3、此时还需要激活,否则make还是使用的老版本

[root@localhost yum.repos.d]# make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
#临时激活devtoolset-11软件集合,一旦重启就会失效
#也可以用source /opt/rh/devtoolset-11/enable来进行激活,这个命令写入环境变量就可以持久化
[root@localhost yum.repos.d]# scl enable devtoolset-11 bash
[root@localhost yum.repos.d]# make --version
GNU Make 4.3
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

  4、持久化激活

[root@localhost yum.repos.d]# echo "source /opt/rh/devtoolset-11/enable" >> /etc/profile

(3).源码编译升级

  1、安装依赖包

[root@localhost ~]# yum -y install gcc

  2、编译安装make

[root@localhost ~]# tar zxvf make-4.4.1.tar.gz
[root@localhost ~]# cd make-4.4.1
[root@localhost make-4.4.1]# ./configure --prefix=/usr/local/make-4.4.1
[root@localhost make-4.4.1]# echo $?
0
[root@localhost make-4.4.1]# make -j$(nproc)
[root@localhost make-4.4.1]# echo $?
0
[root@localhost make-4.4.1]# make install
[root@localhost make-4.4.1]# echo $?
0

  3、配置环境变量

[root@localhost make-4.4.1]# echo "export PATH=/usr/local/make-4.4.1/bin${PATH:+:${PATH}}" >> /etc/profile
[root@localhost make-4.4.1]# source /etc/profile

  

posted @ 2026-01-28 16:51  苦逼运维  阅读(0)  评论(0)    收藏  举报