百度小程序可以根据网站的要求做吗,网站建设评分细则,电子商务网站建设专业主修课程,wordpress子主题命名Linux运维_Bash脚本_编译安装GNU-Tools
Bash (Bourne Again Shell) 是一个解释器#xff0c;负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件#xff0c;并于 1989 年发布的免费软件#xff0c;作为 Sh (Bourne Shell) 的替代品。
您可以在 Linux 和 …Linux运维_Bash脚本_编译安装GNU-Tools
Bash (Bourne Again Shell) 是一个解释器负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件并于 1989 年发布的免费软件作为 Sh (Bourne Shell) 的替代品。
您可以在 Linux 和 MacOS 机器上使用 Bash甚至可以通过适用于 Linux 的 Windows 子系统在 Windows 10 机器上使用。
使用方法
下载源码包:
pkg-config-0.29.2.tar.gz
m4-1.4.18.tar.gz
autoconf-2.69.tar.gz
automake-1.15.tar.gz
libtool-2.4.6.tar.gz
gettext-0.22.4.tar.xz
flex-2.6.4.tar.gz
bison-3.7.5.tar.gz
libiconv-1.14.tar.gz
make-4.3.tar.gz
放于指定路径:
这里 Bash Shell 脚本的全局变量 STORAGE 指定的存放源码包的路径 /home/goufeng 可进行修改。
执行 Bash Shell 脚本:
输入 /[路径名]/[脚本名].sh 即可进行自动编译部署过程中提示输入 (y/n) 输入 y 则进行下一步这样分阶段确认的原因是为了确保能够看到上一个源码编译结果中可能的错误和提示。
完整脚本
#! /bin/bash
# Create By GF 2024-03-02 14:41# ------------------- PKG-Config -------------------
# Need File: pkg-config-0.29.2.tar.gz
# ---------------------- Flex ----------------------
# Need File: m4-1.4.18.tar.gz
# Need File: autoconf-2.69.tar.gz
# Need File: automake-1.15.tar.gz
# Need File: libtool-2.4.6.tar.gz
# Need File: gettext-0.22.4.tar.xz
# Need File: flex-2.6.4.tar.gz
# ---------------------- Bison ---------------------
# Need File: bison-3.7.5.tar.gz
# -------------------- libiconv --------------------
# Need File: libiconv-1.14.tar.gz
# -------------------- GNU Make --------------------
# Need File: make-4.3.tar.gz# ##################################################
STORAGE/home/goufeng# ######################################### PKG-Config ################################################ Function: 编译安装(Compile Install) pkg-config-0.29.2
# ##################################################
function Compile_Install_pkg_config_0_29_2() {if [[ ! -f /usr/bin/pkg-config ! -f /usr/local/bin/pkg-config ! -d /opt/pkg-config-0.29.2 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( pkg-config-0.29.2 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/pkg-config-0.29.2.tar.gz STEP_UNZIPPED1# ------------------------------------------cd $STORAGE/pkg-config-0.29.2 ./configure --prefix/opt/pkg-config-0.29.2 \--with-internal-glib \STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenln -sf /opt/pkg-config-0.29.2/bin/pkg-config /usr/local/bin/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/pkg-config-0.29.2 return 0elseecho [Caution] Program: ( /usr/bin/pkg-config or /usr/local/bin/pkg-config or /opt/pkg-config-0.29.2 ) Already Exists.# ------------------------------------------return 0fi
}# ############################################ Flex ################################################### Function: 编译安装(Compile Install) m4-1.4.18 (for GCC-7.5.0)
# ##################################################
function Compile_Install_m4_1_4_18_for_GCC_7_5_0() {if [[ ! -f /usr/bin/m4 ! -f /usr/local/bin/m4 ! -d /opt/m4-1.4.18 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( m4-1.4.18 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/m4-1.4.18.tar.gz STEP_UNZIPPED1# ------------------------------------------if [[ $STEP_UNZIPPED 1 ]]; then# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: patch 方法.# cd /opt/m4-1.4.18# patch -p1 /opt/0003-c-stack-stop-using-SIGSTKSZ.patch# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 1).# m4-1.4.18/lib/c-stack.c# #if ! HAVE_STACK_T ! defined stack_t# typedef struct sigaltstack stack_t;# #endif# -#ifndef SIGSTKSZ# -# define SIGSTKSZ 16384# -#elif HAVE_LIBSIGSEGV SIGSTKSZ 16384# -/* libsigsegv 2.6 through 2.8 have a bug where some architectures use# - more than the Linux default of an 8k alternate stack when deciding# - if a fault was caused by stack overflow. */# -# undef SIGSTKSZ# -# define SIGSTKSZ 16384# -#endif# /* Storage for the alternate signal stack.# 64 KiB is not too large for Gnulib-using apps, and is large enough# for all known platforms. Smaller sizes may run into trouble.# For example, libsigsegv 2.6 through 2.8 have a bug where some# architectures use more than the Linux default of an 8 KiB alternate# stack when deciding if a fault was caused by stack overflow. */# static max_align_t alternate_signal_stack[(64 * 1024# sizeof (max_align_t) - 1)# / sizeof (max_align_t)];sed -i 53,61d $STORAGE/m4-1.4.18/lib/c-stack.csed -i 53i\\/\* Storage for the alternate signal stack\. $STORAGE/m4-1.4.18/lib/c-stack.csed -i 54i\ 64 KiB is not too large for Gnulib\-using apps\, and is large enough $STORAGE/m4-1.4.18/lib/c-stack.csed -i 55i\ for all known platforms\. Smaller sizes may run into trouble\. $STORAGE/m4-1.4.18/lib/c-stack.csed -i 56i\ For example, libsigsegv 2\.6 through 2\.8 have a bug where some $STORAGE/m4-1.4.18/lib/c-stack.csed -i 57i\ architectures use more than the Linux default of an 8 KiB alternate $STORAGE/m4-1.4.18/lib/c-stack.csed -i 58i\ stack when deciding if a fault was caused by stack overflow\. \*\/ $STORAGE/m4-1.4.18/lib/c-stack.csed -i 59i\static max_align_t alternate_signal_stack\[\(64 \* 1024 $STORAGE/m4-1.4.18/lib/c-stack.csed -i 60i\ \ sizeof \(max_align_t\) \- 1\) $STORAGE/m4-1.4.18/lib/c-stack.csed -i 61i\ \/ sizeof \(max_align_t\)\]\; $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 2).# m4-1.4.18/lib/c-stack.c# -/* Storage for the alternate signal stack. */# -static union# -{# - char buffer[SIGSTKSZ];# -# - /* These other members are for proper alignment. Theres no# - standard way to guarantee stack alignment, but this seems enough# - in practice. */# - long double ld;# - long l;# - void *p;# -} alternate_signal_stack;sed -i 131,142d $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 3).# m4-1.4.18/lib/c-stack.c# /* Always install the overflow handler. */# if (stackoverflow_install_handler (overflow_handler,# - alternate_signal_stack.buffer,# - sizeof alternate_signal_stack.buffer))# alternate_signal_stack,# sizeof alternate_signal_stack))sed -i 196,197d $STORAGE/m4-1.4.18/lib/c-stack.csed -i 196i\ alternate_signal_stack\, $STORAGE/m4-1.4.18/lib/c-stack.csed -i 197i\ sizeof alternate_signal_stack\)\) $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 4).# m4-1.4.18/lib/c-stack.c# stack_t st;# struct sigaction act;# st.ss_flags 0;# st.ss_sp alternate_signal_stack;# st.ss_size sizeof alternate_signal_stack;sed -i 270i\ st\.ss_sp \ alternate_signal_stack\; $STORAGE/m4-1.4.18/lib/c-stack.csed -i 271i\ st\.ss_size \ sizeof alternate_signal_stack\; $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 5).# m4-1.4.18/lib/c-stack.c# # if SIGALTSTACK_SS_REVERSED# /* Irix mistakenly treats ss_sp as the upper bound, rather than# lower bound, of the alternate stack. */# - st.ss_sp alternate_signal_stack.buffer SIGSTKSZ - sizeof (void *);# - st.ss_size sizeof alternate_signal_stack.buffer - sizeof (void *);# -# else# - st.ss_sp alternate_signal_stack.buffer;# - st.ss_size sizeof alternate_signal_stack.buffer;# st.ss_size - sizeof (void *);# char *ss_sp st.ss_sp;# st.ss_sp ss_sp st.ss_size;# # endifsed -i 275,279d $STORAGE/m4-1.4.18/lib/c-stack.csed -i 275i\ st\.ss_size \-\ sizeof \(void \*\)\; $STORAGE/m4-1.4.18/lib/c-stack.csed -i 276i\ char \*ss_sp \ st\.ss_sp\; $STORAGE/m4-1.4.18/lib/c-stack.csed -i 277i\ st\.ss_sp \ ss_sp \ st\.ss_size\; $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token (# - Solve: sed 方法 (Part 6).# m4-1.4.18/lib/c-stack.h# ACTION must be async-signal-safe. ACTION together with its callees# - must not require more than SIGSTKSZ bytes of stack space. Also,# must not require more than 64 KiB bytes of stack space. Also,# ACTION should not call longjmp, because this implementation does# not guarantee that it is safe to return to the original stack.sed -i 37d $STORAGE/m4-1.4.18/lib/c-stack.hsed -i 37i\ must not require more than 64 KiB bytes of stack space\. Also\, $STORAGE/m4-1.4.18/lib/c-stack.h# ......................................# * Problem: -freadahead.c: In function ‘freadahead’# - Solve: sed -i s/IO_ftrylockfile/IO_EOF_SEEN/ /opt/m4-1.4.18/lib/*.c# echo #define _IO_IN_BACKUP 0x100 /opt/m4-1.4.18/lib/stdio-impl.hcd $STORAGE/m4-1.4.18 sed -i s/IO_ftrylockfile/IO_EOF_SEEN/ ./lib/*.ccd $STORAGE/m4-1.4.18 echo #define _IO_IN_BACKUP 0x100 ./lib/stdio-impl.hfi# ------------------------------------------cd $STORAGE/m4-1.4.18 ./configure --prefix/opt/m4-1.4.18 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenln -sf /opt/m4-1.4.18/bin/m4 /usr/local/bin/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/m4-1.4.18 return 0elseecho [Caution] Program: ( /usr/bin/m4 or /usr/local/bin/m4 or /opt/m4-1.4.18 ) Already Exists.# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) autoconf-2.69
# ##################################################
function Compile_Install_autoconf_2_69() {if [[ ! -f /usr/bin/autoconf ! -f /usr/local/bin/autoconf ! -d /opt/autoconf-2.69 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( autoconf-2.69 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar -zxvf autoconf-2.69.tar.gz STEP_UNZIPPED1# ------------------------------------------cd $STORAGE/autoconf-2.69 ./configure --prefix/opt/autoconf-2.69 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED0# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/autoconf-2.69/bin/ /usr/local/bin/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/autoconf-2.69 return 0elseecho [Caution] Program: ( /usr/bin/autoconf or /usr/local/bin/autoconf or /opt/autoconf-2.69 ) Already Exists.# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) automake-1.15 (for Ubuntu)
# ##################################################
function Compile_Install_automake_1_15_for_Ubuntu() {if [[ ! -f /usr/bin/automake ! -f /usr/local/bin/automake ! -d /opt/automake-1.15 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( automake-1.15 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar -zxvf automake-1.15.tar.gz STEP_UNZIPPED1if [[ $STEP_UNZIPPED 1 ]]; then# * Problem: Makefile:3687: recipe for target doc/automake-1.15.1 failed# - Solve: sed -i s/\$\(update_mans\) automake\-\$\(APIVERSION\)/\$\(update_mans\) automake\-\$\(APIVERSION\) \-\-no\-discard\-stderr/ /opt/automake-1.15/Makefilesed -i s/\$\(update_mans\) automake\-\$\(APIVERSION\)/\$\(update_mans\) automake\-\$\(APIVERSION\) \-\-no\-discard\-stderr/ $STORAGE/automake-1.15/Makefile# ......................................# * Problem: Unescaped left brace in regex is illegal here in regex; marked by -- HERE in m/\${ -- HERE ([^ \t:{}])}/ at /usr/local/bin/automake line 3936.# - Solve: 按照提示行数, 将第一个遇到的 { 用 [ ] 括住.# automake-1.15/bin/automake.in# my ($text) _;# - $text ~ s/\${([^ \t:{}])}/substitute_ac_subst_variables_worker ($1)/ge;# $text ~ s/\$[{]([^ \t:{}])}/substitute_ac_subst_variables_worker ($1)/ge;# return $text;sed -i 3881d $STORAGE/automake-1.15/bin/automake.insed -i 3881i\ \$text ~ s/\\\\$\[\{\]\(\[\^ \\\t\\:\\{\}\]\\)\}/substitute_ac_subst_variables_worker \(\$1\)/ge; $STORAGE/automake-1.15/bin/automake.infi# ------------------------------------------cd $STORAGE/automake-1.15 ./configure --prefix/opt/automake-1.15 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED0# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/automake-1.15/bin/ /usr/local/bin/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/automake-1.15 return 0elseecho [Caution] Program: ( /usr/bin/automake or /usr/local/bin/automake or /opt/automake-1.15 ) Already Exists.# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) libtool-2.4.6
# ##################################################
function Compile_Install_libtool_2_4_6() {# ----------------------------------------------# * Problem: Makefile.am:477: error: Libtool library used but LIBTOOL is undefined# Makefile.am:477: The usual way to define LIBTOOL is to add LT_INIT# Makefile.am:477: to configure.ac and run aclocal and autoconf again.# Makefile.am:477: If LT_INIT is in configure.ac, make sure# Makefile.am:477: its definition is in aclocals search path.# autoreconf: automake failed with exit status: 1# - Solve: 原因是 automake 和 libtool 没有安装在同一目录中, 导致 aclocal 在路径中找不到 .m4 文件。# 解决方法 (1):# 1. 执行 aclocal --print-ac-dir 查看 aclocal 的路径, 例如显示 /opt/automake-1.15/share/aclocal# 2. 将 libtool 的 share/aclocal 目录中的 .m4 文件复制到 /opt/automake-1.15/share/aclocal (cp /opt/libtool-2.4.6/share/aclocal/*.m4 /opt/automake-1.15/share/aclocal/)# 3. 再次执行 autoreconf, 问题解决。# 解决方法 (2):# 1. 确保二进制 bin 文件: aclocal (包含在 automake 中) 和 libtoolize (包含在 libtool 中) 在可找到 PATH 中 (最好是同一路径下)# 2. 先执行 libtoolize, 会在当前目录自动生成要用到的 .m4 文件, 再执行 autoreconf, 问题解决。if [[ ! -f /usr/bin/libtool ! -f /usr/local/bin/libtool ! -d /opt/libtool-2.4.6 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( libtool-2.4.6 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar -zxvf libtool-2.4.6.tar.gz STEP_UNZIPPED1# ------------------------------------------cd $STORAGE/libtool-2.4.6 ./configure --prefix/opt/libtool-2.4.6 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/libtool-2.4.6/bin/ /usr/local/bin/# ......................................cp /opt/libtool-2.4.6/share/aclocal/*.m4 /opt/automake-1.15/share/aclocal/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/libtool-2.4.6 return 0elseecho [Caution] Program: ( /usr/bin/libtool or /usr/local/bin/libtool or /opt/libtool-2.4.6 ) Already Exists.# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) gettext-0.22.4 (for Linux)
# ##################################################
function Compile_Install_gettext_0_22_4_for_Linux() {if [[ ! -f /usr/bin/gettext ! -f /usr/local/bin/gettext ! -d /opt/gettext-0.22.4 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( gettext-0.22.4 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar xvJf $STORAGE/gettext-0.22.4.tar.xz STEP_UNZIPPED1# ------------------------------------------# Must Be Shared (--enable-shared) To Be Called By Other Programs.cd $STORAGE/gettext-0.22.4 ./configure --prefix/opt/gettext-0.22.4 \--enable-shared \STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/gettext-0.22.4/bin/ /usr/local/bin/rsync -av /opt/gettext-0.22.4/include/ /usr/local/include/rsync -av /opt/gettext-0.22.4/lib/ /usr/local/lib/fi# ------------------------------------------ldconfig# ------------------------------------------cd $STORAGE rm -rf $STORAGE/gettext-0.22.4 return 0elseecho [Caution] Program: ( /usr/bin/gettext or /usr/local/bin/gettext or /opt/gettext-0.22.4 ) Already Exists.# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) flex-2.6.4 (for Ubuntu)
# ##################################################
function Compile_Install_flex_2_6_4_for_Ubuntu() {if [[ ! -f /usr/bin/flex ! -f /usr/local/bin/flex ! -d /opt/flex-2.6.4 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( flex-2.6.4 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar -zxvf flex-2.6.4.tar.gz STEP_UNZIPPED1# ------------------------------------------# * Problem: Cant exec autopoint: No such file or directory at /opt/autoconf-2.69/share/autoconf/Autom4te/FileUtils.pm line 345.# autoreconf: failed to run autopoint: No such file or directory# autoreconf: autopoint is needed because this package uses Gettext# - Solve: autopoint 在 gettext 的 bin/ 下面, 但系统原有的 gettext 可能没有 autopoint。# autopoint is located under the bin/ of the gettext, but the original system gettext may not have autopoint. # 备份系统原有的 gettext (mv /usr/bin/gettext /usr/bin/gettext.bak) 并重新编译安装 gettext.# Back up the original system gettext (mv /usr/bin/gettext /usr/bin/gettext.bak) and recompile and install the gettextcd $STORAGE/flex-2.6.4 ./autogen.sh ./configure --prefix/opt/flex-2.6.4 \CFLAGS-D_GNU_SOURCE \STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/flex-2.6.4/bin/ /usr/local/bin/rsync -av /opt/flex-2.6.4/include/ /usr/local/include/rsync -av /opt/flex-2.6.4/lib/ /usr/local/lib/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/flex-2.6.4 return 0elseecho [Caution] Program: ( /usr/bin/flex or /usr/local/bin/flex or /opt/flex-2.6.4 ) Already Exists.# ------------------------------------------return 0fi
}# ############################################### Bison ############################################### Function: 编译安装(Compile Install) bison-3.7.5
# ##################################################
function Compile_Install_bison_3_7_5() {if [[ ! -f /usr/bin/bison ! -f /usr/local/bin/bison ! -d /opt/bison-3.7.5 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( bison-3.7.5 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/bison-3.7.5.tar.gz STEP_UNZIPPED1# ------------------------------------------cd $STORAGE/bison-3.7.5 ./configure --prefix/opt/bison-3.7.5 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/bison-3.7.5/bin/ /usr/local/bin/rsync -av /opt/bison-3.7.5/lib/ /usr/local/lib/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/bison-3.7.5 return 0elseecho [Caution] Program: ( /usr/bin/bison or /usr/local/bin/bison or /opt/bison-3.7.5 ) Already Exists.# ------------------------------------------return 0fi
}# ############################################# libiconv ############################################## Function: 编译安装(Compile Install) libiconv-1.14 (for GCC-7.5.0)
# ##################################################
function Compile_Install_libiconv_1_14_for_GCC_7_5_0() {if [[ ! -f /usr/bin/iconv ! -f /usr/local/bin/iconv ! -d /opt/libiconv-1.14 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( libiconv-1.14 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/libiconv-1.14.tar.gz STEP_UNZIPPED1# ------------------------------------------if [[ $STEP_UNZIPPED 1 ]]; then# * Problem: In file included from progname.c:26:0:# ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?# _GL_WARN_ON_USE (gets, gets is a security hole - use fgets instead);# - Solve: patch 方法.# 1. 把 Patch 补丁拷贝到 libiconv-1.14/srclib (cp libiconv-glibc-2.16.patch libiconv-1.14/srclib)# 2. cd libiconv-1.14/srclib# 3. patch -p1 libiconv-glibc-2.16.patch# ......................................# * Problem: In file included from progname.c:26:0:# ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?# _GL_WARN_ON_USE (gets, gets is a security hole - use fgets instead);# - Solve: sed 方法.# --- srclib/stdio.in.h.orig 2011-08-07 16:42:06.000000000 0300# srclib/stdio.in.h 2013-01-10 15:53:03.000000000 0200# -695,7 695,9 # /* It is very rare that the developer ever has full control of stdin,# so any use of gets warrants an unconditional warning. Assume it is# always declared, since it is required by C89. */# -_GL_WARN_ON_USE (gets, gets is a security hole - use fgets instead);# #if defined(__GLIBC__) !defined(__UCLIBC__) !__GLIBC_PREREQ(2, 16)# _GL_WARN_ON_USE (gets, gets is a security hole - use fgets instead);# #endif# #endifsed -i 698d $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i 698i\\#if defined\(__GLIBC__\) \\ \!defined\(__UCLIBC__\) \\ \!__GLIBC_PREREQ\(2\, 16\) $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i 699i\ _GL_WARN_ON_USE \(gets\, \gets is a security hole \- use fgets instead\\)\; $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i 670i\\#endif $STORAGE/libiconv-1.14/srclib/stdio.in.hfi# ------------------------------------------cd $STORAGE/libiconv-1.14 ./configure --prefix/opt/libiconv-1.14 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenrsync -av /opt/libiconv-1.14/bin/ /usr/local/bin/rsync -av /opt/libiconv-1.14/include/ /usr/local/include/rsync -av /opt/libiconv-1.14/lib/ /usr/local/lib/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/libiconv-1.14 return 0elseecho [Caution] Program: ( /usr/bin/iconv or /usr/local/bin/iconv or /opt/libiconv-1.14 ) Already Exists.# ------------------------------------------return 0fi
}# ############################################# GNU Make ############################################## Function: 编译安装(Compile Install) GNU-Make-4.3
# ##################################################
function Compile_Install_GNU_Make_4_3() {if [[ ! -f /usr/bin/gmake ! -f /usr/local/bin/gmake ! -d /opt/gnu-make-4.3 ]]; thenlocal VERIFYlocal STEP_UNZIPPED0local STEP_CONFIGURED0local STEP_INSTALLED0# ------------------------------------------read -p [Confirm] Compile and Install ( gnu-make-4.3 )? (y/n) VERIFYif [[ $VERIFY ! y ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/make-4.3.tar.gz STEP_UNZIPPED1# ------------------------------------------if [[ $STEP_UNZIPPED 1 ! -f $STORAGE/make-4.3/src/gnumake.h ]]; thenecho [Caution] Source Code: ( make-4.3.tar.gz ) is Not The GNU Make Source Code.# ......................................exit 1fi# ------------------------------------------cd $STORAGE/make-4.3 ./configure --prefix/opt/gnu-make-4.3 STEP_CONFIGURED1# ------------------------------------------make make install STEP_INSTALLED1# ------------------------------------------if [[ $STEP_INSTALLED 1 ]]; thenln -sf /opt/gnu-make-4.3/bin/make /usr/local/bin/gmake# ......................................ln -sf /opt/gnu-make-4.3/include/gnumake.h /usr/local/include/fi# ------------------------------------------cd $STORAGE rm -rf $STORAGE/make-4.3 return 0elseecho [Caution] Program: ( /usr/bin/gmake or /usr/local/bin/gmake or /opt/gnu-make-4.3 ) Already Exists.# ------------------------------------------return 0fi
}function main() {# ----------------- PKG-Config -----------------Compile_Install_pkg_config_0_29_2# -------------------- Flex --------------------Compile_Install_m4_1_4_18_for_GCC_7_5_0Compile_Install_autoconf_2_69Compile_Install_automake_1_15_for_UbuntuCompile_Install_libtool_2_4_6Compile_Install_gettext_0_22_4_for_LinuxCompile_Install_flex_2_6_4_for_Ubuntu# -------------------- Bison -------------------Compile_Install_bison_3_7_5# ------------------ libiconv ------------------Compile_Install_libiconv_1_14_for_GCC_7_5_0# ------------------ GNU Make ------------------Compile_Install_GNU_Make_4_3
}main总结
以上就是关于 Linux运维 Bash脚本 编译安装GNU-Tools 的全部内容。
更多内容可以访问我的代码仓库:
https://gitee.com/goufeng928/public
https://github.com/goufeng928/public