From 239b65fde203011208ad63f9f63ef85ddec49ca9 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 14 Nov 2012 21:30:16 +0100 Subject: [PATCH] build: use autotools as build system Signed-off-by: Jan Engelhardt --- .gitignore | 25 +++-- Makefile | 111 -------------------- Makefile.am | 27 +++++ autogen.sh | 5 + configure | 273 ------------------------------------------------ configure.ac | 28 +++++ doc/Makefile | 64 ------------ include/Makefile | 47 --------- install.mk | 31 ------ m4/.gitignore | 2 + macros.mk | 207 ------------------------------------ src/.gitignore | 1 - src/Makefile | 90 ---------------- src/Makefile.am | 11 ++ src/python/.gitignore | 5 +- src/python/Makefile | 54 ---------- src/python/Makefile.am | 24 +++++ src/python/setup.py | 2 +- src/system.h | 4 +- tests/Makefile | 79 -------------- tests/Makefile.am | 29 +++++ tools/Makefile | 59 ----------- tools/Makefile.am | 8 ++ version_info | 8 -- 24 files changed, 157 insertions(+), 1037 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh delete mode 100755 configure create mode 100644 configure.ac delete mode 100644 doc/Makefile delete mode 100644 include/Makefile delete mode 100644 install.mk create mode 100644 m4/.gitignore delete mode 100644 macros.mk delete mode 100644 src/.gitignore delete mode 100644 src/Makefile create mode 100644 src/Makefile.am delete mode 100644 src/python/Makefile create mode 100644 src/python/Makefile.am delete mode 100644 tests/Makefile create mode 100644 tests/Makefile.am delete mode 100644 tools/Makefile create mode 100644 tools/Makefile.am delete mode 100644 version_info diff --git a/.gitignore b/.gitignore index d01d1a1..ef9560e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,25 @@ *~ -*.a +*.la +*.lo *.o -*.d -*.dtmp +*.pc *.swp *.orig +.deps +.dirstamp +.libs .stgit-* .stgitmail.txt +Makefile +Makefile.in cscope.* tags -configure.h -configure.mk -version_info.mk -version.h -libseccomp.pc + +/autom4te.cache/ +/aclocal.m4 +/build-aux/ +/config.* +/configure +/configure.h* +/libtool +/stamp-h1 diff --git a/Makefile b/Makefile deleted file mode 100644 index 5f7aa9b..0000000 --- a/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include macros.mk - -# -# configuration -# - --include version_info.mk --include configure.mk -include install.mk - -# -# targets -# - -CONFIGS = configure.mk configure.h version_info.mk libseccomp.pc -SUBDIRS_BUILD = src tests tools -SUBDIRS_INSTALL = src include doc - -.PHONY: tarball install ctags cstags clean dist-clean $(SUBDIRS_BUILD) - -all: $(SUBDIRS_BUILD) - -$(CONFIGS): version_info - @$(ECHO) ">> INFO: automatically generating configuration ..." - @./configure - -tarball: clean - @ver=$(VERSION_RELEASE); \ - tarball=libseccomp-$$ver.tar.gz; \ - $(ECHO) ">> INFO: creating the tarball ../$$tarball"; \ - tmp_dir=$$(mktemp -d /tmp/libseccomp.XXXXX); \ - rel_dir=$$tmp_dir/libseccomp-$$ver; \ - $(MKDIR) $$rel_dir; \ - $(TAR) cf - --exclude=*~ --exclude=.git* --exclude=.stgit* . | \ - (cd $$rel_dir; tar xf -); \ - (cd $$tmp_dir; $(TAR) zcf $$tarball libseccomp-$$ver); \ - $(MV) $$tmp_dir/$$tarball ..; \ - $(RM) -rf $$tmp_dir; - -$(VERSION_HDR): version_info.mk - @$(ECHO) ">> INFO: creating the version header file" - @hdr="$(VERSION_HDR)"; \ - $(ECHO) "/* automatically generated - do not edit */" > $$hdr; \ - $(ECHO) "#ifndef _VERSION_H" >> $$hdr; \ - $(ECHO) "#define _VERSION_H" >> $$hdr; \ - $(ECHO) "#define VERSION_RELEASE \"$(VERSION_RELEASE)\"" >> $$hdr; \ - $(ECHO) "#endif" >> $$hdr; - -src: $(VERSION_HDR) $(CONFIGS) - @$(ECHO) ">> INFO: building in directory $@/ ..." - @$(MAKE) -C $@ - -tests: src - @$(ECHO) ">> INFO: building in directory $@/ ..." - @$(MAKE) -C $@ - -tools: src - @$(ECHO) ">> INFO: building in directory $@/ ..." - @$(MAKE) -C $@ - -install: $(SUBDIRS_BUILD) - @$(ECHO) ">> INFO: installing in $(INSTALL_PREFIX) ..." - $(INSTALL_PC_MACRO) libseccomp.pc - @for dir in $(SUBDIRS_INSTALL); do \ - $(ECHO) ">> INFO: installing from $$dir/"; \ - $(MAKE) -C $$dir install; \ - done - -ctags: - @$(ECHO) ">> INFO: generating ctags for the project ..." - @ctags -R * - -cstags: - @$(ECHO) ">> INFO: generating cscope tags for the project ..." - @find -iname *.[ch] > cscope.files - @cscope -b -q -k - -clean: - @$(ECHO) ">> INFO: cleaning up libseccomp" - @for dir in $(SUBDIRS_BUILD); do \ - $(MAKE) -C $$dir clean; \ - done - -dist-clean: clean - @$(ECHO) ">> INFO: removing the configuration files" - @$(RM) $(CONFIGS) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6fd9b86 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,27 @@ +# -*- Makefile -*- + +SUBDIRS = src tools tests + +ACLOCAL_AMFLAGS = -I m4 + +pkgconfdir = ${libdir}/pkgconfig +pkgconf_DATA = libseccomp.pc + +include_HEADERS = include/seccomp.h + +man_MANS = \ + doc/man/man3/seccomp_arch_add.3 \ + doc/man/man3/seccomp_arch_remove.3 \ + doc/man/man3/seccomp_attr_get.3 \ + doc/man/man3/seccomp_attr_set.3 \ + doc/man/man3/seccomp_export_bpf.3 \ + doc/man/man3/seccomp_export_pfc.3 \ + doc/man/man3/seccomp_init.3 \ + doc/man/man3/seccomp_load.3 \ + doc/man/man3/seccomp_merge.3 \ + doc/man/man3/seccomp_release.3 \ + doc/man/man3/seccomp_reset.3 \ + doc/man/man3/seccomp_rule_add.3 \ + doc/man/man3/seccomp_rule_add_exact.3 \ + doc/man/man3/seccomp_syscall_priority.3 \ + doc/man/man3/seccomp_syscall_resolve_name.3 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..278050e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +autoreconf -fi; +rm -Rf autom4te.cache; +# do not call configure - this is unexpected diff --git a/configure b/configure deleted file mode 100755 index 8866fda..0000000 --- a/configure +++ /dev/null @@ -1,273 +0,0 @@ -#!/bin/bash - -# -# Enhanced Seccomp Library Configure Script -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# 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: -* general configuration - -h, --help display this help and exit -* installation configuration - --prefix=PREFIX installation base [/usr/local] - --libdir=DIR library directory [/usr/local/lib] -* build options - --enable-python build the python bindings, requires cython -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 - python bindings: $opt_bindings_python -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:,enable-python" -- "$@") -eval set -- "$opt" -while [[ $# -gt 0 ]]; do - case "$1" in - --prefix) - opt_prefix="$2" - shift 2 - ;; - --libdir) - opt_libdir="$2" - shift 2 - ;; - --enable-python) - opt_bindings_python="yes" - shift - ;; - -h|--help) - msg_usage - exit 0 - ;; - --) - shift - ;; - *) - msg_usage - exit 1 - esac -done - -# validate the 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 -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 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..e4e2c27 --- /dev/null +++ b/configure.ac @@ -0,0 +1,28 @@ +AC_INIT([libseccomp], [1.0.0]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_HEADERS([configure.h]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([-Wall foreign subdir-objects tar-pax no-dist-gzip dist-xz]) +AC_PROG_CC +AM_PROG_CC_C_O +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +AC_DISABLE_STATIC +LT_INIT + +AC_CHECK_HEADER([linux/seccomp.h]) + +AM_CPPFLAGS="-I\${top_srcdir}/include" +AM_CFLAGS="-Wall" +AM_LDFLAGS="-Wl,-z -Wl,relro" +AC_SUBST([AM_CPPFLAGS]) +AC_SUBST([AM_CFLAGS]) +AC_SUBST([AM_LDFLAGS]) + +AC_ARG_ENABLE([python], + [AS_HELP_STRING([build the python bindings, requires cython])]) +AM_CONDITIONAL([ENABLE_PYTHON], [test "$enable_python" = yes]) + +AC_CONFIG_FILES([Makefile src/Makefile src/python/Makefile tools/Makefile + tests/Makefile libseccomp.pc]) +AC_OUTPUT diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 348a04b..0000000 --- a/doc/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../macros.mk - -# -# configuration -# - -include $(TOPDIR)/version_info.mk -include $(TOPDIR)/configure.mk -include $(TOPDIR)/install.mk - -MAN3 = \ - man/man3/seccomp_init.3 \ - man/man3/seccomp_load.3 \ - man/man3/seccomp_release.3 \ - man/man3/seccomp_reset.3 \ - man/man3/seccomp_rule_add.3 \ - man/man3/seccomp_rule_add_exact.3 \ - man/man3/seccomp_syscall_priority.3 \ - man/man3/seccomp_syscall_resolve_name.3 \ - man/man3/seccomp_export_bpf.3 \ - man/man3/seccomp_export_pfc.3 \ - man/man3/seccomp_attr_set.3 \ - man/man3/seccomp_attr_get.3 \ - man/man3/seccomp_arch_add.3 \ - man/man3/seccomp_arch_remove.3 \ - man/man3/seccomp_merge.3 - -# -# targets -# - -.PHONY: all install install_man3 - -all: - -install: install_man3 - -install_man3: $(MAN3) - $(INSTALL_MAN3_MACRO) diff --git a/include/Makefile b/include/Makefile deleted file mode 100644 index 2cd0e56..0000000 --- a/include/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../macros.mk - -# -# configuration -# - -include $(TOPDIR)/version_info.mk -include $(TOPDIR)/configure.mk -include $(TOPDIR)/install.mk - -# -# targets -# - -.PHONY: all install install_hdr - -all: - -install: install_hdr - -install_hdr: seccomp.h - $(INSTALL_INC_MACRO) diff --git a/install.mk b/install.mk deleted file mode 100644 index 123af33..0000000 --- a/install.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Enhanced Seccomp Library Installation Defaults -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -INSTALL_PREFIX ?= $(CONF_INSTALL_PREFIX) - -INSTALL_SBIN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/sbin -INSTALL_BIN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/bin -INSTALL_LIB_DIR ?= $(DESTDIR)/$(CONF_INSTALL_LIBDIR) -INSTALL_INC_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/include -INSTALL_MAN_DIR ?= $(DESTDIR)/$(INSTALL_PREFIX)/share/man - -INSTALL_OWNER ?= $$(id -u) -INSTALL_GROUP ?= $$(id -g) diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 0000000..64d9bbc --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,2 @@ +/libtool.m4 +/lt*.m4 diff --git a/macros.mk b/macros.mk deleted file mode 100644 index 5989e05..0000000 --- a/macros.mk +++ /dev/null @@ -1,207 +0,0 @@ -# -# Enhanced Seccomp Library Build Macros -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -SHELL = /bin/bash - -# -# simple /bin/bash script to find the top of the tree -# - -TOPDIR := $(shell \ - ftd() { \ - cd $$1; \ - if [[ -r "macros.mk" ]]; then \ - pwd; \ - else \ - ftd "../"; \ - fi \ - }; \ - ftd .) - -# -# build configuration -# - -V ?= 0 - -CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/include -LIBFLAGS = - -CFLAGS ?= -Wl,-z,relro -Wall -O0 -g -CFLAGS += -fPIC -LDFLAGS ?= -z relro -g - -# -# build tools -# - -LN ?= ln -MV ?= mv -CAT ?= cat -ECHO ?= echo -TAR ?= tar -MKDIR ?= mkdir - -SED ?= sed -AWK ?= awk - -PYTHON ?= /usr/bin/env python - -# we require gcc specific functionality -GCC ?= gcc - -INSTALL ?= install - -# -# auto dependencies -# - -MAKEDEP = @$(GCC) $(CPPFLAGS) -MM -MF $(patsubst %.o,%.d,$@) $<; -MAKEDEP_EXEC = \ - @$(GCC) $(CPPFLAGS) -MM -MT $(patsubst %.d,%,$@) \ - -MF $@ $(patsubst %.d,%.c,$@); - -ADDDEP = \ - @adddep_func() { \ - $(MV) $$1 $$1.dtmp; \ - $(CAT) $$1.dtmp | $(SED) -e 's/\([^\]\)$$/\1 \\/' | \ - ( $(CAT) - && $(ECHO) " $$2" ) > $$1; \ - $(RM) -f $@.dtmp; \ - }; \ - adddep_func - -# -# build constants -# - -VERSION_HDR = version.h - -# -# build macros -# - -PY_DISTUTILS = \ - VERSION_RELEASE="$(VERSION_RELEASE)" \ - CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" \ - $(PYTHON) ./setup.py - -ifeq ($(V),0) - PY_BUILD = @echo " PYTHON build"; -endif -PY_BUILD += $(PY_DISTUTILS) -ifeq ($(V),0) - PY_BUILD += -q -endif -PY_BUILD += build - -ifeq ($(V),0) - PY_INSTALL = @echo " PYTHON install"; -endif -PY_INSTALL += $(PY_DISTUTILS) -ifeq ($(V),0) - PY_INSTALL += -q -endif -PY_INSTALL += install - -ifeq ($(V),0) - COMPILE = @echo " CC $@"; -endif -COMPILE += $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<; - -ifeq ($(V),0) - COMPILE_EXEC = @echo " CC $@"; -endif -COMPILE_EXEC += $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LDFLAGS); - -ifeq ($(V),0) - ARCHIVE = @echo " AR $@"; -endif -ARCHIVE += $(AR) -cru $@ $?; - -ifeq ($(V),0) - LINK_EXEC = @echo " LD $@"; -endif -LINK_EXEC += $(GCC) $(LDFLAGS) -o $@ $^ $(LIBFLAGS); - -ifeq ($(V),0) - LINK_LIB = @echo " LD $@" \ - "($(patsubst %.so.$(VERSION_RELEASE),%.so.$(VERSION_MAJOR),$@))"; -endif -LINK_LIB += $(GCC) $(LDFLAGS) -o $@ $^ -shared \ - -Wl,-soname=$(patsubst %.so.$(VERSION_RELEASE),%.so.$(VERSION_MAJOR),$@) - -# -# install macros -# - -ifeq ($(V),0) - INSTALL_LIB_MACRO = @echo " INSTALL $^ ($(INSTALL_LIB_DIR)/$^)"; -endif -INSTALL_LIB_MACRO += \ - basename=$$(echo $^ | sed -e 's/.so.*$$/.so/'); \ - soname=$$(objdump -p $^ | grep "SONAME" | awk '{print $$2}'); \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ - -d "$(INSTALL_LIB_DIR)"; \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0755 \ - $^ "$(INSTALL_LIB_DIR)"; \ - (cd "$(INSTALL_LIB_DIR)"; $(RM) $$soname); \ - (cd "$(INSTALL_LIB_DIR)"; $(LN) -s $^ $$soname); \ - (cd "$(INSTALL_LIB_DIR)"; $(RM) $$basname); \ - (cd "$(INSTALL_LIB_DIR)"; $(LN) -s $^ $$basename); - -ifeq ($(V),0) - INSTALL_PC_MACRO = \ - @echo " INSTALL $$(cat /proc/$$$$/cmdline | awk '{print $$(NF)}')" \ - " ($(INSTALL_LIB_DIR)/pkgconfig)"; -endif -INSTALL_PC_MACRO += \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ - -d "$(INSTALL_LIB_DIR)/pkgconfig"; \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \ - "$$(cat /proc/$$$$/cmdline | awk '{print $$(NF)}')" \ - "$(INSTALL_LIB_DIR)/pkgconfig"; \# - -ifeq ($(V),0) - INSTALL_INC_MACRO = @echo " INSTALL $^ ($(INSTALL_INC_DIR))"; -endif -INSTALL_INC_MACRO += \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ - -d "$(INSTALL_INC_DIR)"; \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \ - $^ "$(INSTALL_INC_DIR)"; - -ifeq ($(V),0) - INSTALL_MAN3_MACRO = \ - @echo " INSTALL manpages ($(INSTALL_MAN_DIR)/man3)"; -endif -INSTALL_MAN3_MACRO += \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ - -d "$(INSTALL_MAN_DIR)/man3"; \ - $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \ - $^ "$(INSTALL_MAN_DIR)/man3"; - -# -# default build targets -# - -%.o: %.c - $(MAKEDEP) - $(COMPILE) diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 98755dd..0000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -libseccomp.so.* diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index f3a192c..0000000 --- a/src/Makefile +++ /dev/null @@ -1,90 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../macros.mk - -# -# configuration -# - -include $(TOPDIR)/version_info.mk -include $(TOPDIR)/configure.mk -include $(TOPDIR)/install.mk - -LIB_STATIC = libseccomp.a -LIB_SHARED = libseccomp.so.$(VERSION_RELEASE) - -OBJS = \ - api.o db.o arch.o \ - arch-i386.o arch-i386-syscalls.o \ - arch-x86_64.o arch-x86_64-syscalls.o \ - hash.o \ - gen_pfc.o gen_bpf.o - -DEPS = $(OBJS:%.o=%.d) - -# -# bindings configuration -# - -BINDINGS = - -ifeq ($(CONF_BINDINGS_PYTHON), 1) - BINDINGS += python -endif - -# -# targets -# - -.PHONY: all install clean python - -all: $(LIB_STATIC) $(LIB_SHARED) $(BINDINGS) - --include $(DEPS) - -$(LIB_STATIC): $(OBJS) - $(ARCHIVE) - -$(LIB_SHARED): $(OBJS) - $(LINK_LIB) - -python: $(LIB_STATIC) - @$(ECHO) ">> INFO: building in directory $@/ ..." - @$(MAKE) -C $@ - -install: $(LIB_SHARED) - $(INSTALL_LIB_MACRO) - @for dir in $(BINDINGS); do \ - $(ECHO) ">> INFO: installing from $$dir/"; \ - $(MAKE) -C $$dir install; \ - done - -clean: - $(RM) $(DEPS) $(OBJS) $(LIB_STATIC) $(LIB_SHARED) - @for dir in $(BINDINGS); do \ - $(MAKE) -C $$dir clean; \ - done - diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..2ff43b1 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,11 @@ +# -*- Makefile -*- + +SUBDIRS = . +if ENABLE_PYTHON +SUBDIRS += python +endif + +lib_LTLIBRARIES = libseccomp.la + +libseccomp_la_SOURCES = api.c arch.c arch-i386.c arch-i386-syscalls.c \ + arch-x86_64.c arch-x86_64-syscalls.c db.c hash.c gen_pfc.c gen_bpf.c diff --git a/src/python/.gitignore b/src/python/.gitignore index fc8966d..9e5cd01 100644 --- a/src/python/.gitignore +++ b/src/python/.gitignore @@ -1,2 +1,3 @@ -build -seccomp.c +/python-build +/build/ +/seccomp.c diff --git a/src/python/Makefile b/src/python/Makefile deleted file mode 100644 index 3543a65..0000000 --- a/src/python/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# -# Enhanced Seccomp Library Python Bindings Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../../macros.mk - -# -# configuration -# - -include $(TOPDIR)/version_info.mk -include $(TOPDIR)/configure.mk -include $(TOPDIR)/install.mk - -LIB_STATIC = ../libseccomp.a - -# -# targets -# - -.PHONY: all install clean - -all: build - -build: $(LIB_STATIC) libseccomp.pxd seccomp.pyx - @$(RM) seccomp.c - $(PY_BUILD) && touch build - -install: build - $(PY_INSTALL) install --prefix=$(DESTDIR)/$(INSTALL_PREFIX) - -clean: - $(RM) -rf build seccomp.c diff --git a/src/python/Makefile.am b/src/python/Makefile.am new file mode 100644 index 0000000..400b354 --- /dev/null +++ b/src/python/Makefile.am @@ -0,0 +1,24 @@ +# -*- Makefile -*- + +PYTHON = /usr/bin/env python +pyverbose_0 = -q +pyverbose_ = ${pyverbose_0} + +PY_DISTUTILS = \ + VERSION_RELEASE="${VERSION_RELEASE}" \ + CFLAGS="-I\${top_srcdir}/include ${CFLAGS} ${CPPFLAGS}" \ + LDFLAGS="${LDFLAGS}" \ + ${PYTHON} ./setup.py +PY_BUILD = ${PY_DISTUTILS} build ${pyverbose_${V}} +PY_INSTALL = ${PY_DISTUTILS} install ${pyverbose_${V}} + +all-local: python-build + +python-build: ../libseccomp.la libseccomp.pxd seccomp.pyx + ${AM_V_GEN}${PY_DISTUTILS} build && touch $@ + +install-exec-local: + ${PY_DISTUTILS} install --prefix=${DESTDIR}/${prefix} + +clean-local: + rm -Rf python-build seccomp.c diff --git a/src/python/setup.py b/src/python/setup.py index 872642e..62ba24a 100644 --- a/src/python/setup.py +++ b/src/python/setup.py @@ -40,6 +40,6 @@ setup( cmdclass = {'build_ext': build_ext}, ext_modules = [ Extension("seccomp", ["seccomp.pyx"], - extra_objects=["../libseccomp.a"]) + extra_objects=["../.libs/libseccomp.so"]) ] ) diff --git a/src/system.h b/src/system.h index cb14f65..11303cf 100644 --- a/src/system.h +++ b/src/system.h @@ -25,9 +25,9 @@ #include #include -#include +#include "configure.h" -#ifdef CONF_SYSINC_SECCOMP +#ifdef HAVE_LINUX_SECCOMP_H /* system header file */ #include diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index e3714f2..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../macros.mk - -# -# configuration -# - -include $(TOPDIR)/version_info.mk -include $(TOPDIR)/configure.mk - -OBJS = util.o - -LDFLAGS := ../src/libseccomp.a $(OBJS) - -TESTS = 01-allow \ - 02-basic \ - 03-basic-chains \ - 04-multilevel-chains \ - 05-long-jumps \ - 06-actions \ - 07-db-bug-looping \ - 08-subtree-checks \ - 09-syscall-priority-pre \ - 10-syscall-priority-post \ - 11-basic-errors \ - 12-basic-masked-ops \ - 13-attrs \ - 14-reset \ - 15-resolver \ - 16-arch-basic \ - 17-arch-merge - -DEPS_OBJS = $(OBJS:%.o=%.d) -DEPS_TESTS = $(TESTS:%=%.d) - -# -# targets -# - -.PHONY: clean - -all: $(TESTS) $(OBJS) - --include $(DEPS_TESTS) $(DEPS_OBJS) - -$(DEPS_TESTS): - $(MAKEDEP_EXEC) - $(ADDDEP) $@ ../src/libseccomp.a - $(ADDDEP) $@ $(OBJS) - -$(TESTS): - $(COMPILE_EXEC) - -clean: - $(RM) $(DEPS_TESTS) $(DEPS_OBJS) $(TESTS) $(OBJS) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..655278b --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,29 @@ +# -*- Makefile -*- + +AM_LDFLAGS = -static +LDADD = util.la ../src/libseccomp.la + +check_LTLIBRARIES = util.la +util_la_SOURCES = util.c +util_la_LDFLAGS = -module + +TESTS = regression + +check_PROGRAMS = \ + 01-allow \ + 02-basic \ + 03-basic-chains \ + 04-multilevel-chains \ + 05-long-jumps \ + 06-actions \ + 07-db-bug-looping \ + 08-subtree-checks \ + 09-syscall-priority-pre \ + 10-syscall-priority-post \ + 11-basic-errors \ + 12-basic-masked-ops \ + 13-attrs \ + 14-reset \ + 15-resolver \ + 16-arch-basic \ + 17-arch-merge diff --git a/tools/Makefile b/tools/Makefile deleted file mode 100644 index 74f2caa..0000000 --- a/tools/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# -# Enhanced Seccomp Library Makefile -# -# Copyright (c) 2012 Red Hat -# Author: Paul Moore -# - -# -# 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 . -# - -# -# macros -# - -include ../macros.mk - -# -# configuration -# - -include $(TOPDIR)/configure.mk - -LDFLAGS := ../src/libseccomp.a - -TOOLS = bpf_disasm \ - bpf_sim \ - sys_resolver - -DEPS = $(TOOLS:%=%.d) - -# -# targets -# - -.PHONY: clean - -all: $(TOOLS) - --include $(DEPS) - -$(DEPS): - $(MAKEDEP_EXEC) - -$(TOOLS): - $(COMPILE_EXEC) - -clean: - $(RM) $(DEPS) $(TOOLS) diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 0000000..86b012d --- /dev/null +++ b/tools/Makefile.am @@ -0,0 +1,8 @@ +# -*- Makefile -*- + +noinst_PROGRAMS = bpf_disasm bpf_sim sys_resolver + +bpf_disasm_SOURCES = bpf_disasm.c +bpf_sim_SOURCES = bpf_sim.c +sys_resolver_SOURCES = sys_resolver.c +sys_resolver_LDADD = ../src/libseccomp.la diff --git a/version_info b/version_info deleted file mode 100644 index 7520e4f..0000000 --- a/version_info +++ /dev/null @@ -1,8 +0,0 @@ -# -# version_info - version information for seccomp library -# - -# version components -VERSION_MAJOR=0 -VERSION_MINOR=0 -VERSION_MICRO=0 -- 1.7.10.4