Index: /trunk/src/kmk/function.c
===================================================================
--- /trunk/src/kmk/function.c	(revision 1726)
+++ /trunk/src/kmk/function.c	(revision 1727)
@@ -2724,5 +2724,4 @@
     if (e1 - s1 != e2 - s2)
       return comp_vars_ne (o, s1, e1, s2, e2, argv[2], funcname);
-l_simple_compare:
     if (!memcmp (s1, s2, e1 - s1))
       return variable_buffer_output (o, "", 0);     /* eq */
@@ -3089,5 +3088,44 @@
   return variable_buffer_output (o, "", 0);
 }
-#endif
+#endif /* CONFIG_WITH_WHICH */
+
+#ifdef CONFIG_WITH_IF_CONDITIONALS
+
+/* Evaluates the expression given in the argument using the
+   same evaluator as for the new 'if' statements, except now
+   we don't force the result into a boolean like for 'if' and
+   '$(if-expr ,,)'. */
+static char *
+func_expr (char *o, char **argv, const char *funcname UNUSED)
+{
+  o = expr_eval_to_string (o, argv[0]);
+  return o;
+}
+
+/* Same as '$(if ,,)' except the first argument is evaluated
+   using the same evaluator as for the new 'if' statements. */
+static char *
+func_if_expr (char *o, char **argv, const char *funcname UNUSED)
+{
+    int rc;
+    char *to_expand;
+
+    /* Evaluate the condition in argv[0] and expand the 2nd or
+       3rd argument according to the result. */
+    rc = expr_eval_if_conditionals (argv[0], NULL);
+    to_expand = rc == 0 ? argv[1] : argv[2];
+    if (*to_expand)
+      {
+        char *expansion = expand_argument (to_expand, NULL);
+
+        o = variable_buffer_output (o, expansion, strlen (expansion));
+
+        free (expansion);
+      }
+
+    return o;
+}
+
+#endif /* CONFIG_WITH_IF_CONDITIONALS */
 
 #ifdef CONFIG_WITH_STACK
@@ -3108,5 +3146,4 @@
   struct variable *stack_var;
   const char *stack = argv[0];
-  const int return_item = argv[0][sizeof("stack-pop") - 1] == '\0';
 
   stack_var = lookup_variable (stack, strlen (stack) );
@@ -3959,4 +3996,8 @@
   { STRING_SIZE_TUPLE("which"),         0,  0,  1,  func_which},
 #endif
+#ifdef CONFIG_WITH_IF_CONDITIONALS
+  { STRING_SIZE_TUPLE("expr"),          1,  1,  0,  func_expr},
+  { STRING_SIZE_TUPLE("if-expr"),       2,  3,  0,  func_if_expr},
+#endif
 #ifdef CONFIG_WITH_STACK
   { STRING_SIZE_TUPLE("stack-push"),    2,  2,  1,  func_stack_push},
Index: /trunk/src/kmk/testcase-ifcond.kmk
===================================================================
--- /trunk/src/kmk/testcase-ifcond.kmk	(revision 1726)
+++ /trunk/src/kmk/testcase-ifcond.kmk	(revision 1727)
@@ -26,6 +26,6 @@
 
 
-#DEPTH = ../..
-#include $(PATH_KBUILD)/header.kmk
+DEPTH = ../..
+include $(KBUILD_PATH)/header.kmk
 
 ifeq (1,0)
@@ -223,4 +223,5 @@
 # target()
 #
+if 0
 trg_deps_only: foobar
 trg_with_cmds: foobar
@@ -230,9 +231,9 @@
 $(warning works)
 else
-$(error works)
+$(error target)
 endif
 
 if target trg_deps_only
-$(error works)
+$(error target)
 else
 $(warning works)
@@ -240,8 +241,9 @@
 
 if target foobar
-$(error works)
-else
-$(warning works)
-endif
+$(error target)
+else
+$(warning works)
+endif
+endif 
 
 
@@ -255,5 +257,5 @@
 $(warning works)
 else
-$(error works)
+$(error )
 endif
 
@@ -261,5 +263,5 @@
 $(warning works)
 else
-$(error works)
+$(error )
 endif
 
@@ -267,11 +269,45 @@
 $(warning works)
 else
-$(error works)
+$(error )
 endif
 
 if defined (var_not_defined)
-$(error works)
-else
-$(warning works)
+$(error )
+else
+$(warning works)
+endif
+
+
+#
+# Quick check of $(if-expr ) and $(expr ).
+#
+ifeq ($(if-expr 0 || 2,42,500),42)
+$(warning if-expr test 1 succeeded)
+else
+$(error )
+endif
+
+ifeq ($(if-expr 5+3 == 231,42,500),42)
+$(error )
+else
+$(warning if-expr test 2 succeeded)
+endif
+
+ifeq ($(expr 5+3),8)
+$(warning expr test 1 succeeded)
+else
+$(error expr:$(expr 5+3) expected 8)
+endif
+
+ifeq ($(expr 25*25),625)
+$(warning expr test 2 succeeded)
+else
+$(error expr:$(expr 25*25) expected 625)
+endif
+
+ifeq ($(expr 100/3),3)
+$(error )
+else
+$(warning expr test 3 succeeded)
 endif
 
