Makefiles

This commit is contained in:
Vitor Santos Costa 2017-10-17 00:13:09 +01:00
parent 7a7a9f56ed
commit d93134dcf6
16 changed files with 541 additions and 900 deletions

View File

@ -13,15 +13,14 @@
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%.2";
static char SccsId[] = "%W% %G%.2";
#endif
#include "Yap.h"
#include "Yatom.h"
#include "YapHeap.h"
#include "yapio.h"
#include "YapText.h"
#include "Yatom.h"
#include "yapio.h"
#include <stdlib.h>
#if HAVE_STRING_H
#include <string.h>
@ -35,11 +34,9 @@ static char SccsId[] = "%W% %G%.2";
#endif
#endif
Int p_load_foreign( USES_REGS1 );
Int p_load_foreign(USES_REGS1);
Int
p_load_foreign( USES_REGS1 )
{
Int p_load_foreign(USES_REGS1) {
StringList ofiles = NULL;
StringList libs = NULL;
char *InitProcName;
@ -50,16 +47,17 @@ p_load_foreign( USES_REGS1 )
yhandle_t CurSlot = Yap_StartSlots();
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
//Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
//ap_DebugPlWrite(ARG3); printf("%s\n", " \n");
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
// ap_DebugPlWrite(ARG3); printf("%s\n", " \n");
/* collect the list of object files */
t = Deref(ARG1);
while(1) {
if (t == TermNil) break;
while (1) {
if (t == TermNil)
break;
t1 = HeadOfTerm(t);
t = TailOfTerm(t);
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem));
new->next = ofiles;
new->name = AtomOfTerm(t1);
ofiles = new;
@ -67,11 +65,12 @@ p_load_foreign( USES_REGS1 )
/* collect the list of library files */
t = Deref(ARG2);
while(1) {
if (t == TermNil) break;
while (1) {
if (t == TermNil)
break;
t1 = HeadOfTerm(t);
t = TailOfTerm(t);
new = (StringList) Yap_AllocCodeSpace(sizeof(StringListItem));
new = (StringList)Yap_AllocCodeSpace(sizeof(StringListItem));
new->next = libs;
new->name = AtomOfTerm(t1);
libs = new;
@ -82,17 +81,30 @@ p_load_foreign( USES_REGS1 )
InitProcName = (char *)RepAtom(AtomOfTerm(t1))->StrOfAE;
// verify if it was waiting for initialization
if (Yap_LateInit( InitProcName ) ){
returncode = true;
} else
/* call the OS specific function for dynamic loading */
if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
Yap_StartSlots( );
if (Yap_LateInit(InitProcName)) {
returncode = true;
} else
/* call the OS specific function for dynamic loading */
if (Yap_LoadForeign(ofiles, libs, InitProcName, &InitProc) ==
LOAD_SUCCEEDED) {
if (InitProc == NULL) {
char *f;
if (ofiles) {
f = RepAtom(ofiles->name)->StrOfAE;
} else {
f = RepAtom(libs->name)->StrOfAE;
}
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3,
"Foreign module %s does not have initialization function %s", f,
InitProcName);
return false;
}
Yap_StartSlots();
(*InitProc)();
Yap_CloseSlots(CurSlot);
returncode = true;
}
/* I should recover space if load foreign fails */
if (returncode == TRUE) {
ForeignObj *f_code = (ForeignObj *)Yap_AllocCodeSpace(sizeof(ForeignObj));
@ -117,61 +129,60 @@ p_load_foreign( USES_REGS1 )
return returncode;
}
static Int
p_open_shared_object( USES_REGS1 ) {
static Int p_open_shared_object(USES_REGS1) {
Term t = Deref(ARG1);
Term tflags = Deref(ARG2);
char *s;
void *handle;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
Yap_Error(INSTANTIATION_ERROR, t, "open_shared_object/3");
return FALSE;
}
}
if (!IsAtomTerm(t)) {
Yap_Error(TYPE_ERROR_ATOM,t,"open_shared_object/3");
Yap_Error(TYPE_ERROR_ATOM, t, "open_shared_object/3");
return FALSE;
}
if (IsVarTerm(tflags)) {
Yap_Error(INSTANTIATION_ERROR,tflags,"open_shared_object/3");
return FALSE;
}
if (!IsIntegerTerm(tflags)) {
Yap_Error(TYPE_ERROR_INTEGER,tflags,"open_shared_object/3");
Yap_Error(INSTANTIATION_ERROR, tflags, "open_shared_object/3");
return FALSE;
}
if (!IsIntegerTerm(tflags)) {
Yap_Error(TYPE_ERROR_INTEGER, tflags, "open_shared_object/3");
return FALSE;
}
s = (char *)RepAtom(AtomOfTerm(t))->StrOfAE;
if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags)))==NULL) {
Yap_Error(EXISTENCE_ERROR_SOURCE_SINK,t,"open_shared_object_failed for %s"
" with %s\n", s, LOCAL_ErrorMessage);
if ((handle = Yap_LoadForeignFile(s, IntegerOfTerm(tflags))) == NULL) {
Yap_Error(EXISTENCE_ERROR_SOURCE_SINK, t,
"open_shared_object_failed for %s"
" with %s\n",
s, LOCAL_ErrorMessage);
return FALSE;
} else {
return Yap_unify(MkIntegerTerm((Int)handle),ARG3);
return Yap_unify(MkIntegerTerm((Int)handle), ARG3);
}
}
static Int
p_close_shared_object( USES_REGS1 ) {
static Int p_close_shared_object(USES_REGS1) {
Term t = Deref(ARG1);
void *handle;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"close_shared_object/1");
Yap_Error(INSTANTIATION_ERROR, t, "close_shared_object/1");
return FALSE;
}
}
if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"close_shared_object/1");
Yap_Error(TYPE_ERROR_INTEGER, t, "close_shared_object/1");
return FALSE;
}
handle = (char *)IntegerOfTerm(t);
return Yap_CloseForeignFile(handle);
}
static Int
p_call_shared_object_function( USES_REGS1 ) {
static Int p_call_shared_object_function(USES_REGS1) {
Term t = Deref(ARG1);
Term tfunc = Deref(ARG2);
Term tmod;
@ -180,51 +191,51 @@ p_call_shared_object_function( USES_REGS1 ) {
Int res;
tmod = CurrentModule;
restart:
restart:
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
return FALSE;
} else if (IsApplTerm(t)) {
Functor fun = FunctorOfTerm(t);
Functor fun = FunctorOfTerm(t);
if (fun == FunctorModule) {
tmod = ArgOfTerm(1, t);
if (IsVarTerm(tmod) ) {
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
return FALSE;
if (IsVarTerm(tmod)) {
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
return FALSE;
}
if (!IsAtomTerm(tmod) ) {
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_shared_object_function/2");
return FALSE;
if (!IsAtomTerm(tmod)) {
Yap_Error(TYPE_ERROR_ATOM, ARG1, "call_shared_object_function/2");
return FALSE;
}
t = ArgOfTerm(2, t);
goto restart;
}
} else if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"call_shared_object_function/2");
Yap_Error(TYPE_ERROR_INTEGER, t, "call_shared_object_function/2");
return FALSE;
}
handle = (void *)IntegerOfTerm(t);
if (IsVarTerm(tfunc)) {
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
Yap_Error(INSTANTIATION_ERROR, t, "call_shared_object_function/2");
return FALSE;
}
}
if (!IsAtomTerm(tfunc)) {
Yap_Error(TYPE_ERROR_ATOM,t,"call_shared_object_function/2/3");
Yap_Error(TYPE_ERROR_ATOM, t, "call_shared_object_function/2/3");
return FALSE;
}
CurrentModule = tmod;
res = Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE);
res =
Yap_CallForeignFile(handle, (char *)RepAtom(AtomOfTerm(tfunc))->StrOfAE);
CurrentModule = OldCurrentModule;
return res;
}
static Int
p_obj_suffix( USES_REGS1 ) {
return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS),ARG1);
static Int p_obj_suffix(USES_REGS1) {
return Yap_unify(Yap_CharsToListOfCodes(SO_EXT, ENC_ISO_LATIN1 PASS_REGS),
ARG1);
}
static Int
p_open_shared_objects( USES_REGS1 ) {
static Int p_open_shared_objects(USES_REGS1) {
#ifdef SO_EXT
return TRUE;
#else
@ -232,26 +243,25 @@ p_open_shared_objects( USES_REGS1 ) {
#endif
}
void
Yap_InitLoadForeign( void )
{
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
void Yap_InitLoadForeign(void) {
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign,
SafePredFlag | SyncPredFlag);
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag);
Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag);
Yap_InitCPred("close_shared_object", 1, p_close_shared_object, SyncPredFlag|SafePredFlag);
/** @pred close_shared_object(+ _Handle_)
Yap_InitCPred("close_shared_object", 1, p_close_shared_object,
SyncPredFlag | SafePredFlag);
/** @pred close_shared_object(+ _Handle_)
Detach the shared object identified by _Handle_.
Detach the shared object identified by _Handle_.
*/
Yap_InitCPred("$call_shared_object_function", 2, p_call_shared_object_function, SyncPredFlag);
*/
Yap_InitCPred("$call_shared_object_function", 2,
p_call_shared_object_function, SyncPredFlag);
Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
}
void
Yap_ReOpenLoadForeign(void)
{
void Yap_ReOpenLoadForeign(void) {
CACHE_REGS
ForeignObj *f_code = ForeignCodeLoaded;
Term OldModule = CurrentModule;
@ -260,19 +270,13 @@ Yap_ReOpenLoadForeign(void)
YapInitProc InitProc = NULL;
CurrentModule = f_code->module;
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,(char *)RepAtom(f_code->f)->StrOfAE,&InitProc)==LOAD_SUCCEEDED) {
if (Yap_ReLoadForeign(f_code->objs, f_code->libs,
(char *)RepAtom(f_code->f)->StrOfAE,
&InitProc) == LOAD_SUCCEEDED) {
if (InitProc)
(*InitProc)();
(*InitProc)();
}
f_code = f_code->next;
}
CurrentModule = OldModule;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
``
<center>
![The YAP Logo](docs/icons/yap_128x128x32.png)
</center>

View File

@ -1,18 +1,4 @@
#
# Optional Components
#
include(CheckIncludeFileCXX)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckPrototypeExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckVariableExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(GetGitRevisionDescription)
# modern systems do this.
@ -211,7 +197,6 @@ endif (HAVE_LIBLOG)
# set(EXTRALIBS ${EXTRALIBS} socket)
# endif (HAVE_LIBSOCKET)
find_library(HAVE_LIBPTHREAD pthread)
if (HAVE_LIBPTHREAD)
target_link_libraries(libYap pthread)
@ -402,6 +387,28 @@ git_describe(GIT_DESCRIBE)
#Test standard headers (mimics AC_HEADER_STDC)
include(TestSTDC)
check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H )
check_include_files( "stdio.h;readline/history.h" HAVE_READLINE_HISTORY_H )
check_function_exists( add_history HAVE_ADD_HISTORY )
check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP)
check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT)
check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT)
check_symbol_exists( rl_filename_completion_function stdio.h;readline/readline.h HAVE_RL_FILENAME_COMPLETION_FUNCTION)
check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE )
check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE )
check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL )
check_function_exists( rl_set_keyboard_input_timeout HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT )
check_function_exists( rl_set_prompt HAVE_RL_SET_PROMPT)
check_symbol_exists( rl_catch_signals "stdio.h;readline/readline.h" HAVE_DECL_RL_CATCH_SIGNALS )
check_type_size( rl_completion_func_t RL_COMPLETION_FUNC_T )
check_symbol_exists( rl_done stdio.h;readline/readline.h HAVE_DECL_RL_DONE )
CHECK_TYPE_SIZE( rl_hook_func_t RL_HOOK_FUNC_T )
check_symbol_exists( rl_event_hook stdio.h;readline/readline.h HAVE_DECL_RL_EVENT_HOOK )
check_symbol_exists( rl_readline_state stdio.h;readline/readline.h HAVE_DECL_RL_READLINE_STATE )
configure_file(${CMAKE_SOURCE_DIR}/os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/YapIOConfig.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake
${CMAKE_BINARY_DIR}/YapConfig.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../YapTermConfig.h.cmake
@ -409,5 +416,3 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/../YapTermConfig.h.cmake
configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake
${CMAKE_BINARY_DIR}/config.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../GitSHA1.c.in GitSHA1.c @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/YapIOConfig.h)

View File

@ -177,7 +177,7 @@ else()
llvm_set(SYSTEM_LIBS system-libs)
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
endif()
llvm_set(LIBRARY_DIRS libdir true)
llvm_set(LIBRARY_DIRS CMAKE_INSTALL_LIBDIR true)
llvm_set_libs(LIBRARIES libfiles "${LLVM_LIBRARY_DIRS}")
endif()

View File

@ -1,183 +1,78 @@
#
# FindLibR.cmake
# - This module locates an installed R distribution.
#
# Copyright (C) 2009-11 by RStudio, Inc.
# Defines the following:
# R_COMMAND - Path to R command
# R_HOME - Path to 'R home', as reported by R
# R_INCLUDE_DIR - Path to R include directory
# R_LIBRARY_BASE - Path to R library
# R_LIBRARY_BLAS - Path to Rblas / blas library
# R_LIBRARY_LAPACK - Path to Rlapack / lapack library
# R_LIBRARY_READLINE - Path to readline library
# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE]
#
# This program is licensed to you under the terms of version 3 of the
# GNU Affero General Public License. This program is distributed WITHOUT
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
# VTK_R_HOME - (deprecated, use R_HOME instead) Path to 'R home', as reported by R
#
# Variable search order:
# 1. Attempt to locate and set R_COMMAND
# - If unsuccessful, generate error and prompt user to manually set R_COMMAND
# 2. Use R_COMMAND to set R_HOME
# 3. Locate other libraries in the priority:
# 1. Within a user-built instance of R at R_HOME
# 2. Within an installed instance of R
# 3. Within external system libraries
#
# LIBR_FOUND
# LIBR_HOME
# LIBR_INCLUDE_DIRS
# LIBR_DOC_DIR
# LIBR_LIBRARIES
set(TEMP_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
set(CMAKE_FIND_APPBUNDLE "NEVER")
find_program(R_COMMAND R DOC "R executable.")
set(CMAKE_FIND_APPBUNDLE ${TEMP_CMAKE_FIND_APPBUNDLE})
# detection for OSX (look for R framework)
if(APPLE)
if(R_COMMAND)
execute_process(WORKING_DIRECTORY .
COMMAND ${R_COMMAND} RHOME
OUTPUT_VARIABLE R_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
# deprecated
if(VTK_R_HOME)
set(R_HOME ${VTK_R_HOME} CACHE PATH "R home directory obtained from R RHOME")
else()
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
set(VTK_R_HOME ${R_HOME})
endif()
# /deprecated
# the following command does nothing currently, but will be used when deprecated code is removed
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
find_library(LIBR_LIBRARIES R)
if(LIBR_LIBRARIES)
set(LIBR_HOME "${LIBR_LIBRARIES}/Resources" CACHE PATH "R home directory")
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory")
set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory")
set(LIBR_EXECUTABLE "${LIBR_HOME}/R" CACHE PATH "R executable")
endif()
find_path(R_INCLUDE_DIR R.h
HINTS ${R_ROOT_DIR}
PATHS /usr/local/lib /usr/local/lib64 /usr/share
PATH_SUFFIXES include R/include
DOC "Path to file R.h")
find_library(R_LIBRARY_BASE R
HINTS ${R_ROOT_DIR}/lib
DOC "R library (example libR.a, libR.dylib, etc.).")
find_library(R_LIBRARY_BLAS NAMES Rblas blas
HINTS ${R_ROOT_DIR}/lib
DOC "Rblas library (example libRblas.a, libRblas.dylib, etc.).")
find_library(R_LIBRARY_LAPACK NAMES Rlapack lapack
HINTS ${R_ROOT_DIR}/lib
DOC "Rlapack library (example libRlapack.a, libRlapack.dylib, etc.).")
find_library(R_LIBRARY_READLINE readline
DOC "(Optional) system readline library. Only required if the R libraries were built with readline support.")
# detection for UNIX & Win32
else()
# Find R executable and paths (UNIX)
if(UNIX)
# find executable
find_program(LIBR_EXECUTABLE R)
if(LIBR_EXECUTABLE-NOTFOUND)
message(STATUS "Unable to locate R executable")
endif()
# ask R for the home path
if(NOT LIBR_HOME)
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--vanilla" "-e" "cat(R.home())"
OUTPUT_VARIABLE LIBR_HOME
)
if(LIBR_HOME)
set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory")
endif()
endif()
# ask R for the include dir
if(NOT LIBR_INCLUDE_DIRS)
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('include'))"
OUTPUT_VARIABLE LIBR_INCLUDE_DIRS
)
if(LIBR_INCLUDE_DIRS)
set(LIBR_INCLUDE_DIRS ${LIBR_INCLUDE_DIRS} CACHE PATH "R include directory")
endif()
endif()
# ask R for the doc dir
if(NOT LIBR_DOC_DIR)
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('doc'))"
OUTPUT_VARIABLE LIBR_DOC_DIR
)
if(LIBR_DOC_DIR)
set(LIBR_DOC_DIR ${LIBR_DOC_DIR} CACHE PATH "R doc directory")
endif()
endif()
# ask R for the lib dir
if(NOT LIBR_LIB_DIR)
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('lib'))"
OUTPUT_VARIABLE LIBR_LIB_DIR
)
endif()
# Find R executable and paths (Win32)
else()
# find the home path
if(NOT LIBR_HOME)
# read home from the registry
get_filename_component(LIBR_HOME
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\R-core\\R;InstallPath]"
ABSOLUTE CACHE)
# print message if not found
if(NOT LIBR_HOME)
message(STATUS "Unable to locate R home (not written to registry)")
endif()
endif()
# set other R paths based on home path
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory")
set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory")
# set library hint path based on whether we are doing a special session 64 build
if(LIBR_FIND_WINDOWS_64BIT)
set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/x64")
else()
set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/i386")
endif()
endif()
# look for the R executable
find_program(LIBR_EXECUTABLE R
HINTS ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin)
if(LIBR_EXECUTABLE-NOTFOUND)
message(STATUS "Unable to locate R executable")
endif()
# look for the core R library
find_library(LIBR_CORE_LIBRARY NAMES R
HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin)
if(LIBR_CORE_LIBRARY)
set(LIBR_LIBRARIES ${LIBR_CORE_LIBRARY})
else()
message(STATUS "Could not find libR shared library.")
endif()
if(WIN32)
# look for lapack
find_library(LIBR_LAPACK_LIBRARY NAMES Rlapack
HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin)
if(LIBR_LAPACK_LIBRARY)
set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_LAPACK_LIBRARY})
if(UNIX)
set(LIBR_LIBRARIES ${LIBR_LIBRARIES} gfortran)
endif()
endif()
# look for blas
find_library(LIBR_BLAS_LIBRARY NAMES Rblas
HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin)
if(LIBR_BLAS_LIBRARY)
set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_BLAS_LIBRARY})
endif()
# look for rgraphapp
find_library(LIBR_GRAPHAPP_LIBRARY NAMES Rgraphapp
HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin)
if(LIBR_GRAPHAPP_LIBRARY)
set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_GRAPHAPP_LIBRARY})
endif()
endif()
# cache LIBR_LIBRARIES
if(LIBR_LIBRARIES)
set(LIBR_LIBRARIES ${LIBR_LIBRARIES} CACHE PATH "R runtime libraries")
endif()
message(SEND_ERROR "FindR.cmake requires the following variables to be set: R_COMMAND")
endif()
# define find requirements
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibR DEFAULT_MSG
LIBR_HOME
LIBR_EXECUTABLE
LIBR_INCLUDE_DIRS
LIBR_LIBRARIES
LIBR_DOC_DIR
)
if(LIBR_FOUND)
message(STATUS "Found R: ${LIBR_HOME}")
# Note: R_LIBRARY_BASE is added to R_LIBRARIES twice; this may be due to circular linking dependencies; needs further investigation
set(R_LIBRARIES ${R_LIBRARY_BASE} ${R_LIBRARY_BLAS} ${R_LIBRARY_LAPACK} ${R_LIBRARY_BASE})
if(R_LIBRARY_READLINE)
set(R_LIBRARIES ${R_LIBRARIES} ${R_LIBRARY_READLINE})
endif()
# mark low-level variables from FIND_* calls as advanced
mark_as_advanced(
LIBR_CORE_LIBRARY
LIBR_LAPACK_LIBRARY
LIBR_BLAS_LIBRARY
)

View File

@ -12,49 +12,14 @@
# So we look for another one by default
#
# # try to extract R from readline to avoid collision
IF(APPLE)
FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS
${CMAKE_INCLUDE_PATH}
${R_INCLUDE_DIR}
/sw/include
/opt/local/include
/opt/include
/usr/local/opt/readline/include #brew
/usr/local/include
/usr/include/
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h)
# Apple readline does not support readline hooks
# So we look for another one by default
IF(APPLE)
FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline PATHS
${CMAKE_LIBRARY_PATH}
/sw/lib
/opt/local/lib
/usr/local/opt/readline/lib #brew
/opt/lib
/usr/local/lib
/usr/lib
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline)
# Sometimes readline really needs ncurses
IF(APPLE)
FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses PATHS
/sw/lib
/opt/local/lib
/opt/lib
/usr/local/lib
/usr/lib
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses)
MARK_AS_ADVANCED(
@ -63,7 +28,10 @@ MARK_AS_ADVANCED(
READLINE_ncurses_LIBRARY
)
SET( READLINE_FOUND "NO" )
message(STATUS "readline headers found at ${READLINE_INCLUDE_DIR}")
message(STATUS "readline library found at ${READLINE_readline_LIBRARY} ${READLINE_ncurses_LIBRARY} ")
SET( READLINE_FOUND "NO" )
IF(READLINE_INCLUDE_DIR)
IF(READLINE_readline_LIBRARY)
SET( READLINE_FOUND "YES" )
@ -79,8 +47,11 @@ IF(READLINE_INCLUDE_DIR)
ENDIF(READLINE_readline_LIBRARY)
ENDIF(READLINE_INCLUDE_DIR)
set(HAVE_LIBREADLINE 0 CACHE BOOL "Readline works.")
IF(READLINE_FOUND)
MESSAGE(STATUS "Found readline library")
set(HAVE_LIBREADLINE 1)
ELSE(READLINE_FOUND)
IF(READLINE_FIND_REQUIRED)
MESSAGE(SYSTEM_ERROR_FATAL "Could not find readline -- please give some paths to CMake")
@ -92,4 +63,5 @@ find_package_handle_standard_args(Readline READLINE_INCLUDE_DIR READLINE_LIBRARI
MARK_AS_ADVANCED(
READLINE_FOUND
HAVE_LIBREADLINE
)

View File

@ -1,50 +1,46 @@
# - Find the readline library
# This module defines
# READLINE_INCLUDE_DIR, path to readline/readline.h, etc.
# READLINE_LIBRARIES, the libraries required to use READLINE.
# READLINE_FOUND, If false, do not try to use READLINE.
# also defined, but not for general use are
# READLINE_readline_LIBRARY, where to find the READLINE library.
# , where to find the ncurses library [might not be defined]
# include subdirectories configuration
## after we have all functionality in
#
# ADD_SUBDIRECTORY(console/terminal)
option (WITH_READLINE "GNU readline console" ON)
if (WITH_READLINE)
macro_optional_find_package (Readline ON)
find_library(READLINE_ncurses_LIBRARY
NAMES ncurses
HINTS ${Readline_ROOT_DIR}/lib
)
find_path(READLINE_INCLUDE_DIR
NAMES readline/readline.h
HINTS ${Readline_ROOT_DIR}/include
)
find_library(READLINE_readline_LIBRARY
NAMES readline
HINTS ${READLINE_INCLUDE_DIR/../lib} ${Readline_ROOT_DIR}/lib )
if (READLINE_readline_LIBRARY)
set (HAVE_LIBREADLINE TRUE)
if (READLINE_INCLUDE_DIR)
set(READLINE_FOUND TRUE CACHE BOOL "readline is installed correctly")
set (READLINE_LIBRARIES ${READLINE_ncurses_LIBRARY} ${READLINE_readline_LIBRARY} )
endif()
message(STATUS "readline headers found at ${READLINE_INCLUDE_DIR}")
message(STATUS "readline library found at ${READLINE_readline_LIBRARY} ${READLINE_ncurses_LIBRARY} ")
endif ()
set(YAP_SYSTEM_OPTIONS "readline" ${YAP_SYSTEM_OPTIONS} )
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckVariableExists)
set(EXTRALIBS ${EXTRALIBS} readline)
endif ()
if (READLINE_FOUND)
# - Find the readline library
# This module defines
# READLINE_INCLUDE_DIR, path to readline/readline.h, etc.
# READLINE_LIBRARIES, the libraries required to use READLINE.
# READLINE_FOUND, If false, do not try to use READLINE.
# also defined, but not for general use are
# READLINE_readline_LIBRARY, where to find the READLINE library.
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H )
check_include_files( "stdio.h;readline/history.h" HAVE_READLINE_HISTORY_H )
set(YAP_SYSTEM_OPTIONS "readline" ${YAP_SYSTEM_OPTIONS} PARENT_SCOPE)
check_function_exists( add_history HAVE_ADD_HISTORY )
check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP)
check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT)
check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT)
check_symbol_exists( rl_filename_completion_function stdio.h;readline/readline.h HAVE_RL_FILENAME_COMPLETION_FUNCTION)
check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE )
check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE )
check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL )
check_function_exists( rl_set_keyboard_input_timeout HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT )
check_function_exists( rl_set_prompt HAVE_RL_SET_PROMPT)
check_symbol_exists( rl_catch_signals "stdio.h;readline/readline.h" HAVE_DECL_RL_CATCH_SIGNALS )
check_type_size( rl_completion_func_t RL_COMPLETION_FUNC_T )
check_symbol_exists( rl_done stdio.h;readline/readline.h HAVE_DECL_RL_DONE )
CHECK_TYPE_SIZE( rl_hook_func_t RL_HOOK_FUNC_T )
check_symbol_exists( rl_event_hook stdio.h;readline/readline.h HAVE_DECL_RL_EVENT_HOOK )
check_symbol_exists( rl_readline_state stdio.h;readline/readline.h HAVE_DECL_RL_READLINE_STATE )
endif (READLINE_FOUND)
endif (WITH_READLINE)

View File

@ -2054,8 +2054,7 @@ calls it, or to nothing if 'inline' is not supported under any name. */
#ifdef _WIN32
#ifndef __WINDOWS__
#define __WINDOWS__ 1
#endif
#endif
#endif
#endif

View File

@ -1,24 +1,34 @@
#!/bin/bash
export MACOSX_DEPLOYMENT_TARGET=10.12
export MACOSX_DEPLOYMENT_TARGET=10.9
# export CC=$SYS_PREFIX/bin/clang
# export CXX=$SYS_PREFIX/bin/clang++
export R_COMMAND=$R
export CMAKE_BUILD_TYPE=Debug
export CMAKE=$PREFIX/bin/cmake
export CMAKE_INCLUDE_PATH=$SYS_PREFIX/include
export CMAKE_LIBRARY_PATH=$SYS_PREFIX/lib
export CMAKE_INSTALL_PREFIX=$PREFIX
export GENERATOR="-GNinja"
export PYTHON_EXECUTABLE="$PYTHON"
export PYTHON_LIBRARY="$STDLIB_DIR/../libPython${PY_VER}m$SHLIB_EXT"
export PYTHON_INCLUDE_DIR="$STDLIB_DIR/../../include/python$PY_VER"m
mkdir $PREFIX/conda
cd $PREFIX/conda
# The datarootdir option places the docs into a temp folder that won't
CC=$SYS_PREFIX/bin/clang \
CXX=$SYS_PREFIX/bin/clang++ \
$SYS_PREFIX/bin/cmake \
-DCMAKE_INCLUDE_PATH="$SYS_PREFIX"/include \
-DCMAKE_LIBRARY_PATH="$SYS_PREFIX"/lib \
-DCMAKE_BUILD_TYPE=Debug \
$CMAKE --build=. --target=install\
-DCMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" \
-DCMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" \
-DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
-DPYTHON_EXECUTABLE:FILEPATH="$PYTHON_EXECUTABLE" \
-DPYTHON_LIBRARY:FILEPATH="$PYTHON_LIBRARY" \
-DPYTHON_INCLUDE_DIR:PATH="$PYTHON_INCLUDE_DIR" \
$RECIPE_DIR/..
CC=$SYS_PREFIX/bin/clang \
CXX=$SYS_PREFIX/bin/clang++ \
make
CC=$SYS_PREFIX/bin/clang \
CXX=$SYS_PREFIX/bin/clang++ \
make install
make -j install CMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX"
# Remove the created lib64 directory
rm -rf $PREFIX/conda
# rm -rf $PREFIX/conda

View File

@ -5,14 +5,18 @@ package:
requirements:
build:
- cmake
- clang
- swig
- readline
- gmp
run:
- python
- r
- notebook
run:
- readline
- gmp
- r
- notebook
about:
home: http://www.github.com/vscosta/yap-6.3.git
license: LGPL2

View File

@ -13,7 +13,7 @@
#cmakedefine HAVE_READLINE_READLINE_H ${HAVE_READLINE_READLINE_H}
#endif
#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_READLINE_H)
#if defined(FOUND_READLINE)
#define USE_READLINE 1
#endif

View File

@ -53,7 +53,7 @@ static char SccsId[] = "%W% %G%";
#include "iopreds.h"
#if USE_READLINE
#if defined(HAVE_LIBREADLINE)
#include <readline/history.h>
#include <readline/readline.h>

View File

@ -81,9 +81,9 @@ extensions=[Extension('_yap', native_sources,
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1'),
('YAP_PYTHON', '1')],
runtime_library_dirs=['yap4py','${libdir}','${bindir}'],
runtime_library_dirs=['yap4py','${RCMAKE_INSTALL_LIBDIR}','${CMAKE_INSTALL_BINDIR}'],
swig_opts=['-modern', '-c++', '-py3','-I${RELATIVE_SOURCE}/CXX'],
library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${bindir}", '.'],
library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${CMAKE_INSTALL_BINDIR}", '.'],
extra_link_args=my_extra_link_args,
extra_compile_args=['-g3','-O0'],
libraries=['Yap','${GMP_LIBRARIES}'],

View File

@ -2,15 +2,34 @@
# PROJECT ( YAP_REAL C )
# LIBR_FOUND
# LIBR_HOME
# LIBR_INCLUDE_DIRS
# LIBR_DOC_DIR
# LIBR_LIBRARIES
#
macro_optional_find_package (LibR ON)
# - This module locates an installed R distribution.
#
# Defines the following:
# R_COMMAND - Path to R command
# R_HOME - Path to 'R home', as reported by R
# R_INCLUDE_DIR - Path to R include directory
# R_LIBRARY_BASE - Path to R library
# R_LIBRARY_BLAS - Path to Rblas / blas library
# R_LIBRARY_LAPACK - Path to Rlapack / lapack library
# R_LIBRARY_READLINE - Path to readline library
# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE]
#
# VTK_R_HOME - (deprecated, use R_HOME instead) Path to 'R home', as reported by R
#
# Variable search order:
# 1. Attempt to locate and set R_COMMAND
# - If unsuccessful, generate error and prompt user to manually set R_COMMAND
# 2. Use R_COMMAND to set R_HOME
# 3. Locate other libraries in the priority:
# 1. Within a user-built instance of R at R_HOME
# 2. Within an installed instance of R
# 3. Within external system libraries
#
if (LIBR_FOUND)
macro_optional_find_package (R ON)
if (R_HOME)
set (REAL_SOURCES
real.c
@ -24,7 +43,7 @@ add_to_group( REAL_PL pl_library)
include_directories (
${CMAKE_CURRENT_BINARY_DIR}
${LIBR_INCLUDE_DIRS}
${R_INCLUDE_DIR}
)
set (CMAKE_REQUIRED_INCLUDES
@ -34,7 +53,7 @@ include_directories (
add_lib(real ${REAL_SOURCES})
target_link_libraries (real ${LIBR_LIBRARIES} libYap)
target_link_libraries (real ${R_LIBRARIES} libYap)
check_include_files( "stdio.h;R.h" HAVE_R_H )
check_include_files( "R.h;Rembedded.h" HAVE_R_EMBEDDED_H )
@ -52,5 +71,4 @@ include_directories (
DESTINATION ${libpl}
)
endif (LIBR_FOUND)
endif()

View File

@ -310,7 +310,7 @@ main_message(error(type_error(Type,Who), _What), Level, _LC) -->
[ ' ~a: ~q should be of type ~a' - [Level,Who,Type]],
[ nl ].
main_message(error(system_error(Who), _What), Level, _LC) -->
[ ' ~a: ~q error' - [Level,Who]],
[ ' ~a: ~q' - [Level,Who]],
[ nl ].
main_message(error(uninstantiation_error(T),_), Level, _LC) -->
[ ' ~a: found ~q, expected unbound variable ' - [Level,T], nl ].