Skip to content
Snippets Groups Projects
Commit 68fe7aec authored by Mick Jordan's avatar Mick Jordan
Browse files

native build fixes for Linux; create platform.mk from GnuR info

parent dd11ddc6
No related branches found
No related tags found
No related merge requests found
Showing
with 158 additions and 105 deletions
......@@ -28,7 +28,7 @@
# that refers to GnuR-internal symbols.
#
include ../platform.mk
include $(TOPDIR)/platform.mk
.PHONY: all clean cleanlib cleanobj force libr
......@@ -41,22 +41,22 @@ C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
F_OBJECTS := $(wildcard $(GNUR_DIR)/src/appl/d*.o)
LIBDIR := $(OBJ)
LIB_APPL := $(OBJ)/libappl.$(SHARED_EXT)
LIB_APPL := $(OBJ)/libappl$(DYLIB_EXT)
all: $(LIB_APPL) libr
$(LIB_APPL): $(C_OBJECTS) $(F_OBJECTS)
mkdir -p $(LIBDIR)
$(CC) $(LDFLAGS) -o $(LIB_APPL) $(C_OBJECTS) $(F_OBJECTS) $(LIBS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_APPL) $(C_OBJECTS) $(F_OBJECTS) $(LIBS)
# On Darwin we need to create a dummy libR.dylib
ifeq ($(OSNAME), Darwin)
LIB_RDUMMY := $(OBJ)/libR.$(SHARED_EXT)
ifeq ($(OS_NAME), Darwin)
LIB_RDUMMY := $(OBJ)/libR$(DYLIB_EXT)
libr: $(LIB_RDUMMY)
$(LIB_RDUMMY): $(OBJ)/rdummy.o
mkdir -p $(LIBDIR)
$(CC) $(LDFLAGS) -o $(LIB_RDUMMY) -current_version $(R_VERSION) -compatibility_version $(R_VERSION) $(OBJ)/rdummy.o
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_RDUMMY) -current_version $(R_VERSION) -compatibility_version $(R_VERSION) $(OBJ)/rdummy.o
cleanlibr:
rm -f $(LIB_RDUMMY)
......@@ -71,10 +71,6 @@ endif
$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: $(SRC)/%.f
$(FC) $(CFLAGS) -c $< -o $@
cleanlib:
rm -f $(LIBDIR)/libappl.*
......
......@@ -32,9 +32,10 @@ include $(TOPDIR)/platform.mk
OBJ = lib
SRC = src
C_SOURCES := $(wildcard $(SRC)/*.c)
C_LIBNAME := librfficall.$(SHARED_EXT)
C_LIBNAME := librfficall$(DYLIB_EXT)
C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
C_LIB := $(TOPDIR)/builtinlibs/$(OBJ)/$(C_LIBNAME)
CFLAGS := $(CFLAGS) -DFASTR
JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(OS_DIR)
FFI_INCLUDES = -I$(TOPDIR)/include/jni/include -I$(TOPDIR)/include/jni/include/R_ext
......@@ -44,7 +45,7 @@ INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES)
all: $(C_LIB)
$(C_LIB): $(OBJ) $(C_OBJECTS)
$(CC) $(LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
$(OBJ):
mkdir -p $(OBJ)
......
......@@ -21,49 +21,12 @@
# questions.
#
# This extracts, configures and builds GnuR for the current platform.
# FastR does not, obviously, need all of GnuR to be built; only those pieces
# that it shares, but is simpler and safer to just build all of it. The relevant
# pieces are then copied to other FastR directories
.PHONY: all clean
include ../platform.mk
.PHONY: all clean config build copy
TARGET_DIR := ../builtinlibs/lib
BLAS_TARGET := $(TARGET_DIR)/libRblas.$(SHARED_EXT)
LAPACK_TARGET := $(TARGET_DIR)/libRlapack.$(SHARED_EXT)
export PCRE_TARGET := $(TARGET_DIR)/libpcre.$(SHARED_EXT)
all: Makefile $(GNUR_DIR) config build copy
$(GNUR_DIR):
tar xf $(TOPDIR)/../lib/R-$(R_VERSION).tar.gz
config: $(GNUR_DIR)/Makefile
$(GNUR_DIR)/Makefile:
(cd $(GNUR_DIR); ./configure --with-x=no --without-recommended-packages --enable-R-shlib >& /dev/null)
build: $(GNUR_DIR)/bin/R
$(GNUR_DIR)/bin/R:
(cd $(GNUR_DIR); make >& make.log)
copy: $(TARGET_DIR) $(BLAS_TARGET) $(LAPACK_TARGET) $(PCRE_TARGET)
$(TARGET_DIR):
mkdir -p $(TARGET_DIR)
$(BLAS_TARGET): $(GNUR_DIR)/lib/libRblas.$(SHARED_EXT)
cp $(GNUR_DIR)/lib/libRblas.$(SHARED_EXT) $(BLAS_TARGET)
$(LAPACK_TARGET): $(GNUR_DIR)/lib/libRlapack.$(SHARED_EXT)
cp $(GNUR_DIR)/lib/libRlapack.$(SHARED_EXT) $(LAPACK_TARGET)
$(PCRE_TARGET):
$(MAKE) -f Makefile.pcre
all:
$(MAKE) -f Makefile.gnur
$(MAKE) -f Makefile.libs
clean:
rm -rf $(GNUR_DIR)
rm -f $(BLAS_TARGET) $(LAPACK_TARGET) $(PCRE_TARGET)
$(MAKE) -f Makefile.gnur clean
$(MAKE) -f Makefile.libs clean
#
# Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# This extracts, configures and builds GnuR for the current platform.
# FastR does not, obviously, need all of GnuR to be built; only those pieces
# that it shares, but is simpler and safer to just build all of it. The relevant
# pieces are then copied to other FastR directories.
#
# The configuration of GnuR for FastR is platform specific and a special step
# is needed for Linux where, ordinarily, the PCRE library is compiled non-PIC
# as it is built as a library archive. FastR needs a shared library, which can be
# enabled by setting --enable-R-shlib, but unfortunately this also sets the visibility
# of the functions to hidden, so FastR cannot find them. There does not appear to be a
# way to fix this simply using configure args, so we patch up the Makeconf file.
# Portions of the Makeconf file are then extracted to use in building the native
# parts of FastR, especially packages with native code.
# Building GnuR takes several minutes, so in some environments, e.g. repository gates,
# referring to a pre-built GnuR would be of value. This is TBD.
.PHONY: all config config_update build clean
OSNAME := $(shell uname)
ifeq ($(OSNAME), Linux)
else ifeq ($(OSNAME), SunOS)
else ifeq ($(OSNAME), Darwin)
else
all:
@echo "This Makefile does not know how to compile for $(OSNAME)"
@false
endif
all: Makefile $(GNUR_DIR) config build
$(GNUR_DIR):
tar xf $(TOPDIR)/../lib/R-$(R_VERSION).tar.gz
config: $(GNUR_DIR)/Makefile config_update
ifeq ($(OSNAME), Linux)
config_update: Makeconf.done
Makeconf.done: edMakeconf
ed $(GNUR_DIR)/Makeconf < edMakeconf
touch Makeconf.done
else
config_update:
endif
$(GNUR_DIR)/Makefile:
(cd $(GNUR_DIR); ./configure --with-x=no --without-recommended-packages >& gnur_configure.log)
build: $(GNUR_DIR)/bin/R
$(GNUR_DIR)/bin/R: $(GNUR_DIR)/Makeconf
(cd $(GNUR_DIR); make >& gnur_make.log)
clean:
rm Makeconf.done
(cd $(GNUR_DIR); make distclean)
#
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -21,35 +21,32 @@
# questions.
#
OSNAME := $(shell uname)
ifeq ($(OSNAME), Linux)
OS_DIR := linux
CC := gcc
FC := gfortran
CFLAGS := -fPIC -O2
LDFLAGS := -fPIC -shared
SHARED_EXT := so
LIBS := -lgfortran
else ifeq ($(OSNAME), SunOS)
OS_DIR := solaris
CC := cc
FC := f90
CFLAGS := -m64 -O -xcode=pic13
LDFLAGS := -G -m64
SHARED_EXT := so
LIBS := -lgfortran
else ifeq ($(OSNAME), Darwin)
OS_DIR := darwin
CC := gcc
FC := gfortran
CFLAGS := -fPIC -O2
LDFLAGS := -dynamiclib -undefined dynamic_lookup
SHARED_EXT := dylib
else
all:
@echo "This Makefile does not know how to compile for $(OSNAME)"
@false
endif
CFLAGS := $(CFLAGS) -DFASTR
# Copies the Lbas and lapack libraries and builds the pcre library
include $(TOPDIR)/platform.mk
TARGET_DIR := $(TOPDIR)/builtinlibs/lib
BLAS_TARGET := $(TARGET_DIR)/libRblas$(DYLIB_EXT)
LAPACK_TARGET := $(TARGET_DIR)/libRlapack$(DYLIB_EXT)
PCRE_TARGET := $(TARGET_DIR)/libpcre$(DYLIB_EXT)
all: $(TARGET_DIR) $(BLAS_TARGET) $(LAPACK_TARGET) $(PCRE_TARGET)
$(TARGET_DIR):
mkdir -p $(TARGET_DIR)
$(BLAS_TARGET): $(GNUR_DIR)/lib/libRblas$(DYLIB_EXT)
cp $(GNUR_DIR)/lib/libRblas$(DYLIB_EXT) $(BLAS_TARGET)
$(LAPACK_TARGET): $(GNUR_DIR)/lib/libRlapack$(DYLIB_EXT)
cp $(GNUR_DIR)/lib/libRlapack$(DYLIB_EXT) $(LAPACK_TARGET)
PCRE_OBJS := $(wildcard $(GNUR_DIR)/src/extra/pcre/pcre_*.o)
$(PCRE_TARGET): $(PCRE_OBJS) $(TOPDIR)/platform.mk
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(PCRE_TARGET) $(PCRE_OBJS)
clean:
rm -f $(BLAS_TARGET) $(LAPACK_TARGET) $(PCRE_TARGET)
......@@ -21,13 +21,20 @@
# questions.
#
# This is separate because at the time the parent Makefile is analyzed
# the pcre object files do not exist
# Extracts relevant parts of the generated GnuR Makeconf file into FastR's platform.mk
include ../platform.mk
.PHONY: all clean
PCRE_OBJS := $(wildcard $(GNUR_DIR)/src/extra/pcre/pcre_*.o)
OS_NAME := $(shell uname)
OS_DIR := $(shell echo $(OS_NAME) | tr '[:upper:]' '[:lower:]' )
$(PCRE_TARGET): $(PCRE_OBJS)
$(CC) $(LDFLAGS) -o $(PCRE_TARGET) $(PCRE_OBJS)
all: $(TOPDIR)/platform.mk
$(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
clean:
rm -f $(TOPDIR)/platform.mk
/^CFLAGS/s/$/ -fpic/
/^FFLAGS/s/$/ -fpic/
w
q
/^CC =.*/ w platform.mk.temp
/^CFLAGS =.*/ w platform.mk.temp
/^DYLIB_.* =.*/ w platform.mk.temp
/^F77 =.*/ w platform.mk.temp
/^FFLAGS =.*/ w platform.mk.temp
/^FPICFLAGS =.*/ w platform.mk.temp
/^FLIBS_IN_SO =.*/ w platform.mk.temp
......@@ -27,7 +27,7 @@
# and overwrites the default. The libraries are stored in the directory denoted
# FASTR_LIBDIR.
include ../../platform.mk
include $(TOPDIR)/platform.mk
.PHONY: all clean cleanlib cleanobj force libr libcommon
......@@ -57,7 +57,6 @@ FFI_INCLUDES = -I$(TOPDIR)/include/jni/include
INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES)
PKGDIR := $(FASTR_LIBDIR)/$(PKG)
PKGTAR := $(SRC)/$(OS_DIR)/$(PKG).tar.gz
ifneq ($(C_SOURCES),)
all: libcommon $(LIB_PKG) $(PKG_EXTRAS)
......@@ -76,16 +75,13 @@ $(OBJ):
$(LIB_PKG): $(OBJ) $(C_OBJECTS) $(PKGDIR)
mkdir -p $(LIBDIR)
$(CC) $(LDFLAGS) -o $(LIB_PKG) $(C_OBJECTS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_PKG) $(C_OBJECTS)
mkdir -p $(FASTR_LIBDIR)/$(PKG)/libs
cp $(LIB_PKG) $(FASTR_LIBDIR)/$(PKG)/libs
$(OBJ)/%.o: $(SRC)/%.c $(H_SOURCES)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJ)/%.o: $(SRC)/%.f
$(FC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(LIBDIR)/*
rm -rf $(FASTR_LIBDIR)/$(PKG)
......
......@@ -33,7 +33,7 @@ include $(NATIVE_PROJECT)/platform.mk
ifeq ($(FASTR_INSTALL), GNUR)
INCLUDES := -I $(R_HOME)/include
ifeq ($(OSNAME), Darwin)
ifeq ($(OS_NAME), Darwin)
FRAMEWORKFLAGS := -F${R_HOME}/../.. -framework R
else
FRAMEWORKFLAGS :=
......
......@@ -46,7 +46,7 @@ INCLUDE_DIR := $(NATIVE_PROJECT)/include/jni/include
all: $(C_LIB)
$(C_LIB): $(OBJ) $(C_OBJECTS)
$(CC) $(LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
$(OBJ):
mkdir -p $(OBJ)
......
......@@ -33,7 +33,7 @@ include $(NATIVE_PROJECT)/platform.mk
ifeq ($(FASTR_INSTALL), GNUR)
INCLUDES := -I $(R_HOME)/include
ifeq ($(OSNAME), Darwin)
ifeq ($(OS_NAME), Darwin)
FRAMEWORKFLAGS := -F${R_HOME}/../.. -framework R
else
FRAMEWORKFLAGS :=
......@@ -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 $@
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment