1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
# ENCAP_PKG([mkencap-options], [install target if enabled],
# [install target if disabled])
# ---------------------------------------------------------
# Check for Encap tools.
AC_DEFUN([ENCAP_PKG], [
MKENCAP_OPTS=$1;
# allow user to disable Encap support
AC_ARG_ENABLE([encap],
[ --disable-encap Do not configure as an Encap package],
[],
[enable_encap=default])
if test "$enable_encap" != "no"; then
# look for epkg and mkencap
AC_PATH_PROG([EPKG], [epkg])
AC_PATH_PROG([MKENCAP], [mkencap])
# enable by default if epkg or mkencap are found
if test "${EPKG:+set}" = "set" || test "${MKENCAP:+set}" = "set" && test "$enable_encap" = "default"; then
enable_encap=yes;
fi
fi
if test "$enable_encap" = "yes"; then
# generate fallback values for ${ENCAP_SOURCE} and ${ENCAP_TARGET}
# from the environment or the default prefix
if test -z "${ENCAP_SOURCE}" && test -z "${ENCAP_TARGET}"; then
ENCAP_SOURCE="${ac_default_prefix}/encap";
ENCAP_TARGET="${ac_default_prefix}";
elif test -z "${ENCAP_TARGET}"; then
ENCAP_TARGET="`dirname ${ENCAP_SOURCE}`";
elif test -z "${ENCAP_SOURCE}"; then
ENCAP_SOURCE="${ENCAP_TARGET}/encap";
fi
# if --prefix is specified:
# 1) if its next-to-last component is "encap", assume that it
# points to the package directory
# 2) otherwise, assume it points to the target directory
if test "${prefix}" != "NONE"; then
prefixdir="`dirname ${prefix}`";
prefixbase="`basename ${prefix}`";
if test "`basename ${prefixdir}`" = "encap"; then
ENCAP_SOURCE="${prefixdir}";
ENCAP_TARGET="`dirname ${ENCAP_SOURCE}`";
elif test "${prefixdir}" != "${ENCAP_SOURCE}"; then
ENCAP_SOURCE="${prefix}/encap";
ENCAP_TARGET="${prefix}";
fi
if ( test "`basename ${prefixdir}`" = "encap" || \
test "${prefixdir}" = "${ENCAP_SOURCE}" ) && \
test "${prefixbase}" != "${PACKAGE_NAME}-${PACKAGE_VERSION}"; then
ENCAP_PKGSPEC="${prefixbase}";
fi
fi
# display results
AC_MSG_CHECKING([for Encap source directory])
AC_MSG_RESULT([${ENCAP_SOURCE}])
AC_MSG_CHECKING([for Encap target directory])
AC_MSG_RESULT([${ENCAP_TARGET}])
AC_MSG_CHECKING([for Encap package directory])
if test "${ENCAP_PKGSPEC:-unset}" = "unset"; then
ENCAP_PKGSPEC='${PACKAGE_NAME}-${PACKAGE_VERSION}';
AC_MSG_RESULT([${ENCAP_SOURCE}/${PACKAGE_NAME}-${PACKAGE_VERSION}])
else
AC_MSG_RESULT([${ENCAP_SOURCE}/${ENCAP_PKGSPEC}])
fi
prefix='${ENCAP_SOURCE}/${ENCAP_PKGSPEC}';
# override default sysconfdir and localstatedir
if test "$sysconfdir" = '${prefix}/etc'; then
sysconfdir='${ENCAP_TARGET}/etc';
fi
if test "$localstatedir" = '${prefix}/var'; then
localstatedir='/var/lib/${PACKAGE_NAME}';
fi
# check for --disable-epkg-install
AC_ARG_ENABLE([epkg-install],
[ --disable-epkg-install Do not run epkg during make install],
[],
[enable_epkg_install=yes])
if test "$enable_epkg_install" = "no"; then
EPKG=":";
fi
# generate Makefile variables
dnl AC_SUBST([ENCAP_SOURCE])
dnl AC_SUBST([ENCAP_TARGET])
dnl AC_SUBST([ENCAP_PKGSPEC])
dnl AC_SUBST([EPKG])
dnl AC_SUBST([MKENCAP])
dnl AC_SUBST([MKENCAP_OPTS])
dnl
dnl m4_ifdef([EM_MAKEFILE_END], [
dnl # generate rules for make install target
dnl EM_MAKEFILE_END([[
dnl target modify <install>:
dnl command \\\${MKENCAP} \\\`test -f \\\${srcdir}/COPYRIGHT && echo -I \\\${srcdir}/COPYRIGHT\\\` \\\${MKENCAP_OPTS} -s \\\${DESTDIR}\\\${ENCAP_SOURCE} -e \\\${ENCAP_PKGSPEC}
dnl command if test -z \\\\\"\\\${DESTDIR}\\\\\"; then \
dnl \\\${EPKG} -s \\\${ENCAP_SOURCE} -t \\\${ENCAP_TARGET} \\\${ENCAP_PKGSPEC}; \
dnl fi
dnl ]])])
ENCAP_DEFS="ENCAP_SOURCE = ${ENCAP_SOURCE}\\
ENCAP_TARGET = ${ENCAP_TARGET}\\
ENCAP_PKGSPEC = ${ENCAP_PKGSPEC}\\
EPKG = ${EPKG:-:}\\
MKENCAP = ${MKENCAP:-:}\\
MKENCAP_OPTS = ${MKENCAP_OPTS}";
AC_SUBST([ENCAP_DEFS])
dnl ### generate rules for make install target
ENCAP_INSTALL_RULES='if test -f ${top_srcdir}/COPYRIGHT; then \\\
${INSTALL_DATA} ${top_srcdir}/COPYRIGHT ${ENCAP_SOURCE}/${ENCAP_PKGSPEC}; \\\
fi\
${MKENCAP} ${MKENCAP_OPTS} -s ${DESTDIR}${ENCAP_SOURCE} -e ${ENCAP_PKGSPEC};\
if test -z \"${DESTDIR}\"; then \\\
${EPKG} -s ${ENCAP_SOURCE} -t ${ENCAP_TARGET} ${ENCAP_PKGSPEC}; \\\
fi';
AC_SUBST([ENCAP_INSTALL_RULES])
ENCAP_INSTALL_TARGET=$2
else
ENCAP_INSTALL_TARGET=$3
fi
AC_SUBST([ENCAP_INSTALL_TARGET])
])
|