Index: Mk/bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.682 diff -u -r1.682 bsd.port.mk --- Mk/bsd.port.mk 6 May 2011 06:20:12 -0000 1.682 +++ Mk/bsd.port.mk 9 May 2011 06:43:32 -0000 @@ -222,6 +222,16 @@ # - Set this instead of ONLY_FOR_ARCHS if the given port # fetches and installs compiled i386 binaries. # +# ONLY_FOR_OSVER +# - A space-separated list of OS versions the port can be built on. +# An OS version may be : +# - a single value (e.g. 700000), +# - a lower limit (e.g. 700000+), +# - a higher limit (e.g. 800000-), +# - a range (e.g. 700000-800000). +# ONLY_FOR_OSVER_REASON +# - Reason why it's only for ${ONLY_FOR_OSVER} +# # Dependency checking. Use these if your port requires another port # not in the list below. (Default: empty.) # @@ -295,6 +305,14 @@ # passed to the compiler by setting DEBUG_FLAGS. It is # set to "-g" at default. # +## +# USE_SRC - If set, this port needs kernel sources to build. +# If set to "yes", presence of ${SRC_BASE}/sys/Makefile +# is checked. If set to a space-separated list of files, +# presence of those files under ${SRC_BASE}/ is checked. +# SRC_BASE - Set to the base directory of your kernel sources +# Default: /usr/src +## # USE_BZIP2 - If set, this port tarballs use bzip2, not gzip, for # compression. # USE_XZ - If set, this port tarballs use xz (or lzma) @@ -1394,6 +1412,21 @@ WWWDIR?= ${PREFIX}/www/${PORTNAME} ETCDIR?= ${PREFIX}/etc/${PORTNAME} +.if defined(USE_SRC) +SRC_BASE?= /usr/src +. if ${USE_SRC:L} == "yes" +_SRC_CHECK_FILES= sys/Makefile +. else +_SRC_CHECK_FILES= ${USE_SRC} +.endif + +.for file in ${_SRC_CHECK_FILES} +. if !defined(${IGNORE}) && !exists(${SRC_BASE}/${file}) +IGNORE= requires kernel source files +. endif +.endfor +.endif # defined(USE_SRC) + .if defined(USE_LINUX_RPM) .include "${PORTSDIR}/Mk/bsd.linux-rpm.mk" .endif @@ -3257,6 +3290,63 @@ .endif +# Check for OS version compatibility +.if defined(ONLY_FOR_OSVER) + +# Sanity check +_ONLY_FOR_OSVER_CHECK:= ${ONLY_FOR_OSVER:C/^[[:digit:]]+((-[[:digit:]]+)|[-+])?$//} + +. if (${_ONLY_FOR_OSVER_CHECK}x != "x") +IGNORE= invalid value specified for ONLY_FOR_OSVER: ${_ONLY_FOR_OSVER_CHECK} +. else +_ONLY_FOR_OSVER_IGNORE= requires FreeBSD ${ONLY_FOR_OSVER} + +. for version in ${ONLY_FOR_OSVER} +_ONLY_FOR_OSVER:= ${version:C/\+$//} +. if ${_ONLY_FOR_OSVER} != "${version}" +# OSVERSION+ provided +_ONLY_FOR_MIN_OSVER:= ${_ONLY_FOR_OSVER} +. else +_ONLY_FOR_OSVER:= ${version:C/-$//} +. if ${_ONLY_FOR_OSVER} != "${version}" +# OSVERSION- provided +_ONLY_FOR_MAX_OSVER:= ${_ONLY_FOR_OSVER} +. else +_ONLY_FOR_OSVER:= ${version:C/-//} +. if ${_ONLY_FOR_OSVER} != "${version}" +# OSVERSION-OSVERSION range provided +_ONLY_FOR_MIN_OSVER:= ${version:C/-.*$//} +_ONLY_FOR_MAX_OSVER:= ${version:C/^.*-//} +. else +# single OSVERSION provided +_ONLY_FOR_MIN_OSVER:= ${version} +_ONLY_FOR_MAX_OSVER:= ${version} +. endif +. endif +. endif + +# Check OSVERSION against current requirements, one success is enough to continue +. if (!defined(_ONLY_FOR_MAX_OSVER) && (${OSVERSION} >= ${_ONLY_FOR_MIN_OSVER})) || \ + (!defined(_ONLY_FOR_MIN_OSVER) && (${OSVERSION} <= ${_ONLY_FOR_MAX_OSVER})) || \ + (defined(_ONLY_FOR_MIN_OSVER) && defined(_ONLY_FOR_MAX_OSVER) && \ + (${OSVERSION} >= ${_ONLY_FOR_MIN_OSVER}) && (${OSVERSION} <= ${_ONLY_FOR_MAX_OSVER})) +. undef _ONLY_FOR_OSVER_IGNORE +. endif + +. undef _ONLY_FOR_OSVER +. undef _ONLY_FOR_MIN_OSVER +. undef _ONLY_FOR_MAX_OSVER +. endfor + +. if defined(_ONLY_FOR_OSVER_IGNORE) +IGNORE= ${_ONLY_FOR_OSVER_IGNORE} +. if defined(ONLY_FOR_OSVER_REASON) +IGNORE+= (${ONLY_FOR_OSVER_REASON}) +. endif +. endif +. endif +.endif # defined(ONLY_FOR_OSVER) + # Check the user interaction and legal issues .if !defined(NO_IGNORE) .if (defined(IS_INTERACTIVE) && defined(BATCH))