diff --git a/C/load_foreign.c b/C/load_foreign.c index aeb2c9351..adb75e4c0 100644 --- a/C/load_foreign.c +++ b/C/load_foreign.c @@ -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 #if HAVE_STRING_H #include @@ -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; } - - - - - - - - diff --git a/CMakeLists.txt b/CMakeLists.txt index 4160f9da8..bdcd2d35e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ + # value of 3.4.0 or lower. cmake_minimum_required(VERSION 3.4) - if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) - endif(COMMAND cmake_policy) +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) # Sets the version of CMake required to build the native # library. You should either keep the default value or pass a @@ -13,9 +14,10 @@ include(CMakeToolsHelpers OPTIONAL) project( YAP ) include(FeatureSummary) +include(GNUInstallDirs) set(YAP_APP_DIR "${CMAKE_SOURCE_DIR}/../..") - cmake_policy(VERSION 3.4) +cmake_policy(VERSION 3.4) set( CMAKE_MODULE_PATH @@ -32,7 +34,17 @@ include(MacroOptionalAddSubdirectory) include(MacroOptionalFindPackage) include(FeatureSummary) include(FindPackageHandleStandardArgs) -include (GNUInstallDirs) + +# Optional Components +# +include(CheckIncludeFileCXX) +include(CheckFunctionExists) +include(CheckFunctionExists) +include(CheckPrototypeExists) +include(CheckVariableExists) +include(CheckCXXSourceCompiles) +include(TestBigEndian) +include(GetGitRevisionDescription) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code.z @@ -43,14 +55,14 @@ include (GNUInstallDirs) # Search packages for host system instead of packages for target system # in case of cross compilation define these macro by toolchain file if(NOT COMMAND find_host_package) - macro(find_host_package) - find_package(${ARGN}) - endmacro() + macro(find_host_package) + find_package(${ARGN}) + endmacro() endif() if(NOT COMMAND find_host_program) - macro(find_host_program) - find_program(${ARGN}) - endmacro() + macro(find_host_program) + find_program(${ARGN}) + endmacro() endif() option(BUILD_SHARED_LIBS "Build shared library" ON) @@ -62,43 +74,43 @@ set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) include (MacroLogFeature) if (POLICY CMP0042) - cmake_policy( SET CMP0042 NEW) + cmake_policy( SET CMP0042 NEW) endif() function(add_to_group list output) - set (tmp ${${output}}) - foreach (path ${${list}}) - get_source_file_property(path ${path} LOCATION) - list( APPEND tmp ${path}) - endforeach () - set (${output} ${tmp} CACHE INTERNAL "prolog library files") + set (tmp ${${output}}) + foreach (path ${${list}}) + get_source_file_property(path ${path} LOCATION) + list( APPEND tmp ${path}) + endforeach () + set (${output} ${tmp} CACHE INTERNAL "prolog library files") endfunction(add_to_group list output ) function(add_to_libgroup el list) add_custom_command( TARGET ${el} POST_BUILD -COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py - DEPENDS ${el} ) - list( APPEND ${list} ${${el}}) - set (${list} ${${list}} CACHE INTERNAL "prolog dll files") + COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py + DEPENDS ${el} ) + list( APPEND ${list} ${${el}}) + set (${list} ${${list}} CACHE INTERNAL "prolog dll files") endfunction(add_to_libgroup el list ) function(add_to_corelibgroup el list) add_custom_command( TARGET ${el} POST_BUILD -COMMAND ${CMAKE_COMMAND} -E copy $ $ $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py - DEPENDS ${el} ) - list( APPEND ${list} ${${el}}) - set (${list} ${${list}} CACHE INTERNAL "prolog dll files") + COMMAND ${CMAKE_COMMAND} -E copy $ $ $ ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py + DEPENDS ${el} ) + list( APPEND ${list} ${${el}}) + set (${list} ${${list}} CACHE INTERNAL "prolog dll files") endfunction(add_to_corelibgroup el list ) if (ANDROID_OLD) - macro ( MY_add_custom_target) - endmacro() + macro ( MY_add_custom_target) + endmacro() else() - macro ( MY_add_custom_target ) - add_custom_target (${ARGN}) - endmacro() + macro ( MY_add_custom_target ) + add_custom_target (${ARGN}) + endmacro() endif() if (WIN32) @@ -120,66 +132,66 @@ macro ( add_corelib arg1 ) endmacro() if (ANDROID_OLD) - macro ( MY_add_dependencies) - endmacro() + macro ( MY_add_dependencies) + endmacro() else() - macro ( MY_add_dependencies ) - add_dependencies (${ARGN}) - endmacro() + macro ( MY_add_dependencies ) + add_dependencies (${ARGN}) + endmacro() endif() if (ANDROID_OLD) - macro ( MY_add_library) - endmacro() + macro ( MY_add_library) + endmacro() else() - macro ( MY_add_library ) - add_library (${ARGN}) - endmacro() + macro ( MY_add_library ) + add_library (${ARGN}) + endmacro() endif() if (ANDROID) - macro ( MY_add_subdirectory) - endmacro() + macro ( MY_add_subdirectory) + endmacro() else() - macro ( MY_add_subdirectory ) - add_subdirectory (${ARGN}) - endmacro() + macro ( MY_add_subdirectory ) + add_subdirectory (${ARGN}) + endmacro() endif() if (ANDROID_OLD) - macro ( MY_include) - endmacro() + macro ( MY_include) + endmacro() else() - macro ( MY_include ) - include (${ARGN}) - endmacro() + macro ( MY_include ) + include (${ARGN}) + endmacro() endif() if (ANDROID) - macro ( MY_install) - endmacro() + macro ( MY_install) + endmacro() else() - macro ( MY_install ) - install (${ARGN}) - endmacro() + macro ( MY_install ) + install (${ARGN}) + endmacro() endif() if (ANDROID_OLD) - macro ( MY_set_target_properties) - endmacro() + macro ( MY_set_target_properties) + endmacro() else() - macro ( MY_set_target_properties ) - set_target_properties (${ARGN}) - endmacro() + macro ( MY_set_target_properties ) + set_target_properties (${ARGN}) + endmacro() endif() if (ANDROID_OLD) - macro ( MY_target_link_libraries) - endmacro() + macro ( MY_target_link_libraries) + endmacro() else() - macro ( MY_target_link_libraries ) - target_link_libraries (${ARGN}) - endmacro() + macro ( MY_target_link_libraries ) + target_link_libraries (${ARGN}) + endmacro() endif() @@ -195,43 +207,48 @@ disallow_intree_builds() # set(CMAKE_BUILD_TYPE Debug) if (APPLE) - set (MACOSX_RPATH ON) + set (MACOSX_RPATH ON) + set (PATH $ENV{PATH}) + list (FIND ${PATH} pos /usr/local) + if (pos EQUAL -1) + set (pos 0) + endif() + list (INSERT CMAKE_PREFIX_PATH pos + /usr/local/opt/gmp + /usr/local/opt/libxml2 + /usr/local/opt/openmpi + /usr/local/opt/openssl + /usr/local/opt/postgresql + /usr/local/opt/python3 + /usr/local/opt/readline + /usr/local/opt/swig + ) endif (APPLE ) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif(POLICY CMP0042) -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif(POLICY CMP0043) - - -if (ANDROID) - set ( prefix ${YAP_APP_DIR}/build ) - set ( datarootdir ${prefix}/assets ) -else() -set ( prefix "${CMAKE_INSTALL_PREFIX}") - set ( datarootdir ${prefix}/share ) +if(ANDROID) + set ( datarootdir /assets ) endif() - set ( libpl ${datarootdir}/Yap) -set ( includedir "${prefix}/include") -set ( exec_prefix "${prefix}") -set ( libdir "${exec_prefix}/lib") -set ( datadir "${datarootdir}") -set ( mandir "${datarootdir}/man") -set ( bindir "${exec_prefix}/bin") -set ( docdir "${datarootdir}/doc/Yap") -set ( dlls "${exec_prefix}/lib/Yap") +set ( prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR}) +set ( bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR}) +set ( includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR}) +set ( libdir ${CMAKE_INSTALL_PREFIX}/lib) #LIBDIR}) +set ( exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR}) +set( datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR}) +set ( datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR}) +set ( mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR}) + +set ( libpl ${datarootdir}/Yap) + +set ( dlls ${libdir}/Yap) set(YAP_ROOTDIR ${prefix}) - # erootdir -> rootdir # bindir defined above # libdir defined above -set(YAP_LIBDIR "${dlls}") -set(YAP_SHAREDIR "${datarootdir}") -set(YAP_BINDIR "${bindir}") -set(YAP_INCLUDEDIR "${includedir}") -set(YAP_ROOTDIR "${prefix}") +set(YAP_SHAREDIR ${datarootdir}) +set(YAP_BINDIR ${bindir}) +set(YAP_INCLUDEDIR ${includedir}) +set(YAP_ROOTDIR ${prefix}) +set(YAP_LIBDIR ${dlls}) # # @@ -246,308 +263,22 @@ set (pl_library "" CACHE INTERNAL "prolog library files" ) set (pl_os_library "" CACHE INTERNAL "prolog os files" ) set (pl_boot_library "" CACHE INTERNAL "prolog boot files" ) -# -# Sources Section -# +find_package (GMP) +# GMP_FOUND - true if GMP/MPIR was found +# GMP_INCLUDE_DIRS - include search path +# GMP_LIBRARIES - libraries to link with +# GMP_LIBRARY_ #add_executable(test ${SOURCES}) +list(APPEND YAP_SYSTEM_OPTIONS big_numbers) -set (ABSMI_SOURCES - C/absmi.c - C/absmi_insts.h - C/fli_absmi_insts.h - C/or_absmi_insts.h - C/control_absmi_insts.h - C/index_absmi_insts.h - C/prim_absmi_insts.h - C/cp_absmi_insts.h - C/lu_absmi_insts.h - C/unify_absmi_insts.h - C/fail_absmi_insts.h - C/meta_absmi_insts.h - ) - -set (ENGINE_SOURCES - ${ABSMI_SOURCES} - C/agc.c - C/adtdefs.c - C/alloc.c - C/amasm.c - C/analyst.c - C/args.c - C/arrays.c - C/arith0.c - C/arith1.c - C/arith2.c - C/atomic.c - C/attvar.c - C/bignum.c - C/bb.c - C/blobs.c - C/cdmgr.c - C/cmppreds.c - C/compiler.c - C/computils.c - C/corout.c - C/cut_c.c - C/dbase.c - C/dlmalloc.c - C/errors.c - C/eval.c - C/exec.c - C/exo.c - C/exo_udi.c - C/flags.c - C/globals.c - C/gmp_support.c - C/gprof.c - C/grow.c - C/heapgc.c - C/index.c - C/init.c - C/inlines.c - C/depth_bound.c - C/mavar.c - C/modules.c - C/other.c - C/parser.c - C/qlyr.c - C/qlyw.c - C/range.c - C/save.c - C/scanner.c - C/signals.c - C/sort.c - C/stdpreds.c - C/stack.c - C/text.c - C/threads.c - C/tracer.c - C/unify.c - C/userpreds.c - C/utilpreds.c - C/yap-args.c - C/write.c - C/udi.c - #packages/udi/rtree.c - #packages/udi/rtree_udi.c - - # ${IOLIB_SOURCES} - # MPI_SOURCES - ) - -set(C_INTERFACE_SOURCES - ${PROJECT_BINARY_DIR}/GitSHA1.c - C/load_foreign.c - C/load_dl.c - C/load_dld.c - C/load_dyld.c - C/load_none.c - C/load_aout.c - C/load_aix.c - C/load_dll.c - C/load_shl.c - C/c_interface.c - C/clause_list.c - ) - - - find_package (GMP) - # GMP_FOUND - true if GMP/MPIR was found - # GMP_INCLUDE_DIRS - include search path - # GMP_LIBRARIES - libraries to link with - # GMP_LIBRARY_ #add_executable(test ${SOURCES}) - - list(APPEND YAP_SYSTEM_OPTIONS big_numbers) +find_package( Readline) +List(APPEND YAP_SYSTEM_OPTIONS readline) # include subdirectories configuration ## after we have all functionality in # # ADD_SUBDIRECTORY(console/terminal) - include(readline) - if (READLINE_FOUND ) - list( APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES} ) - - list(APPEND YAP_SYSTEM_OPTIONS readline) - endif() - -list(APPEND LIBYAP_SOURCES ${C_INTERFACE_SOURCES} ${ENGINE_SOURCES}) - -set( BEAM_HEADERS -BEAM/beam.h -) - set (CORE_HEADERS - ${CMAKE_SOURCE_DIR}/H/Atoms.h - ${CMAKE_SOURCE_DIR}/H/Foreign.h - ${CMAKE_SOURCE_DIR}/H/Regs.h - ${CMAKE_SOURCE_DIR}/H/ScannerTypes.h - ${CMAKE_SOURCE_DIR}/H/Tags_24bits.h - ${CMAKE_SOURCE_DIR}/H/Tags_32LowTag.h - ${CMAKE_SOURCE_DIR}/H/Tags_32Ops.h - ${CMAKE_SOURCE_DIR}/H/Tags_32bits.h - ${CMAKE_SOURCE_DIR}/H/Tags_64bits.h - ${CMAKE_SOURCE_DIR}/H/TermExt.h - ${CMAKE_SOURCE_DIR}/H/Yap.h - ${CMAKE_SOURCE_DIR}/H/YapAppliedOpcodes.h - ${CMAKE_SOURCE_DIR}/H/YapCompile.h - ${CMAKE_SOURCE_DIR}/H/YapCompoundTerm.h - ${CMAKE_SOURCE_DIR}/H/YapEval.h - ${CMAKE_SOURCE_DIR}/H/YapFlags.h - ${CMAKE_SOURCE_DIR}/H/YapGFlagInfo.h - ${CMAKE_SOURCE_DIR}/H/YapHandles.h - ${CMAKE_SOURCE_DIR}/H/YapHeap.h - ${CMAKE_SOURCE_DIR}/H/YapLFlagInfo.h - ${CMAKE_SOURCE_DIR}/H/YapOpcodes.h - ${CMAKE_SOURCE_DIR}/H/YapSignals.h - ${CMAKE_SOURCE_DIR}/H/YapTags.h - ${CMAKE_SOURCE_DIR}/H/YapTerm.h - ${CMAKE_SOURCE_DIR}/H/YapText.h - ${CMAKE_SOURCE_DIR}/H/Yapproto.h - ${CMAKE_SOURCE_DIR}/H/Yatom.h - ${CMAKE_SOURCE_DIR}/H/absmi-interpretrer.h - ${CMAKE_SOURCE_DIR}/H/absmi-switch.h - ${CMAKE_SOURCE_DIR}/H/absmi-threaded.h - ${CMAKE_SOURCE_DIR}/H/absmi-traced.h - ${CMAKE_SOURCE_DIR}/H/absmi.h - ${CMAKE_SOURCE_DIR}/H/alloc.h - ${CMAKE_SOURCE_DIR}/H/amidefs.h - ${CMAKE_SOURCE_DIR}/H/amijit.h - ${CMAKE_SOURCE_DIR}/H/amiops.h - ${CMAKE_SOURCE_DIR}/H/arith2.h - ${CMAKE_SOURCE_DIR}/H/arrays.h - ${CMAKE_SOURCE_DIR}/H/attvar.h - ${CMAKE_SOURCE_DIR}/H/clause.h - ${CMAKE_SOURCE_DIR}/H/corout.h - ${CMAKE_SOURCE_DIR}/H/cut_c.h - ${CMAKE_SOURCE_DIR}/H/dlmalloc.h - ${CMAKE_SOURCE_DIR}/H/fields.h - ${CMAKE_SOURCE_DIR}/H/findclause.h - ${CMAKE_SOURCE_DIR}/H/generated/dglobals.h - ${CMAKE_SOURCE_DIR}/H/generated/dhstruct.h - ${CMAKE_SOURCE_DIR}/H/generated/h0globals.h - ${CMAKE_SOURCE_DIR}/H/generated/h0struct.h - ${CMAKE_SOURCE_DIR}/H/generated/hglobals.h - ${CMAKE_SOURCE_DIR}/H/generated/hlocals.h - ${CMAKE_SOURCE_DIR}/H/generated/hstruct.h - ${CMAKE_SOURCE_DIR}/H/generated/i0globals.h - ${CMAKE_SOURCE_DIR}/H/generated/iatoms.h - ${CMAKE_SOURCE_DIR}/H/generated/iglobals.h - ${CMAKE_SOURCE_DIR}/H/generated/ihstruct.h - ${CMAKE_SOURCE_DIR}/H/generated/ilocals.h - ${CMAKE_SOURCE_DIR}/H/generated/ratoms.h - ${CMAKE_SOURCE_DIR}/H/generated/rglobals.h - ${CMAKE_SOURCE_DIR}/H/generated/rhstruct.h - ${CMAKE_SOURCE_DIR}/H/generated/rlocals.h - ${CMAKE_SOURCE_DIR}/H/generated/tatoms.h - ${CMAKE_SOURCE_DIR}/H/globals.h - ${CMAKE_SOURCE_DIR}/H/headclause.h - ${CMAKE_SOURCE_DIR}/H/heap.h - ${CMAKE_SOURCE_DIR}/H/heapgc.h - ${CMAKE_SOURCE_DIR}/H/index.h - ${CMAKE_SOURCE_DIR}/H/inline-only.h - ${CMAKE_SOURCE_DIR}/H/iswiatoms.h - ${CMAKE_SOURCE_DIR}/H/locals.h - ${CMAKE_SOURCE_DIR}/H/nolocks.h - ${CMAKE_SOURCE_DIR}/H/qly.h - ${CMAKE_SOURCE_DIR}/H/rclause.h - ${CMAKE_SOURCE_DIR}/H/rheap.h - ${CMAKE_SOURCE_DIR}/H/saveclause.h - ${CMAKE_SOURCE_DIR}/H/sig.h - ${CMAKE_SOURCE_DIR}/H/sshift.h - ${CMAKE_SOURCE_DIR}/H/threads.h - ${CMAKE_SOURCE_DIR}/H/tracer.h - ${CMAKE_SOURCE_DIR}/H/trim_trail.h - ${CMAKE_SOURCE_DIR}/H/udi_private.h - ${CMAKE_SOURCE_DIR}/H/utarray.h - ${CMAKE_SOURCE_DIR}/H/uthash.h - ${CMAKE_SOURCE_DIR}/H/walkclause.h - ${CMAKE_SOURCE_DIR}/H/yerror.h - ) - -set (INCLUDE_HEADERS - ${CMAKE_SOURCE_DIR}/include/GitSHA1.h - ${CMAKE_SOURCE_DIR}/include/SWI-Prolog.h - ${CMAKE_SOURCE_DIR}/include/VFS.h - ${CMAKE_SOURCE_DIR}/include/YapDefs.h - ${CMAKE_SOURCE_DIR}/include/YapError.h - ${CMAKE_SOURCE_DIR}/include/YapErrors.h - ${CMAKE_SOURCE_DIR}/include/YapFormat.h - ${CMAKE_SOURCE_DIR}/include/YapInterface.h - ${CMAKE_SOURCE_DIR}/include/YapRegs.h - ${CMAKE_SOURCE_DIR}/include/YapStreams.h - ${CMAKE_SOURCE_DIR}/include/blobs.h - ${CMAKE_SOURCE_DIR}/include/c_interface.h - ${CMAKE_SOURCE_DIR}/include/clause_list.h - ${CMAKE_SOURCE_DIR}/include/pl-types.h - ${CMAKE_SOURCE_DIR}/include/udi.h -) - -set (CONFIGURATION_HEADERS -${CMAKE_BINARY_DIR}/YapConfig.h - ${CMAKE_BINARY_DIR}/YapTermConfig.h - ${CMAKE_BINARY_DIR}/config.h - ${CMAKE_BINARY_DIR}/cudd_config.h - ${CMAKE_BINARY_DIR}/dlocals.h - ${CMAKE_BINARY_DIR}/YapIOConfig.h -) - - -set (CXX_HEADERS - ${CMAKE_SOURCE_DIR}/CXX/yapa.hh - ${CMAKE_SOURCE_DIR}/CXX/yapdb.hh - ${CMAKE_SOURCE_DIR}/CXX/yapi.hh - ${CMAKE_SOURCE_DIR}/CXX/yapie.hh - ${CMAKE_SOURCE_DIR}/CXX/yapq.hh - ${CMAKE_SOURCE_DIR}/CXX/yapt.hh - -) -set (PYTHON_HEADERS ${CMAKE_SOURCE_DIR}/packages/python/py4yap.h) - -set (OPTYap_HEADERS - ${CMAKE_SOURCE_DIR}/OPTYap/opt.config.h - ${CMAKE_SOURCE_DIR}/OPTYap/opt.proto.h - ${CMAKE_SOURCE_DIR}/OPTYap/opt.structs.h - ${CMAKE_SOURCE_DIR}/OPTYap/opt.macros.h - ${CMAKE_SOURCE_DIR}/OPTYap/or.macros.h - ${CMAKE_SOURCE_DIR}/OPTYap/or.sba_amiops.h - ${CMAKE_SOURCE_DIR}/OPTYap/or.sba_unify.h - ${CMAKE_SOURCE_DIR}/OPTYap/tab.structs.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_x86.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_sparc.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_mips.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_mips_funcs.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_alpha.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_alpha_funcs.h - ${CMAKE_SOURCE_DIR}/OPTYap/locks_pthread.h - - ) - -set (YAPOS_HEADERS - ${CMAKE_SOURCE_DIR}/os/encoding.h - ${CMAKE_SOURCE_DIR}/os/fmemopen.h - ${CMAKE_SOURCE_DIR}/os/format.h - ${CMAKE_SOURCE_DIR}/os/getw.h - ${CMAKE_SOURCE_DIR}/os/iopreds.h - ${CMAKE_SOURCE_DIR}/os/sysbits.h - ${CMAKE_SOURCE_DIR}/os/yapio.h -) - -list( APPEND c_headers ${CMAKE_SOURCE_DIR}/utf8proc/utf8proc.h ) -list( APPEND c_headers ${YAPOS_HEADERS} ) -list( APPEND c_headers ${OPTYap_HEADERS} ) -list( APPEND c_headers ${INCLUDE_HEADERS} ) -list( APPEND c_headers ${CORE_HEADERS} ) -list (APPEND c_headers ${PYTHON_HEADERS}) -#list( APPEND c_headers ${CONFIGURATION_HEADERS} ) -list( APPEND cxx_headers ${CXX_HEADERS} ) - - -set(STATIC_SOURCES - #NOT INCLUDED FOR NOW - ) - -set(CONSOLE_SOURCES -console/yap.c) #MPI STUFF # library/mpi/mpi.c library/mpi/mpe.c @@ -588,7 +319,7 @@ if (UNIX) execute_process ( COMMAND ${UNAME} -m OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE ) - set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS}) + set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS}) endif() @@ -604,10 +335,10 @@ set ( DEF_TRAILSPACE 0 ) # dd_definitions (-D) ## don't touch these opts - set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEPTH_LIMIT=1;COROUTINING=1;RATIONAL_TREES=1 ) +set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEPTH_LIMIT=1;COROUTINING=1;RATIONAL_TREES=1 ) # inform we are compiling YAP - set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE" ) +set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE" ) # Compilation model # target_compile_definitions(libYap PUBLIC _XOPEN_SOURCE=700 ) @@ -615,7 +346,7 @@ set ( DEF_TRAILSPACE 0 ) #add_definitions( -Wall -Wstrict-prototypes -Wmissing-prototypes) # Model Specific - set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG=1> ) +set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG=1> ) #ensure cells are properly aligned in code set (ALIGN_LONGS 1) @@ -641,11 +372,11 @@ endif() # Model Specific if (HAVE_GCC) set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall ) -if ( ${C_COMPILER} MATCHES "GNU") - set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fomit-frame-pointer;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> ) -else() - set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> ) -endif() + if ( ${C_COMPILER} MATCHES "GNU") + set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fomit-frame-poinkter;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> ) + else() + set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$:-O3;-fstrict-aliasing;-freorder-blocks;-fsched-interblock> ) + endif() set_property( DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -fexceptions ) endif() @@ -662,21 +393,22 @@ endif (HAVE_GCC) #option (YAP_SWI_IO ON) OPTION (WITH_CALL_TRACER -"support for procedure-call tracing" ON) + "support for procedure-call tracing" ON) #TODO: if (WITH_CALL_TRACER) - list (APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS}) -set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:LOW_LEVEL_TRACER=1> ) + list (APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS}) + set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:LOW_LEVEL_TRACER=1> ) endif (WITH_CALL_TRACER) set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1) include_directories ( utf8proc packages/myddas packages/myddas/sqlite3/src) + if (ANDROID) - include_directories ( - packages/myddas/sqlite3/src/Android/jni/sqlite - packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper + include_directories ( + packages/myddas/sqlite3/src/Android/jni/sqlite + packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper ) endif (ANDROID) @@ -685,88 +417,94 @@ set_property( SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YA add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1) if (MYSQL_FOUND) - add_definitions(= -DMYDDAS_MYSQL=1) + add_definitions(= -DMYDDAS_MYSQL=1) endif() if (ODBC_FOUND) - add_definitions(= -DMYDDAS_ODBC=1) + add_definitions(= -DMYDDAS_ODBC=1) endif() if (MYSQL_POSTGRES) - add_definitions(= -DMYDDAS_POSTGRES=1) + add_definitions(= -DMYDDAS_POSTGRES=1) endif() OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON) IF (WITH_SWIG OR ANDROID) - find_host_package (SWIG) - # macro_log_feature (SWIG_FOUND "Swig" - # "Use SWIG Interface Generator " - # "http://www.swig.org" ON) + find_host_package (SWIG) + # macro_log_feature (SWIG_FOUND "Swig" + # "Use SWIG Interface Generator " + # "http://www.swig.org" ON) ENDIF (WITH_SWIG OR ANDROID) + option (WITH_PYTHON - "Allow Python->YAP and YAP->Python" ON) + "Allow Python->YAP and YAP->Python" ON) IF (WITH_PYTHON) - include(python NO_POLICY_SCOPE) + include(python NO_POLICY_SCOPE) ENDIF (WITH_PYTHON) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - if (WIN32) - List (APPEND YLIBS $ ) - List (APPEND YLIBS $ ) - if (WITH_PYTHON ) - List (APPEND YLIBS $ ) - endif() - endif() - +List (APPEND YLIBS $ ) +List (APPEND YLIBS $ ) +List (APPEND YLIBS $ ) +List (APPEND YLIBS $ ) +List (APPEND YLIBS $ ) +if (WIN32) + List (APPEND YLIBS $ ) + List (APPEND YLIBS $ ) + if (WITH_PYTHON ) + List (APPEND YLIBS $ ) + endif() +endif() +include (Sources) add_corelib( # Sets the name of the library. - libYap + libYap - # Sets the library as a shared library. - SHARED + # Sets the library as a shared library. + SHARED - ${ENGINE_SOURCES} - ${C_INTERFACE_SOURCES} - //${STATIC_SOURCES} - # cmake object libraries - ${YLIBS} - ) + ${ENGINE_SOURCES} + ${C_INTERFACE_SOURCES} + //${STATIC_SOURCES} + # cmake object libraries + ${YLIBS} + ) if (WIN32) - target_link_libraries(libYap ${WINDLLS}) - if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES ) - target_link_libraries(libYap ${PYTHON_LIBRARIES}) - endif() + target_link_libraries(libYap ${WINDLLS}) + if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES ) + target_link_libraries(libYap ${PYTHON_LIBRARIES}) + endif() endif (WIN32) - if (GMP_FOUND) - #config.h needs this (TODO: change in code latter) - include_directories( ${GMP_INCLUDE_DIRS} ) - target_link_libraries(libYap ${GMP_LIBRARIES} ) - endif (GMP_FOUND) +if (GMP_FOUND) + #config.h needs this (TODO: change in code latter) + include_directories( ${GMP_INCLUDE_DIRS} ) + target_link_libraries(libYap ${GMP_LIBRARIES} ) +endif (GMP_FOUND) +if (READLINE_FOUND) + include_directories( ${READLINE_INCLUDE_DIR} ) + target_link_libraries(libYap ${READLINE_LIBRARIES} ) + # required for configure + list (APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES}) + list (APPEND CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR}) +endif() -include (Sources) - set(YAP_STARTUP startup.yss) ## define system - # Optional libraries that affect compilation - # +# Optional libraries that affect compilation +# set(CMAKE_TOP_BINARY_DIR ${CMAKE_BINARY_DIR}) @@ -781,7 +519,7 @@ string( SUBSTRING ${CMAKE_SHARED_LIBRARY_SUFFIX} 1 -1 SO_EXT ) set_property(DIRECTORY PROPERTY CXX_STANDARD 11) # rpath stuff, hopefully it works - +# use, i.e. don't skip the full RPATH for the build tree # use, i.e. don't skip the full RPATH for the build tree SET(CMAKE_SKIP_BUILD_RPATH FALSE) @@ -789,34 +527,26 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE) # (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -SET(CMAKE_INSTALL_RPATH "${libdir};${dlls}:") +SET(CMAKE_INSTALL_RPATH "${libdir}:${dlls}:") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -set_target_properties(libYap - PROPERTIES OUTPUT_NAME Yap - ) - MY_set_target_properties(libYap - PROPERTIES VERSION ${YAP_FULL_VERSION} - SOVERSION ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION} - ) # the RPATH to be used when installing, but only if it's not a system directory -LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir};${dlls}" isSystemDir) +LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH "${libdir};${dlls}") + SET(CMAKE_INSTALL_RPATH "${libdir}") ENDIF("${isSystemDir}" STREQUAL "-1") - include_directories (H - H/generated - include os OPTYap utf8proc JIT/HPP) + H/generated + include os OPTYap utf8proc JIT/HPP) include_directories (BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_TOP_BINARY_DIR}) if (ANDROID) -include_directories (CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni) + include_directories (CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni) endif() include( Threads ) # @@ -827,12 +557,20 @@ include( Threads ) # list(APPEND YAP_SYSTEM_OPTIONS "thread support") +set_target_properties(libYap + PROPERTIES OUTPUT_NAME Yap + ) +MY_set_target_properties(libYap + PROPERTIES VERSION ${YAP_FULL_VERSION} + SOVERSION ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION} + ) + #utf-8 is not an option # we use the nice UTF-8 package #available at the Julia project - ADD_SUBDIRECTORY ( OPTYap ) - ADD_SUBDIRECTORY ( os ) +ADD_SUBDIRECTORY ( OPTYap ) +ADD_SUBDIRECTORY ( os ) ADD_SUBDIRECTORY ( packages/myddas ) ADD_SUBDIRECTORY ( utf8proc ) ADD_SUBDIRECTORY ( library/dialect/swi/fli ) @@ -849,29 +587,29 @@ ADD_SUBDIRECTORY( library) ADD_SUBDIRECTORY( swi/library "swiLibrary" ) if (ANDROID) - target_link_libraries(libYap android log) + target_link_libraries(libYap android log) endif () set_target_properties(libYap - PROPERTIES OUTPUT_NAME Yap + PROPERTIES OUTPUT_NAME Yap ) if (PYTHONLIBS_FOUND AND SWIG_FOUND) - add_subdirectory(packages/python/swig) + add_subdirectory(packages/python/swig) - include(FindPythonModule) + include(FindPythonModule) - find_python_module( jupyter ) + find_python_module( jupyter ) - if (PY_JUPYTER) - add_subdirectory(packages/python/yap_kernel) - ENDIF() + if (PY_JUPYTER) + add_subdirectory(packages/python/yap_kernel) + ENDIF() endif() IF (SWIG_FOUND OR ANDROID) - add_subDIRECTORY (packages/swig NO_POLICY_SCOPE) + add_subDIRECTORY (packages/swig NO_POLICY_SCOPE) ENDIF() @@ -908,28 +646,28 @@ IF (WITH_CLPBN) ENDIF(WITH_CLPBN) IF (WITH_CPLINT) - add_subDIRECTORY (packages/cplint) - ENDIF(WITH_CPLINT) + add_subDIRECTORY (packages/cplint) +ENDIF(WITH_CPLINT) - # please install doxygen for prolog first - # git clone http://www.github.com/vscosta/doxygen-yap - # cd doxygen-yap - # mkdir -p build - # cd build - # make; sudo make install - option (WITH_DOCS - "generate YAP docs" OFF) +# please install doxygen for prolog first +# git clone http://www.github.com/vscosta/doxygen-yap +# cd doxygen-yap +# mkdir -p build +# cd build +# make; sudo make install +option (WITH_DOCS + "generate YAP docs" OFF) - IF (WITH_DOCS) +IF (WITH_DOCS) add_subDIRECTORY (docs) - ENDIF (WITH_DOCS) +ENDIF (WITH_DOCS) # add_subDIRECTORY (packages/cuda) option (WITH_GECODE -"interface gecode constraint solver" ON) + "interface gecode constraint solver" ON) if (WITH_GECODE) -add_subDIRECTORY (packages/gecode) + add_subDIRECTORY (packages/gecode) endif() add_subDIRECTORY (packages/real) @@ -1008,7 +746,7 @@ endif() if(WIN32) if(MSVC) - set(MSVC_RUNTIME "dynamic") + set(MSVC_RUNTIME "dynamic") ENDIF(MSVC) target_link_libraries(libYap wsock32 ws2_32 Shlwapi) @@ -1022,11 +760,11 @@ set_target_properties (yap-bin PROPERTIES OUTPUT_NAME yap) target_link_libraries(yap-bin libYap ) - install(TARGETS libYap yap-bin - RUNTIME DESTINATION ${bindir} - LIBRARY DESTINATION ${libdir} - ARCHIVE DESTINATION ${libdir} - ) +install(TARGETS libYap yap-bin + RUNTIME DESTINATION ${bindir} + LIBRARY DESTINATION ${libdir} + ARCHIVE DESTINATION ${libdir} + ) CMAKE_DEPENDENT_OPTION (WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON @@ -1035,26 +773,26 @@ CMAKE_DEPENDENT_OPTION (WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" CMAKE_DEPENDENT_OPTION (WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON "NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF ) - add_subDIRECTORY(library/lammpi) +add_subDIRECTORY(library/lammpi) - if (MPI_C_FOUND) +if (MPI_C_FOUND) CMAKE_DEPENDENT_OPTION( WITH_MPI ON "Interface to OpenMPI/MPICH" "MPI_C_FOUND" OFF) macro_optional_add_subDIRECTORY(library/mpi) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ") - include_directories(${MPI_C_INCLUDE_PATH}) - target_link_libraries(yap-bin ${MPI_C_LIBRARIES} ) - if(MPI_C_COMPILE_FLAGS) - set_target_properties(yap-bin PROPERTIES - COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}") - endif(MPI_C_COMPILE_FLAGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ") + include_directories(${MPI_C_INCLUDE_PATH}) + target_link_libraries(yap-bin ${MPI_C_LIBRARIES} ) + if(MPI_C_COMPILE_FLAGS) + set_target_properties(yap-bin PROPERTIES + COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}") + endif(MPI_C_COMPILE_FLAGS) - if(MPI_C_LINK_FLAGS) - set_target_properties(yap-bin PROPERTIES - LINK_FLAGS "${MPI_C_LINK_FLAGS}") - endif() - endif (MPI_C_FOUND) + if(MPI_C_LINK_FLAGS) + set_target_properties(yap-bin PROPERTIES + LINK_FLAGS "${MPI_C_LINK_FLAGS}") + endif() +endif (MPI_C_FOUND) ## add_subDIRECTORY(utils) @@ -1064,7 +802,7 @@ CMAKE_DEPENDENT_OPTION (WITH_SYSTEM_SHM "Use SHM for shared memory allocation" O macro_display_feature_log() if(POLICY CMP0058) -cmake_policy(SET CMP0058 NEW) + cmake_policy(SET CMP0058 NEW) endif(POLICY CMP0058) include(Config NO_POLICY_SCOPE) @@ -1072,5 +810,5 @@ include(Config NO_POLICY_SCOPE) feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES - INCLUDE_QUIET_PACKAGES -) + INCLUDE_QUIET_PACKAGES + ) diff --git a/README.md b/README.md index 3f94fb556..7a61c7ee2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - +``
![The YAP Logo](docs/icons/yap_128x128x32.png)
diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 7d88ccf8d..ac4b4b6fb 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -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) - diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake index 4a364f9ff..a0fbf77d0 100644 --- a/cmake/FindLLVM.cmake +++ b/cmake/FindLLVM.cmake @@ -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() diff --git a/cmake/FindLibR.cmake b/cmake/FindLibR.cmake index d6a05569d..adecd8cd7 100755 --- a/cmake/FindLibR.cmake +++ b/cmake/FindLibR.cmake @@ -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 -) diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake index de432a3eb..8595a1005 100644 --- a/cmake/FindReadline.cmake +++ b/cmake/FindReadline.cmake @@ -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 ) diff --git a/cmake/readline.cmake b/cmake/readline.cmake index c75482bf8..67aab37a9 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -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) diff --git a/config.h.cmake b/config.h.cmake index 2ae0c048e..2176733d4 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -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 - diff --git a/info/build.sh b/info/build.sh index eb06d6e5d..c8ffac3fe 100644 --- a/info/build.sh +++ b/info/build.sh @@ -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 diff --git a/info/meta.yaml b/info/meta.yaml index 8e6c482d9..152a6f5d3 100644 --- a/info/meta.yaml +++ b/info/meta.yaml @@ -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 diff --git a/os/YapIOConfig.h.cmake b/os/YapIOConfig.h.cmake index 41d4a4a75..2d0701eea 100644 --- a/os/YapIOConfig.h.cmake +++ b/os/YapIOConfig.h.cmake @@ -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 diff --git a/os/readline.c b/os/readline.c index ec3007ae7..73f460b2e 100644 --- a/os/readline.c +++ b/os/readline.c @@ -53,7 +53,7 @@ static char SccsId[] = "%W% %G%"; #include "iopreds.h" -#if USE_READLINE +#if defined(HAVE_LIBREADLINE) #include #include diff --git a/packages/python/swig/setup.py.cmake b/packages/python/swig/setup.py.cmake index 58b803cd9..08807e0df 100644 --- a/packages/python/swig/setup.py.cmake +++ b/packages/python/swig/setup.py.cmake @@ -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}'], diff --git a/packages/real/CMakeLists.txt b/packages/real/CMakeLists.txt index 15b1fcac7..7a84d4710 100644 --- a/packages/real/CMakeLists.txt +++ b/packages/real/CMakeLists.txt @@ -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() diff --git a/pl/messages.yap b/pl/messages.yap index 9450dbea7..5d8c1909b 100644 --- a/pl/messages.yap +++ b/pl/messages.yap @@ -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 ].