--- bsd.port.mk 2011-08-23 06:59:56.418030776 +0200 +++ bsd.port.mk 2011-08-23 18:07:27.663775068 +0200 @@ -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,12 @@ # 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. +## # USE_BZIP2 - If set, this port tarballs use bzip2, not gzip, for # compression. # USE_XZ - If set, this port tarballs use xz (or lzma) @@ -1361,6 +1377,29 @@ WWWDIR?= ${PREFIX}/www/${PORTNAME} ETCDIR?= ${PREFIX}/etc/${PORTNAME} +.if defined(USE_SRC) +. if exists(${SRC_BASE}/sys/sys/param.h) +_SRC_OSVERSION!= ${AWK} '/^\#define[[:blank:]]__FreeBSD_version/ {print $$3}' < ${SRC_BASE}/sys/sys/param.h +. if ${OSVERSION} != ${_SRC_OSVERSION} +IGNORE= requires source files for OS version ${OSVERSION} +. endif +. endif + +. if !defined(${IGNORE}) +. 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 +.endif # defined(USE_SRC) + .if defined(USE_LINUX_RPM) .include "${PORTSDIR}/Mk/bsd.linux-rpm.mk" .endif @@ -3162,6 +3201,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))