/
githubmirror
/
libseccomp
Обзор
Документация
Войти
/
githubmirror
/
libseccomp
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v2.1.0
configure
277 строк
6 KB
Paul Moore
build: disable the python bindings for the v2.1.x release
11 июн 2013, 00:54
11 июн 2013, 00:54
a363a8d
Код
Авторство
О чём код?
#!/bin/bash # # Enhanced Seccomp Library Configure Script # # Copyright (c) 2012 Red Hat <pmoore@redhat.com> # Author: Paul Moore <pmoore@redhat.com> # # # This library is free software; you can redistribute it and/or modify it # under the terms of version 2.1 of the GNU Lesser General Public License as # published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, see <http://www.gnu.org/licenses>. # # configuration defaults opt_prefix="/usr/local" opt_libdir="" opt_sysinc_seccomp="yes" opt_bindings_python="no" # output files cnf_mk_file="configure.mk" cnf_h_file="configure.h" #### # functions function test_deps() { [[ -z "$1" ]] && return 0 which "$1" >& /dev/null && return 0 return 1 } function verify_deps() { [[ -z "$1" ]] && return if ! test_deps "$1"; then echo "error: install \"$1\" and include it in your \$PATH" exit 1 fi } function msg_usage() { cat << EOF Configure the enhanced seccomp library, libseccomp, for this system. Usage: ./configure <options> Options: * general configuration -h, --help display this help and exit * installation configuration --prefix=PREFIX installation base [/usr/local] --libdir=DIR library directory [/usr/local/lib] EOF } function msg_summary() { cat << EOF CONFIGURATION SUMMARY libseccomp version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO} installation base: $opt_prefix library directory: $opt_libdir use system includes: $opt_sysinc_seccomp EOF } function msg_error() { echo "error: $@" } function cnf_mk_header() { echo "# generated by configure on $(date -R)" >> $cnf_mk_file echo "# options: \"$opt_str\"" >> $cnf_mk_file echo "" >> $cnf_mk_file } function cnf_mk_footer() { echo "" >> $cnf_mk_file } function cnf_mk_entry() { [[ $# -ne 2 ]] && return case "$2" in no) echo "$1 = 0" >> $cnf_mk_file ;; yes) echo "$1 = 1" >> $cnf_mk_file ;; *) echo "$1 = \"$2\"" >> $cnf_mk_file esac } function cnf_h_header() { echo "/* generated by configure on $(date -R) */" >> $cnf_h_file echo "/* options: \"$opt_str\" */" >> $cnf_h_file echo "" >> $cnf_h_file echo "#ifndef _CONFIGURE_H" >> $cnf_h_file echo "#define _CONFIGURE_H" >> $cnf_h_file echo "" >> $cnf_h_file } function cnf_h_footer() { echo "" >> $cnf_h_file echo "#endif" >> $cnf_h_file echo "" >> $cnf_h_file } function cnf_h_entry() { [[ $# -ne 2 ]] && return case "$2" in no) echo "#undef $1" >> $cnf_h_file ;; yes) echo "#define $1 1" >> $cnf_h_file ;; *) echo "#define $1 $2" >> $cnf_h_file esac } function cnf_reset() { cat /dev/null > $cnf_mk_file cat /dev/null > $cnf_h_file } function cnf_header() { cnf_mk_header cnf_h_header } function cnf_entry() { cnf_mk_entry "$1" "$2" cnf_h_entry "$1" "$2" } function cnf_footer() { cnf_mk_footer cnf_h_footer } function tmpl_filter() { name="echo \$$1" val="$(eval $name)" cat - | sed -e 's/%%'"$1"'%%/'"${val//\//\\/}"'/g;' } #### # main # # setup # # verify script dependencies verify_deps getopt # parse the command line options opt_str="$@" opt=$(getopt -n "$0" --options "h" --longoptions "help,prefix:,libdir:" -- "$@") eval set -- "$opt" while [[ $# -gt 0 ]]; do case "$1" in --prefix) opt_prefix="$2" shift 2 ;; --libdir) opt_libdir="$2" shift 2 ;; -h|--help) msg_usage exit 0 ;; --) shift ;; *) msg_usage exit 1 esac done # # validate the command line options # if [[ -e "$opt_prefix" && ! -d "$opt_prefix" ]]; then msg_error "install prefix ($opt_prefix) is not a directory" exit 1 fi if [[ -z $opt_libdir ]]; then opt_libdir="$opt_prefix/lib" fi if [[ -e "$opt_libdir" && ! -d "$opt_libdir" ]]; then msg_error "libdir ($opt_libdir) is not a directory" exit 1 fi if [[ "$opt_bindings_python" = "yes" ]]; then if ! test_deps cython; then msg_error "python bindings require the cython package" exit 1 fi cython_ver=$(cython -V 2>&1 | cut -d' ' -f 3) if [[ $(echo $cython_ver | cut -d'.' -f 1) -lt 1 && $(echo $cython_ver | cut -d'.' -f 2) -lt 16 ]]; then msg_error "python bindings require cython 0.16 or higher" exit 1 fi fi # # automatic configuration # # system seccomp includes if [[ -r "/usr/include/linux/seccomp.h" ]]; then opt_sysinc_seccomp="yes" else opt_sysinc_seccomp="no" fi # generate the version files . ./version_info VERSION_RELEASE="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}" rm -f ./version_info.mk echo "# generated by configure on $(date -R)" >> ./version_info.mk echo "VERSION_MAJOR=$VERSION_MAJOR" >> ./version_info.mk echo "VERSION_MINOR=$VERSION_MINOR" >> ./version_info.mk echo "VERSION_MICRO=$VERSION_MICRO" >> ./version_info.mk echo "VERSION_RELEASE=$VERSION_RELEASE" >> ./version_info.mk # generate the pkg-config metadata INSTALL_PREFIX="$opt_prefix" INSTALL_LIBDIR="$opt_libdir" rm -f ./libseccomp.pc cat ./libseccomp.pc.in | \ tmpl_filter INSTALL_PREFIX | \ tmpl_filter INSTALL_LIBDIR | \ tmpl_filter VERSION_RELEASE \ >> ./libseccomp.pc # # finish # # reset the configuration files cnf_reset cnf_header # output the configuration files cnf_mk_entry "CONF_INSTALL_PREFIX" "$opt_prefix" cnf_mk_entry "CONF_INSTALL_LIBDIR" "$opt_libdir" cnf_entry "CONF_SYSINC_SECCOMP" "$opt_sysinc_seccomp" cnf_entry "CONF_BINDINGS_PYTHON" "$opt_bindings_python" # configuration footer cnf_footer # display a summary and exit msg_summary exit 0