diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 35 | ||||
-rw-r--r-- | doc/Makefile | 56 | ||||
-rw-r--r-- | install.mk | 30 | ||||
-rw-r--r-- | macros.mk | 31 | ||||
-rw-r--r-- | src/.gitignore | 2 | ||||
-rw-r--r-- | src/Makefile | 11 |
7 files changed, 137 insertions, 29 deletions
@@ -11,3 +11,4 @@ cscope.* tags configure.h configure.mk +version.h @@ -30,27 +30,19 @@ include macros.mk # -include configure.mk - -INSTALL_PREFIX ?= $(CONF_INSTALL_PREFIX) - -INSTALL_SBIN_DIR ?= $(INSTALL_PREFIX)/sbin -INSTALL_BIN_DIR ?= $(INSTALL_PREFIX)/bin -INSTALL_LIB_DIR ?= $(INSTALL_PREFIX)/lib -INSTALL_MAN_DIR ?= $(INSTALL_PREFIX)/share/man - -INSTALL_OWNER ?= root -INSTALL_GROUP ?= root +include install.mk # # targets # CONFIGS = configure.mk configure.h -SUBDIRS = src tests tools +SUBDIRS_BUILD = src tests tools +SUBDIRS_INSTALL = src doc -.PHONY: tarball install ctags cstags clean dist-clean $(SUBDIRS) +.PHONY: tarball install ctags cstags clean dist-clean $(SUBDIRS_BUILD) -all: $(SUBDIRS) +all: $(SUBDIRS_BUILD) $(CONFIGS): @echo "INFO: automatically generating configuration ..."; \ @@ -68,10 +60,6 @@ tarball: clean mv $$tmp_dir/$$tarball ..; \ rm -rf $$tmp_dir; -install: $(SUBDIRS) - @echo "INFO: installing files in $(INSTALL_PREFIX)" - @echo "- XXX - TBD" - $(VERSION_HDR): version_info @echo "INFO: creating the version header file" @hdr="$(VERSION_HDR)"; \ @@ -82,10 +70,17 @@ $(VERSION_HDR): version_info echo "#define VERSION_RELEASE \"$$VERSION_RELEASE\"" >> $$hdr; \ echo "#endif" >> $$hdr; -$(SUBDIRS): $(VERSION_HDR) $(CONFIGS) - @echo "INFO: entering directory $@/ ..." +$(SUBDIRS_BUILD): $(VERSION_HDR) $(CONFIGS) + @echo "INFO: building in directory $@/ ..." @$(MAKE) -s -C $@ +install: $(SUBDIRS_BUILD) + @echo "INFO: installing in $(INSTALL_PREFIX) ..." + @for dir in $(SUBDIRS_INSTALL); do \ + echo "INFO: installing from $$dir/"; \ + $(MAKE) -s -C $$dir install; \ + done + ctags: @echo "INFO: generating ctags for the project ..." @ctags -R * @@ -96,7 +91,7 @@ cstags: @cscope -b -q -k clean: - @for dir in $(SUBDIRS); do \ + @for dir in $(SUBDIRS_BUILD); do \ echo "INFO: cleaning in $$dir/"; \ $(MAKE) -s -C $$dir clean; \ done diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..1086e31 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,56 @@ +# +# Enhanced Seccomp Library Makefile +# +# Copyright (c) 2012 Red Hat <pmoore@redhat.com> +# Author: Paul Moore <pmoore@redhat.com> +# + +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# +# macros +# + +include ../macros.mk + +# +# configuration +# + +include ../configure.mk +include ../install.mk +include ../version_info + +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 \ + +# +# targets +# + +.PHONY: all install install_man3 + +all: + +install: install_man3 + +install_man3: $(MAN3) + $(INSTALL_MACRO) share/man/man3 "manpages" diff --git a/install.mk b/install.mk new file mode 100644 index 0000000..b1e60a0 --- /dev/null +++ b/install.mk @@ -0,0 +1,30 @@ +# +# Enhanced Seccomp Library Installation Defaults +# +# Copyright (c) 2012 Red Hat <pmoore@redhat.com> +# Author: Paul Moore <pmoore@redhat.com> +# + +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +INSTALL_PREFIX ?= $(CONF_INSTALL_PREFIX) + +INSTALL_SBIN_DIR ?= $(INSTALL_PREFIX)/sbin +INSTALL_BIN_DIR ?= $(INSTALL_PREFIX)/bin +INSTALL_LIB_DIR ?= $(INSTALL_PREFIX)/lib +INSTALL_MAN_DIR ?= $(INSTALL_PREFIX)/share/man + +INSTALL_OWNER ?= $$(id -u) +INSTALL_GROUP ?= $$(id -g) @@ -22,13 +22,13 @@ SHELL = /bin/bash # -# simple /bin/sh script to find the top of the tree +# simple /bin/bash script to find the top of the tree # -TOPDIR = $$( \ +TOPDIR = $$(\ ftd() { \ cd $$1; \ - if [ -r "macros.mk" ]; then \ + if [[ -r "macros.mk" ]]; then \ pwd; \ else \ ftd "../"; \ @@ -59,6 +59,8 @@ SED ?= sed # we require gcc specific functionality GCC ?= gcc +INSTALL ?= install + # # auto dependencies # @@ -81,7 +83,7 @@ ADDDEP = \ # build constants # -VERSION_HDR = src/version.h +VERSION_HDR = version.h # # build macros @@ -91,7 +93,26 @@ ARCHIVE = @echo " AR $@ (add/update: $?)"; $(AR) -cru $@ $?; COMPILE = @echo " CC $@"; $(GCC) $(CFLAGS) $(INCFLAGS) -o $@ -c $<; COMPILE_EXEC = @echo " CC $@"; $(GCC) $(CFLAGS) $(INCFLAGS) -o $@ $< $(LDFLAGS); LINK_EXEC = @echo " LD $@"; $(GCC) $(LDFLAGS) -o $@ $^ $(LIBFLAGS); -LINK_LIB = @echo " LD $@ "; $(GCC) $(LDFLAGS) -o $@ $^ -shared -Wl,-soname=$@; +LINK_LIB = @echo " LD $@"; $(GCC) $(LDFLAGS) -o $@ $^ -shared -Wl,-soname=$@; + +# +# install macros +# + +INSTALL_MACRO = \ + @install_func() { \ + dir="$(INSTALL_PREFIX)"/"$$1"; \ + if [[ -n "$$2" ]]; then \ + $(ECHO) " INSTALL $$2"; \ + else \ + $(ECHO) " INSTALL $^ ($$dir/$^)"; \ + fi; \ + $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ + -d "$$dir"; \ + $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \ + $^ "$$dir"; \ + }; \ + install_func # # default build targets diff --git a/src/.gitignore b/src/.gitignore index 6702033..98755dd 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1 @@ -version.h +libseccomp.so.* diff --git a/src/Makefile b/src/Makefile index 036e34c..0c62dd7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -29,13 +29,15 @@ include ../macros.mk # configuration # --include ../configure.mk +include ../configure.mk +include ../install.mk include ../version_info LIB_STATIC = libseccomp.a LIB_SHARED = libseccomp.so.$(VERSION_RELEASE) -OBJS = api.o db.o \ +OBJS = \ + api.o db.o \ arch.o arch-i386.o \ hash.o \ gen_pfc.o gen_bpf.o @@ -46,7 +48,7 @@ DEPS = $(OBJS:%.o=%.d) # targets # -.PHONY: all clean +.PHONY: all install clean all: $(LIB_STATIC) $(LIB_SHARED) @@ -58,5 +60,8 @@ $(LIB_STATIC): $(OBJS) $(LIB_SHARED): $(OBJS) $(LINK_LIB) +install: $(LIB_SHARED) + $(INSTALL_MACRO) lib + clean: $(RM) -f $(DEPS) $(OBJS) $(LIB_STATIC) $(LIB_SHARED) |