From eaa681d8181700ace30719f0f1101b1c92c28e9a Mon Sep 17 00:00:00 2001
From: Mick Jordan <mick.jordan@oracle.com>
Date: Thu, 9 Apr 2015 16:02:12 -0700
Subject: [PATCH] native build fixes for unit tests

---
 .hgignore                                            |  2 ++
 com.oracle.truffle.r.native/gnur/Makefile            |  3 +++
 com.oracle.truffle.r.native/gnur/Makefile.libs       |  2 +-
 com.oracle.truffle.r.native/gnur/Makefile.platform   |  2 +-
 com.oracle.truffle.r.native/library/base/Makefile    | 12 ++++++++----
 .../packages/testrffi/src/src/Makefile               |  2 +-
 6 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/.hgignore b/.hgignore
index 1cb5e1e72c..8af9c89293 100644
--- a/.hgignore
+++ b/.hgignore
@@ -91,6 +91,8 @@ R.tokens
 findbugs.html
 com.oracle.truffle.r.native/builtinlibs/lib/*
 com.oracle.truffle.r.native/library/*/lib/*
+com.oracle.truffle.r.native/platform.mk
+com.oracle.truffle.r.native/gnur/Makeconf.done
 com.oracle.truffle.r.native/include/jni/include
 com.oracle.truffle.r.native/include/jni/linked
 com.oracle.truffle.r.test.native/packages/*/lib/*
diff --git a/com.oracle.truffle.r.native/gnur/Makefile b/com.oracle.truffle.r.native/gnur/Makefile
index 1d878478b8..a4468ffc2a 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile
+++ b/com.oracle.truffle.r.native/gnur/Makefile
@@ -25,8 +25,11 @@
 
 all: 
 	$(MAKE) -f Makefile.gnur
+	$(MAKE) -f Makefile.platform
 	$(MAKE) -f Makefile.libs
 
 clean:
 	$(MAKE) -f Makefile.gnur clean
 	$(MAKE) -f Makefile.libs clean
+	$(MAKE) -f Makefile.platform clean
+	
\ No newline at end of file
diff --git a/com.oracle.truffle.r.native/gnur/Makefile.libs b/com.oracle.truffle.r.native/gnur/Makefile.libs
index 57e6ab3270..ca45fa3b5a 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile.libs
+++ b/com.oracle.truffle.r.native/gnur/Makefile.libs
@@ -21,7 +21,7 @@
 # questions.
 #
 
-# Copies the Lbas and lapack libraries and builds the pcre library
+# Copies the Blas and lapack libraries and builds the pcre library
 
 include $(TOPDIR)/platform.mk
 
diff --git a/com.oracle.truffle.r.native/gnur/Makefile.platform b/com.oracle.truffle.r.native/gnur/Makefile.platform
index bff6250fe8..e38dbff2ef 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile.platform
+++ b/com.oracle.truffle.r.native/gnur/Makefile.platform
@@ -34,7 +34,7 @@ $(TOPDIR)/platform.mk: sedMakeconf
 	sed -f sedMakeconf $(GNUR_DIR)/Makeconf >& /dev/null
 	echo OS_NAME = $(OS_NAME) >> platform.mk.temp
 	echo OS_DIR = $(OS_DIR) >> platform.mk.temp
-	cp platform.mk.temp $(TOPDIR)/platform.mk
+	mv platform.mk.temp $(TOPDIR)/platform.mk
 
 clean:
 	rm -f $(TOPDIR)/platform.mk
diff --git a/com.oracle.truffle.r.native/library/base/Makefile b/com.oracle.truffle.r.native/library/base/Makefile
index e5c14fcd55..7ca188ab76 100644
--- a/com.oracle.truffle.r.native/library/base/Makefile
+++ b/com.oracle.truffle.r.native/library/base/Makefile
@@ -21,13 +21,17 @@
 # questions.
 #
 
-PKG_EXTRAS = $(FASTR_LIBDIR)/$(PKG)/R/Rprofile
+RPROFILE := $(FASTR_LIBDIR)/base/R/Rprofile
+RPROFILE_ORIG := $(RPROFILE).orig
+PKG_EXTRAS = $(RPROFILE)
 
 include ../lib.mk
 
 # edit the Rprofile to add fastr as a default package
+# sed's edit in place option with backup is not portable
 
-$(PKG_EXTRAS): $(FASTR_LIBDIR)/$(PKG)/R/Rprofile.orig
+$(PKG_EXTRAS): $(RPROFILE_ORIG)
 
-$(FASTR_LIBDIR)/$(PKG)/R/Rprofile.orig:
-	sed -f sed_profile -i .orig $(FASTR_LIBDIR)/$(PKG)/R/Rprofile
+$(RPROFILE_ORIG):
+	cp $(RPROFILE) $(RPROFILE_ORIG)
+	sed -f sed_profile $(RPROFILE_ORIG) > $(RPROFILE)
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 688c4e2c39..ca69da5ac0 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
@@ -47,7 +47,7 @@ endif
 all: $(C_LIB)
 
 $(C_LIB): $(C_OBJECTS)
-	$(CC) $(LDFLAGS)  -o $(C_LIB) $(C_OBJECTS)
+	$(DYLIB_LD) $(DYLIB_LDFLAGS)  -o $(C_LIB) $(C_OBJECTS)
 
 %.o: %.c
 	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
-- 
GitLab