Bug: #898142
--- a/jni/GNUmakefile
+++ b/jni/GNUmakefile
@@ -67,9 +67,11 @@ OFLAGS = -O2 $(JFLAGS)
 WERROR = -Werror
 ifneq ($(OS),darwin)
 ifneq ($(OS),aix)
+ifneq ($(OS),linux)
   WFLAGS += -Wundef $(WERROR)
 endif
 endif
+endif
 WFLAGS += -W -Wall -Wno-unused -Wno-parentheses -Wno-unused-parameter
 PICFLAGS = -fPIC
 SOFLAGS = # Filled in for each OS specifically
@@ -278,7 +280,7 @@ debug:
 	@echo "OBJS=$(OBJS)"
 
 $(LIBJFFI):  $(OBJS) $(LIBFFI_LIBS)
-	$(CC) -o $@ $(LDFLAGS) $(SOFLAGS) $(OBJS) $(LIBFFI) $(LIBS)
+	$(CC) -o $@ $(LDFLAGS) $(SOFLAGS) $(OBJS) $(LIBFFI) $(LIBS) $(LIBFFI_LIBS)
 	$(STRIP) $@
 ifeq ($(OS), darwin)
 	codesign -s - $@
@@ -287,10 +289,14 @@ endif
 $(BUILD_DIR)/%.o : $(SRC_DIR)/%.c $(wildcard $(JFFI_SRC_DIR)/*.h)
 	@mkdir -p $(@D)
 	@$(CCACHE) $(CC) $(CFLAGS) -c $< -o $@
+	mkdir -p $(@D)
+	$(CCACHE) $(CC) $(CFLAGS) -c $< -o $@
 
 $(BUILD_DIR)/%.o : $(SRC_DIR)/%.S $(wildcard $(JFFI_SRC_DIR)/*.h)
 	@mkdir -p $(@D)
 	@$(CC) $(CFLAGS) -o $@ -c $<
+	mkdir -p $(@D)
+	$(CC) $(CFLAGS) -o $@ -c $<
 
 $(OBJS) : $(LIBFFI)
 
