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