apparmor/changehat/mod_apparmor/Makefile

96 lines
3.5 KiB
Makefile
Raw Normal View History

# ----------------------------------------------------------------------
# Copyright (c) 2004, 2005 NOVELL (All rights reserved)
#
# 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 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, contact Novell, Inc.
# ----------------------------------------------------------------------
NAME:=apache2-mod_apparmor
all:
COMMONDIR=../../common/
include common/Make.rules
COMMONDIR_EXISTS=$(strip $(shell [ -d ${COMMONDIR} ] && echo true))
ifeq ($(COMMONDIR_EXISTS), true)
common/Make.rules: $(COMMONDIR)/Make.rules
ln -sf $(COMMONDIR) .
endif
TARGET:=mod_apparmor.so
MANPAGES=mod_apparmor.8
APXS:=$(shell if [ -x "/usr/sbin/apxs2" ] ; then \
echo "/usr/sbin/apxs2" ; \
elif [ -x "/usr/sbin/apxs" ] ; then \
echo "/usr/sbin/apxs" ; \
elif [ -x "/usr/bin/apxs2" ] ; then \
echo "/usr/bin/apxs2" ; \
elif [ -x "/usr/bin/apxs" ] ; then \
echo "/usr/bin/apxs" ; \
else \
echo "apxs" ; \
fi )
APXS_INSTALL_DIR=$(shell ${APXS} -q LIBEXECDIR)
DESTDIR=
ifdef USE_SYSTEM
LIBAPPARMOR = $(shell if pkg-config --exists libapparmor ; then \
pkg-config --silence-errors --libs libapparmor ; \
elif ldconfig -p | grep -q libapparmor\.so$$ ; then \
echo -lapparmor ; \
fi )
ifeq ($(strip $(LIBAPPARMOR)),)
ERROR_MESSAGE = Unable to find libapparmor installed on this system; either \
install libapparmor devel packages, set the LIBAPPARMOR variable \
manually, or build against in-tree libapparmor)
endif # LIBAPPARMOR not set
LDLIBS += $(LIBAPPARMOR)
else
LIBAPPARMOR_SRC := ../../libraries/libapparmor/
LIBAPPARMOR_INCLUDE = $(LIBAPPARMOR_SRC)/include
LIBAPPARMOR_PATH := $(LIBAPPARMOR_SRC)/src/.libs/
ifeq ($(realpath $(LIBAPPARMOR_PATH)/libapparmor.a),)
ERROR_MESSAGE = $(LIBAPPARMOR_PATH)/libapparmor.a is missing; either build against \
the in-tree libapparmor by building it first and then trying again \
(see the top-level README for help) or build against the system \
libapparmor by adding USE_SYSTEM=1 to your make command.)
endif
# Need to pass -Wl twice here to get past both apxs2 and libtool, as
# libtool will add the path to the RPATH of the library if passed -L/some/path
LIBAPPARMOR_FLAGS = -I$(LIBAPPARMOR_INCLUDE) -Wl,-Wl,-L$(LIBAPPARMOR_PATH)
LDLIBS = -lapparmor
endif
.PHONY: libapparmor_check
.SILENT: libapparmor_check
libapparmor_check:
@if [ -n "$(ERROR_MESSAGE)" ] ; then \
echo "$(ERROR_MESSAGE)" 1>&2 ; \
return 1 ; \
fi
all: libapparmor_check $(TARGET) ${MANPAGES} ${HTMLMANPAGES}
%.so: %.c
${APXS} ${LIBAPPARMOR_FLAGS} -c $< ${LDLIBS}
mv .libs/$@ .
.PHONY: install
install: ${TARGET} ${MANPAGES}
mkdir -p ${DESTDIR}/${APXS_INSTALL_DIR}
install -m 755 $< ${DESTDIR}/${APXS_INSTALL_DIR}
make install_manpages DESTDIR=${DESTDIR}
.PHONY: clean
clean: _clean
rm -rf .libs
rm -f *.la *.lo *.so *.o *.slo Make.rules