源码编译PG8.4.1时,需要在安装完几个依赖的开发库后,在源代码目录下运行configure脚本。下面我们就分析一下该名为configure的shell脚本。其主要功能是猜测系统依赖变量的值并创建Makefiles。

一、环境检测

下面的代码是为了照顾zsh这种极品Shell,因为不使用zsh,所以这里不对代码进行分析。这里提一点emulate sh 到底是干什么的呢?Zsh can emulate sh, ksh, or csh. (csh is not fully emulated). zsh does an outstanding job in its sh and ksh emulation. You can start emulating another shell by running emulate some_shell from the command line. If you add the -R flag, all options will be reset to their default values. You can also create a link called ‘csh’, or ‘ksh’, or ‘sh’ that points to zsh. Zsh will notice that it was invoked with a different name, and do its best to behave like the shell you specify.

# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; thenemulate shNULLCMD=:# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which# is contrary to our usage.  Disable this feature.alias -g '${1+"$@"}'='"$@"'setopt NO_GLOB_SUBST
elsecase `(set -o) 2>/dev/null` in*posix*) set -o posix ;;
esac
fi

DUALCASE变量的解释如下linux中特别的Shell变量 DUALCASE
test –n 字符串 —> 判断字符串的长度非零
set -o选项的解释Linux中shell的 set命令 -e -o 选项作用

PATH需要CR,避免依赖于Character Ranges,这里把所有字母和数字列出来。

1 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
2 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
3 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
4 as_cr_digits='0123456789'
5 as_cr_alnum=$as_cr_Letters$as_cr_digits

检测PATH_SEPATATOR,即PATH变量的分隔符为;还是 。

# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; thenecho "#! /bin/sh" >conf$$.shecho  "exit 0"   >>conf$$.shchmod +x conf$$.shif (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; thenPATH_SEPARATOR=';'elsePATH_SEPARATOR=:firm -f conf$$.sh
fi

PATHSEPARATOR+set意思是如果设置了PATHSEPARATOR,则用set置换变量,否则不进行置换.语法:‘变量={PATH_SEPARATOR+set} 意思是如果设置了PATH_SEPARATOR,则用set置换变量,否则不进行置换. 语法 :`变量=PATHS​EPARATOR+set意思是如果设置了PATHS​EPARATOR,则用set置换变量,否则不进行置换.语法:‘变量={参数+word}`:如果设置了参数,则用word置换变量,否则不进行置换.
$$ 当前Shell进程ID。对于 Shell 脚本,就是这些脚本所在的进程ID。
PATH="/nonexistent;." —> 暂时没明白什么意思

在可用的情况下,需要支持unset

1 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
2   as_unset=unset
3 else
4   as_unset=false
5 fi

需要空格,tab,新行以顺序排列,放置编辑器出现关于space-tab兼容性问题。如果调用_AS_PATH_WALK时IFS没有设置,将会通过将IFS设置为空值,关闭word splitting。

1 as_nl='
2 '
3 IFS=" ""    $as_nl"

查找出运行该脚本的用户

# Find who we are.  Look in the path if we contain no directory separator.
case $0 in*[\\/]* ) as_myself=$0 ;;*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
doIFS=$as_save_IFStest -z "$as_dir" && as_dir=.test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS;;
esac

$0当前脚本的文件名

如果没有发现用户,可能是通过sh COMMAND运行的

if test "x$as_myself" = x; thenas_myself=$0
fi
if test ! -f "$as_myself"; thenecho "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2{ (exit 1); exit 1; }
fi

Work around bugs in pre-3.0 UWIN ksh.

for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '

NLS nuisances. 麻烦事 处理语言国际化,还原为默认设置

for as_var in \LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \LC_TELEPHONE LC_TIME
doif (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); theneval $as_var=C; export $as_varelse($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_varfi
done

basename 命令
$ basename /usr/bin/sort 输出"sort"。
$ basename ./include/stdio.h .h 输出"stdio"。
为basename指定一个路径,basename命令会删掉所有的前缀包括最后一个slash(‘/’)字符,然后将字符串显示出来。
basename命令格式:

basename [pathname] [suffix]
basename [string] [suffix]

suffix为后缀,如果suffix被指定了,basename会将pathname或string中的suffix去掉。

# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1 &&test "X`expr 00001 : '.*\(...\)'`" = X001; thenas_expr=expr
elseas_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; thenas_basename=basename
elseas_basename=false
fi

可执行文件的名字

# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \X"$0" : 'X\(//\)$' \| \X"$0" : 'X\(/\)' \| . 2>/dev/null ||
echo X/"$0" |sed '/^.*\/\([^/][^/]*\)\/*$/{s//\1/q}/^X\/\(\/\/\)$/{s//\1/q}/^X\/\(\/\).*/{s//\1/q}s/.*/./; q'`

对系统的命令的测试

if test "x$CONFIG_SHELL" = x; thenif (eval ":") 2>/dev/null; thenas_have_required=yes
elseas_have_required=no
fi
if test $as_have_required = yes &&      (eval ":
(as_func_return () {(exit \$1)
}
as_func_success () {as_func_return 0
}
as_func_failure () {as_func_return 1
}
as_func_ret_success () {return 0
}
as_func_ret_failure () {return 1
}exitcode=0
if as_func_success; then:
elseexitcode=1echo as_func_success failed.
fiif as_func_failure; thenexitcode=1echo as_func_failure succeeded.
fiif as_func_ret_success; then:
elseexitcode=1echo as_func_ret_success failed.
fiif as_func_ret_failure; thenexitcode=1echo as_func_ret_failure succeeded.
fiif ( set x; as_func_ret_success y && test x = \"\$1\" ); then:
elseexitcode=1echo positional parameters were not saved.
fitest \$exitcode = 0) || { (exit 1); exit 1; }(as_lineno_1=\$LINENOas_lineno_2=\$LINENOtest \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
") 2> /dev/null; then
elseas_candidate_shells=as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
doIFS=$as_save_IFStest -z "$as_dir" && as_dir=.case $as_dir in/*)for as_base in sh bash ksh sh5; doas_candidate_shells="$as_candidate_shells $as_dir/$as_base"done;;esac
done
IFS=$as_save_IFSfor as_shell in $as_candidate_shells $SHELL; do# Try only shells that exist, to save several forks.if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&{ ("$as_shell") 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; thenemulate shNULLCMD=:# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which# is contrary to our usage.  Disable this feature.alias -g '${1+"$@"}'='"$@"'setopt NO_GLOB_SUBST
elsecase `(set -o) 2>/dev/null` in*posix*) set -o posix ;;
esacfi:
_ASEOF
}; thenCONFIG_SHELL=$as_shellas_have_required=yesif { "$as_shell" 2> /dev/null <<\_ASEOF
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; thenemulate shNULLCMD=:# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which# is contrary to our usage.  Disable this feature.alias -g '${1+"$@"}'='"$@"'setopt NO_GLOB_SUBST
elsecase `(set -o) 2>/dev/null` in*posix*) set -o posix ;;
esacfi:
(as_func_return () {(exit $1)
}
as_func_success () {as_func_return 0
}
as_func_failure () {as_func_return 1
}
as_func_ret_success () {return 0
}
as_func_ret_failure () {return 1
}exitcode=0
if as_func_success; then:
elseexitcode=1echo as_func_success failed.
fiif as_func_failure; thenexitcode=1echo as_func_failure succeeded.
fiif as_func_ret_success; then:
elseexitcode=1echo as_func_ret_success failed.
fiif as_func_ret_failure; thenexitcode=1echo as_func_ret_failure succeeded.
fiif ( set x; as_func_ret_success y && test x = "$1" ); then:
elseexitcode=1echo positional parameters were not saved.
fitest $exitcode = 0) || { (exit 1); exit 1; }(as_lineno_1=$LINENOas_lineno_2=$LINENOtest "x$as_lineno_1" != "x$as_lineno_2" &&test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }_ASEOF
}; thenbreak
fifidoneif test "x$CONFIG_SHELL" != x; thenfor as_var in BASH_ENV ENVdo ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_vardoneexport CONFIG_SHELLexec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fiif test $as_have_required = no; thenecho This script requires a shell more modern than all theecho shells that I found on your system.  Please install aecho modern shell, or manually run the script under such aecho shell if you do have one.{ (exit 1); exit 1; }
fififi(eval "as_func_return () {(exit \$1)
}
as_func_success () {as_func_return 0
}
as_func_failure () {as_func_return 1
}
as_func_ret_success () {return 0
}
as_func_ret_failure () {return 1
}exitcode=0
if as_func_success; then:
elseexitcode=1echo as_func_success failed.
fiif as_func_failure; thenexitcode=1echo as_func_failure succeeded.
fiif as_func_ret_success; then:
elseexitcode=1echo as_func_ret_success failed.
fiif as_func_ret_failure; thenexitcode=1echo as_func_ret_failure succeeded.
fiif ( set x; as_func_ret_success y && test x = \"\$1\" ); then:
elseexitcode=1echo positional parameters were not saved.
fitest \$exitcode = 0") || {echo No shell found that supports shell functions.echo Please tell autoconf@gnu.org about your system,echo including any error possibly output before thisecho message
}

PostgreSQL数据库源码安装第一步——configure脚本分析(环境检测)相关推荐

  1. 大数据Spark “蘑菇云”行动第103课:Hive源码大师之路第一步:Hive源码思考和解析初体验

    大数据Spark "蘑菇云"行动第103课:Hive源码大师之路第一步:Hive源码思考和解析初体验 老师上课使用的Hive源码下载地址:http://www-eu.apache. ...

  2. PostGreSQL(1)-源码安装

    目录 简述 一.格式化磁盘 二.源码安装 PostGreSql 1. 安装 readline-devel 2. 安装 PostGresql 3. 设置环境变量 三. 初始化 1. 设置运行用户 2. ...

  3. mysql数据库源码安装_学习笔记-源码安装mariadb 20210128

    源码安装Mariadb数据库 安装之前先检查一下空间: 1 [15:13:16 root@centos8 ~]#free -h(#检查空间)2 total used free shared buff/ ...

  4. 短视频源码,成品短视频app源码搭建第一步

    随着短视频平台的兴起,短视频app也成为了移动应用市场的一大风口.开发一款成品的短视频app需要大量的资源和时间,而使用现成的小视频app源码则可以快速地搭建出一个基础功能完备的短视频app.本文将介 ...

  5. postgresql mysql 源码安装_PostGreSQL12 源码安装与字符集修改 (一)

    这篇简单的记录PostGreSQL12 (以下简称PG)Binary packages on RHEL 7.3安装过程,与后期的PG DB 和RHEL7 OS字符集修改. 2, 创建PG owner系 ...

  6. Linux安装MySQL(源码安装)

    文章目录 一.下载 二.最小化安装配置 三.MySQL的安装的几种方式 1.MySQL安装方式 2. 三种安装方式的区别 四.MySQL的GLIBC版本安装 1. 上传软件包解压 2. 软件安装 3. ...

  7. Linux下的软件安装方式+源码安装软件cmatrix代码雨

    Linux下的软件安装方式 1 rpm工具安装 2 yum工具安装 3 源码编译安装 软件包类型 1 二进制软件包(=rpm软件包) 无需编译,直接安装 根据计算机CPU架构类型和操作系统选择合适的软 ...

  8. mysql5.6.35源码安装记录

    mysql数据库源码安装: 源码地址:wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.xx.tar.gz #安装前准备, ...

  9. 【Guacamole中文文档】二、用户指南—— 2.Guacamole源码安装

    Guacamole源码安装 Guacamole分为两部分:guacamole-server,提供Guacamole代理和相关库:以及guacamole-client,提供通过servlet容器(通常是 ...

最新文章

  1. flask 学习实战项目实例
  2. IC设计通过system c 建模和 rtl级的有什么区别
  3. TCP服务器:多进程
  4. java media player_MediaPlayerForJava(创建一个视频播放器)
  5. webrtc简单案例——音视频采集和播放
  6. 版是什么_雕版研习 | 什么是版画?版是画的母亲,画是版的子女
  7. 框架学习与探究之AOP--Castle DynamicProxy
  8. [Java基础]对象(反)序列化流
  9. java项目 js报错红叉,解决js红叉,java Resources红叉
  10. ABI 大屏(示例布局)
  11. RHEL6/7 x86_64下cachefilesd占用cpu达到100%
  12. stdafx.h作用以及include中为何iostream必须放在stdafx.h之后?
  13. 智慧城市:大数据运营中心 IOC —— Web GIS 地图应用
  14. JavaScript 利用Ajax制作一个汇率转换器
  15. vue函数@click.prevent使用纪要
  16. Linux服务端监控
  17. Ph P Manual
  18. FTP、FTPS和SFTP
  19. 树莓派+温度传感器DS18B20
  20. 沙特更新ICT和移动设备要求

热门文章

  1. 华东师范大学2018年机试题
  2. 虚幻引擎[真实字幕组]开始公开招募!这太真实了!
  3. c++ primer 第3章 思维导图 一边看书一边写
  4. 电子科技大学计算机调剂要求,2016电子科技大学考研调剂信息发布(3.16更新)
  5. plot.figue中设置图片的大小
  6. 题库管理系统(部分代码)
  7. halcon系列:高斯混合模型之create_class_gmm 算子
  8. Vant 2 - 移动端 Vue 组件库 _ 问题记录
  9. 基于Unreal Engine 2的救援机器人仿真平台开发(一)
  10. 笔记本电脑硬盘坏道故障处理