From 88d8d67e1c4470e479ba46f0c51aac7f3bada3cc Mon Sep 17 00:00:00 2001
From: Mick Jordan <mick.jordan@oracle.com>
Date: Fri, 10 Apr 2015 08:39:44 -0700
Subject: [PATCH] native: avoid include of platform.mk on clean

---
 com.oracle.truffle.r.native/builtinlibs/Makefile             | 2 ++
 com.oracle.truffle.r.native/fficall/jni/Makefile             | 2 ++
 com.oracle.truffle.r.native/gnur/Makefile.gnur               | 5 +++++
 com.oracle.truffle.r.native/gnur/Makefile.libs               | 2 ++
 com.oracle.truffle.r.native/library/lib.mk                   | 2 ++
 .../packages/testrffi/src/src/Makefile                       | 2 ++
 com.oracle.truffle.r.test.native/urand/Makefile              | 2 ++
 .../rpackages/rffi/testrffi/src/Makefile                     | 2 ++
 8 files changed, 19 insertions(+)

diff --git a/com.oracle.truffle.r.native/builtinlibs/Makefile b/com.oracle.truffle.r.native/builtinlibs/Makefile
index cb12f95b38..723a87ff99 100644
--- a/com.oracle.truffle.r.native/builtinlibs/Makefile
+++ b/com.oracle.truffle.r.native/builtinlibs/Makefile
@@ -28,7 +28,9 @@
 # that refers to GnuR-internal symbols.
 #
 
+ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
+endif
 
 .PHONY: all clean cleanlib cleanobj force libr
 
diff --git a/com.oracle.truffle.r.native/fficall/jni/Makefile b/com.oracle.truffle.r.native/fficall/jni/Makefile
index 273f98512c..3f14954c3d 100644
--- a/com.oracle.truffle.r.native/fficall/jni/Makefile
+++ b/com.oracle.truffle.r.native/fficall/jni/Makefile
@@ -25,7 +25,9 @@ ifeq ($(TOPDIR),)
     TOPDIR = $(abspath ../..)
 endif
 
+ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
+endif
 
 .PHONY: all clean
 
diff --git a/com.oracle.truffle.r.native/gnur/Makefile.gnur b/com.oracle.truffle.r.native/gnur/Makefile.gnur
index c5c581f7ed..108538b086 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile.gnur
+++ b/com.oracle.truffle.r.native/gnur/Makefile.gnur
@@ -77,6 +77,11 @@ build: $(GNUR_DIR)/bin/R
 $(GNUR_DIR)/bin/R: $(GNUR_DIR)/Makeconf 
 	(cd $(GNUR_DIR); make >& gnur_make.log)
 
+HAVE_MAKEFILE := $(shell [ -f $(GNUR_DIR)/Makefile ] && echo "Makefile.exists")
+ifeq ($(HAVE_MAKEFILE),Makefile.exists)
 clean:
 	rm -f Makeconf.done
 	(cd $(GNUR_DIR); make distclean)
+else
+clean:
+endif
diff --git a/com.oracle.truffle.r.native/gnur/Makefile.libs b/com.oracle.truffle.r.native/gnur/Makefile.libs
index ca45fa3b5a..43739766d2 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile.libs
+++ b/com.oracle.truffle.r.native/gnur/Makefile.libs
@@ -23,7 +23,9 @@
 
 # Copies the Blas and lapack libraries and builds the pcre library
 
+ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
+endif
 
 TARGET_DIR := $(TOPDIR)/builtinlibs/lib
 BLAS_TARGET := $(TARGET_DIR)/libRblas$(DYLIB_EXT)
diff --git a/com.oracle.truffle.r.native/library/lib.mk b/com.oracle.truffle.r.native/library/lib.mk
index 4e129f6588..c9322d1ca0 100644
--- a/com.oracle.truffle.r.native/library/lib.mk
+++ b/com.oracle.truffle.r.native/library/lib.mk
@@ -30,7 +30,9 @@
 # A package that requires special processing before the library is built should
 # define LIB_PKG_PRE and for post processing define LIB_PKG_POST
 
+ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
+endif
 
 .PHONY: all clean cleanlib cleanobj force libr libcommon 
 
diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/src/src/Makefile b/com.oracle.truffle.r.test.native/packages/testrffi/src/src/Makefile
index ca69da5ac0..4419b3fcf6 100644
--- a/com.oracle.truffle.r.test.native/packages/testrffi/src/src/Makefile
+++ b/com.oracle.truffle.r.test.native/packages/testrffi/src/src/Makefile
@@ -29,7 +29,9 @@ C_OBJECTS := $(C_SOURCES:.c=.o)
 C_LIB := testrffi.so
 
 NATIVE_PROJECT=$(FASTR_HOME)/com.oracle.truffle.r.native
+ifneq ($(MAKECMDGOALS),clean)
 include $(NATIVE_PROJECT)/platform.mk
+endif
 
 ifeq ($(FASTR_INSTALL), GNUR)
     INCLUDES := -I $(R_HOME)/include
diff --git a/com.oracle.truffle.r.test.native/urand/Makefile b/com.oracle.truffle.r.test.native/urand/Makefile
index 65bb933d03..4fe68d6161 100644
--- a/com.oracle.truffle.r.test.native/urand/Makefile
+++ b/com.oracle.truffle.r.test.native/urand/Makefile
@@ -27,7 +27,9 @@ endif
 
 NATIVE_PROJECT = $(subst test.native,native,$(TOPDIR))
 
+ifneq ($(MAKECMDGOALS),clean)
 include $(NATIVE_PROJECT)/platform.mk
+endif
 
 .PHONY: all clean
 
diff --git a/com.oracle.truffle.r.test/rpackages/rffi/testrffi/src/Makefile b/com.oracle.truffle.r.test/rpackages/rffi/testrffi/src/Makefile
index 73ab7c69aa..abd870b114 100644
--- a/com.oracle.truffle.r.test/rpackages/rffi/testrffi/src/Makefile
+++ b/com.oracle.truffle.r.test/rpackages/rffi/testrffi/src/Makefile
@@ -29,7 +29,9 @@ C_OBJECTS := $(C_SOURCES:.c=.o)
 C_LIB := testrffi.so
 
 NATIVE_PROJECT=$(FASTR_HOME)/com.oracle.truffle.r.native
+ifneq ($(MAKECMDGOALS),clean)
 include $(NATIVE_PROJECT)/platform.mk
+endif
 
 ifeq ($(FASTR_INSTALL), GNUR)
     INCLUDES := -I $(R_HOME)/include
-- 
GitLab