diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 068b631c..76f08623 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1810,6 +1810,17 @@ def is_local_uid(uid=''):
                 return True
     return False
 
+def ifVarInRange(d, var, first=1, last=0, tval="", fval=""):
+    """
+    Return a value depending on whether a bitbake variable is in a numeric
+    range.  Conventionally, 0 as the emd pf the range matches all values.
+    """
+    try:
+        v = int(d.getVar(var))
+    except:
+        return fval
+    return tval if v >= first and (v <= last or last == 0) else fval
+
 def mkstemp(suffix=None, prefix=None, dir=None, text=False):
     """
     Generates a unique filename, independent of time.
