OMS-Auditd-Plugin/build/configure

369 строки
10 KiB
Bash
Executable File

#!/bin/bash
####
# microsoft-oms-auditd-plugin
#
# Copyright (c) Microsoft Corporation
#
# All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
####
# Detect old CentOS 5 build environment
CENTOS5_BUILD_ENV=1
grep "CentOS release 5" /etc/redhat-release > /dev/null 2>&1
if [ $? -ne 0 ]; then
CENTOS5_BUILD_ENV=0
fi
home_dir=`(cd ~/; pwd -P)`
base_dir=`(cd ..; pwd -P)`
scxpal_dir=`(cd ../../pal; pwd -P)`
if [ "$CENTOS5_BUILD_ENV" -eq 1 ]; then
root_dir=`(cd ../../..; pwd -P)`
ver_file=../../auoms.version
else
root_dir=`(cd ../..; pwd -P)`
ver_file=../auoms.version
fi
enable_debug=""
enable_debug_flag=0
enable_purify_agent=""
enable_purify_server=""
enable_omi_tools=""
enable_omi_tools_flag=0
opensource_distro=0
build_type=Release
ULINUX=0
NOULINIX=0
if [ ! -d "$scxpal_dir" ]; then
echo "PAL directory ($scxpal_dir) does not exist" >& 2
exit 1
fi
if [ ! -e /usr/include/auparse.h ]; then
echo "audit libs dev package is not installed!" >& 2
exit 1
fi
if [ ! -e ${root_dir}/rapidjson-1.0.2.tar.gz ]; then
echo "rapidjson 1.0.2 tar file (${root_dir}/v1.0.2.tar.gz) is missing. Downloading..." >& 2
wget -O ${root_dir}/rapidjson-1.0.2.tar.gz https://github.com/Tencent/rapidjson/archive/v1.0.2.tar.gz >& 2
fi
echo "c3711ed2b3c76a5565ee9f0128bb4ec6753dbcc23450b713842df8f236d08666 ${root_dir}/rapidjson-1.0.2.tar.gz" | sha256sum -c -
if [ $? -ne 0 ]; then
echo "Download of ${root_dir}/rapidjson-1.0.2.tar.gz failed or file is corrupted!" >& 2
exit 1
fi
if [ ! -e ${root_dir}/msgpack-c-cpp-2.0.0.zip ]; then
echo "MsgPack cpp 2.0.0 zip file (${root_dir}/cpp-2.0.0.zip) is missing. Downloading..." >& 2
wget -O ${root_dir}/msgpack-c-cpp-2.0.0.zip https://github.com/msgpack/msgpack-c/archive/cpp-2.0.0.zip >& 2
fi
echo "9f3860bc014355dbdf6519ffb78d54d120bb8d134dcb4eba35eb5103c1ac3cd1 ${root_dir}/msgpack-c-cpp-2.0.0.zip" | sha256sum -c -
if [ $? -ne 0 ]; then
echo "Download of ${root_dir}/msgpack-c-cpp-2.0.0.zip failed or file is corrupted!" >& 2
exit 1
fi
if [ ! -e ${root_dir}/re2-2020-11-01.zip ]; then
echo "re2 zip file (${root_dir}/re2-2020-11-01.zip) is missing. Downloading..." >& 2
wget -O ${root_dir}/re2-2020-11-01.zip https://github.com/google/re2/archive/2020-11-01.zip >& 2
fi
echo "b7a29e40083005d280136205a925a49a1cc2b22df7c2a5e3764c35d1c70f4441 ${root_dir}/re2-2020-11-01.zip" | sha256sum -c -
if [ $? -ne 0 ]; then
echo "Download of ${root_dir}/re2-2020-11-01.zip failed or file is corrupted!" >& 2
exit 1
fi
number_of_bits() {
# Always favor 64-bit if we get something unanticipated
case `uname -m` in
*64*)
echo "64"
;;
*86* | *athlon*)
echo "32"
;;
*)
echo "64"
;;
esac
}
for opt
do
arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case $opt in
-h | --help)
help=1
;;
--enable-debug)
enable_debug="--enable-debug"
build_type=Debug
enable_debug_flag=1
;;
--enable-ulinux)
if [ `uname` != "Linux" ]; then
echo "Cannot build for ULINUX on non-Linux platforms" >& 2
exit 1
fi
if [ "$NOULINUX" = "1" ]; then
echo "Conflicting qualifers: --enable-ulinux and --noenable-ulinux can't be specified together" >& 2
exit 1
fi
enable_ulinux="--enable-ulinux"
ULINUX=1
;;
--noenable-ulinux)
if [ `uname` != "Linux" ]; then
echo "Cannot build for ULINUX on non-Linux platforms" >& 2
exit 1
fi
if [ "$ULINUX" = "1" ]; then
echo "Conflicting qualifers: --enable-ulinux and --noenable-ulinux can't be specified together" >& 2
exit 1
fi
NOULINUX=1
;;
--enable-open-source)
opensource_distro=1
;;
*)
echo "configure: invalid option '$opt'" >& 2
echo "Try configure --help' for more information." >& 2
exit 1
;;
esac
done
if [ "$help" = "1" ]; then
cat<<EOF
Usage: ./configure [OPTIONS]
OVERVIEW:
This script configures auoms for building. Type the following commands.
$ ./configure
$ make
OPTIONS:
-h, --help Print this help message.
--enable-debug Perform a debug build.
--[no]enable-ulinux Specifies platform as ULINUX (Linux only);
ULINUX is assumed on universal build systems
--enable-open-source Build for open source distribution
EOF
exit 0
fi
# No errors allowed from this point forward
set -e
if [ "$ULINUX" -eq 1 -a "$opensource_distro" -eq 1 ]; then
echo "*** ULINUX not permitted for open source distributions; ULINUX disabled ***" >& 2
ULINUX=0
fi
if [ "$opensource_distro" -eq 1 ]; then
# We really don't want ULINUX, not even defaulted
NOULINUX=1
fi
if [ "$ULINUX" -eq 1 ]; then
if [ "$CENTOS5_BUILD_ENV" -eq 1 ]; then
if [ ! -e /opt/rh/devtoolset-2/root/usr/bin/g++ ]; then
echo "devtools-2 packages are not installed!" >& 2
exit 1
fi
fi
if [ ! -e /usr/include/boost148 ]; then
echo "boost148-devel package is not installed!" >& 2
exit 1
fi
fi
# Note: Most of this code came from the PAL configure file
set_ulinux_pf()
{
PF_MAJOR=1
PF_MINOR=0
PF_DISTRO=ULINUX
if [ -e /usr/bin/dpkg ]; then
BUILD_DPKG=1
PKG_SUFFIX=deb
else
if [ -e /usr/bin/rpmbuild ]; then
BUILD_RPM=1
else
echo "Can't determine if this system should build .DEB or .RPM packages" >& 2
exit 1
fi
fi
}
uname=`uname`
case $uname in
Linux)
PF=Linux
PKG_SUFFIX=rpm
if [ -e /etc/SuSE-release ]; then
CHECK_SUSE=1
fi
if [ -e /etc/redhat-release ]; then
CHECK_RHEL_OR_CENTOS=1
fi
if [ -n "$CHECK_RHEL_OR_CENTOS" ]; then
CHECK_CENTOS=`grep -i "Red Hat" /etc/redhat-release || echo 1`
if [ "$CHECK_CENTOS" != "1" ]; then
CHECK_RHEL=1
fi
fi
if [ "$ULINUX" = "1" ]; then
set_ulinux_pf
BUILD_RPM=1
BUILD_DPKG=1
elif [ -n "$CHECK_SUSE" ]; then
PF_MAJOR=`head -n 1 /etc/SuSE-release | sed 's/.* \([0-9][0-9]*\)[ \.].*/\1/'`
PF_MINOR=`(head -n 1 /etc/SuSE-release | sed 's/.* [0-9][0-9]*[\.]\([0-9][0-9]*\).*/\1/') | grep -v '[^0-9]' || echo '0'`
PF_DISTRO=SUSE
elif [ -n "$CHECK_RHEL" ]; then
PF_MAJOR=`head -n 1 /etc/redhat-release | sed 's/.* \([0-9][0-9]*\)[ \.].*/\1/'`
PF_MINOR=`(head -n 1 /etc/redhat-release | sed 's/.* [0-9][0-9]*[\.]\([0-9][0-9]*\).*/\1/') | grep -v '[^0-9]' || echo '0'`
PF_DISTRO=REDHAT
elif [ -n "$CHECK_CENTOS" ]; then
PF_MAJOR=`head -n 1 /etc/redhat-release | sed 's/.* \([0-9][0-9]*\)[ \.].*/\1/'`
PF_MINOR=`(head -n 1 /etc/redhat-release | sed 's/.* [0-9][0-9]*[\.]\([0-9][0-9]*\).*/\1/') | grep -v '[^0-9]' || echo '0'`
PF_DISTRO=REDHAT
elif [ -e /etc/lsb-release ]; then
source /etc/lsb-release
if [ "$DISTRIB_ID" = "Ubuntu" ]; then
PF_MAJOR=`echo $DISTRIB_RELEASE | cut -d '.' -f 1`
PF_MINOR=`echo $DISTRIB_RELEASE | cut -d '.' -f 2`
PF_DISTRO=UBUNTU
PKG_SUFFIX=deb
BUILD_DPKG=1
else
set_ulinux_pf
fi
else
set_ulinux_pf
fi
case `uname -m` in
*64*)
PF_ARCH=x64
ARCH=x64
USR_LIB_DIR=/usr/lib64
;;
*86*)
PF_ARCH=x86
ARCH=ia32
USR_LIB_DIR=/usr/lib
;;
*athlon*)
PF_ARCH=x86
ARCH=ia32
USR_LIB_DIR=/usr/lib
;;
*)
PF_ARCH=UNKNOWN
ARCH=UNKNOWN
USR_LIB_DIR=UNKNOWN
;;
esac
if [ "$PF_ARCH" = "x86" ]; then
PF_WIDTH=32
else
PF_WIDTH=64
fi
;;
esac
if [ "$uname" = "Linux" ]; then
BUILD_CONFIGURATION=${PF}_${PF_DISTRO}_${PF_MAJOR}.${PF_MINOR}_${PF_ARCH}_${PF_WIDTH}_${build_type}
else
BUILD_CONFIGURATION=${PF}_${PF_MAJOR}.${PF_MINOR}_${PF_ARCH}_${PF_WIDTH}_${build_type}
fi
# Create a ~/bin directory (if it doesn't exist) as user
# This is done so that, if user doesn't have a ~/bin directory,
# they'll have one owned by the user (and not by root)
[ ! -d ~/bin ] && mkdir ~/bin
# Do we have a version file from the super project? If not, make one
if [ -f $ver_file ]; then
rm -f Makefile.version
ln -s $ver_file Makefile.version
else
cat <<EOF > Makefile.version
AUOMS_BUILDVERSION_MAJOR=0
AUOMS_BUILDVERSION_MINOR=0
AUOMS_BUILDVERSION_PATCH=0
AUOMS_BUILDVERSION_BUILDNR=0
AUOMS_BUILDVERSION_DATE=20160101
AUOMS_BUILDVERSION_STATUS=Developer_Build
EOF
fi
# Generate the config.mak file
cat <<EOF > config.mak
ENABLE_DEBUG=$enable_debug_flag
BUILD_TYPE=$build_type
PF=$PF
PF_MAJOR=$PF_MAJOR
PF_MINOR=$PF_MINOR
PF_ARCH=$PF_ARCH
ARCH=$ARCH
PF_WIDTH=$PF_WIDTH
PF_DISTRO=$PF_DISTRO
ULINUX=$ULINUX
BUILD_CONFIGURATION=$BUILD_CONFIGURATION
PACKAGE_SUFFIX=$PKG_SUFFIX
USR_LIB_DIR=$USR_LIB_DIR
CENTOS5_BUILD_ENV=$CENTOS5_BUILD_ENV
EOF
if [ "$ULINUX" = "1" ]; then
echo "Configured AUOMS for ULINUX build"
else
echo "Configured AUOMS for non-ULINUX build"
fi