From 6148e8199fa664e22f6faab210900e6f40869158 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 23 Aug 2016 15:08:36 -0500 Subject: [PATCH] linux_weird --- cmake/cudd.cmake | 6 +++--- library/system.yap | 14 ++++++++++++++ library/system/sys.c | 22 ++++++++++++++++++++++ packages/bdd/cudd_config.h.cmake | 10 ++++++++++ packages/cplint/cplint.h | 2 +- packages/real/real.pl | 1 + packages/swig/python/setup.py.cmake | 3 ++- 7 files changed, 53 insertions(+), 5 deletions(-) diff --git a/cmake/cudd.cmake b/cmake/cudd.cmake index 69db4bced..de2d30096 100644 --- a/cmake/cudd.cmake +++ b/cmake/cudd.cmake @@ -18,10 +18,10 @@ if (CUDD_FOUND) set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} ) -check_include_files( cudd.h HAVE_CUDD_H ) +check_include_files( "stdio.h;cudd.h" HAVE_CUDD_H ) check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H ) -check_include_files( cuddInt.h HAVE_CUDDINT_H ) -check_include_files( "stdio.h;cudd/cudd.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H ) +check_include_files( "cuddInt.h" HAVE_CUDDINT_H ) +check_include_files( "cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H ) endif (CUDD_FOUND) endif(WITH_CUDD) diff --git a/library/system.yap b/library/system.yap index 498d692ae..9dbcca7f1 100644 --- a/library/system.yap +++ b/library/system.yap @@ -45,6 +45,7 @@ mktemp/2, make_directory/1, popen/3, + read_link/3, rename_file/2, shell/0, shell/1, @@ -318,6 +319,14 @@ Create file _OldFile_ to _NewFile_. This predicate uses the `C` built-in function `rename`. +*/ +/** @pred read_link(+ SymbolicLink, -Link, -NewPath) + + +Follow a _SymbolicLink_, and obtain the actual _Link_ and the target _newPath_). This predicate uses the +`C` built-in function `readlink` and is not yet operational in WIN32. + + */ /** @pred shell @@ -797,3 +806,8 @@ tmpdir(TmpDir):- path_separator('\\'):- win, !. path_separator('/'). + +read_link(P,D,F) :- + read_link(P, D), + absolute_file_name(D, [], F). + diff --git a/library/system/sys.c b/library/system/sys.c index 3df2e5ae2..fab7b2321 100644 --- a/library/system/sys.c +++ b/library/system/sys.c @@ -312,6 +312,27 @@ static YAP_Bool rename_file(void) { return (TRUE); } + + static YAP_Bool read_link(void) { + char *s1 = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); +#if HAVE_READLINK + char buf[PATH_MAX + 1]; + + if (readlink(s1, buf, PATH_MAX) < 0) + return false; + + + /* return an error number */ + if (!YAP_Unify(YAP_ARG2, YAP_MkAtomTerm(YAP_LookupAtom(buf)))) { + return false; + } +#endif +# if _WIN32 + return false; +#endif + return true; +} + static YAP_Bool dir_separator(void) { return (YAP_Unify(YAP_ARG1, YAP_MkAtomTerm(YAP_LookupAtom("/")))); } @@ -1038,6 +1059,7 @@ void init_sys(void) { YAP_UserCPredicate("tmpdir", p_tmpdir, 2); YAP_UserCPredicate("rename_file", rename_file, 3); YAP_UserCPredicate("sleep", p_sleep, 2); + YAP_UserCPredicate("read_link", read_link, 2); YAP_UserCPredicate("error_message", error_message, 2); YAP_UserCPredicate("win", win, 0); YAP_UserCPredicate("md5", md5, 3); diff --git a/packages/bdd/cudd_config.h.cmake b/packages/bdd/cudd_config.h.cmake index c44e536a2..689fb289b 100644 --- a/packages/bdd/cudd_config.h.cmake +++ b/packages/bdd/cudd_config.h.cmake @@ -1,5 +1,15 @@ // cmake template file +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_H +#cmakedefine HAVE_CUDD_H ${HAVE_CUDD_H} +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_CUDD_CUDD_H +#cmakedefine HAVE_CUDD_CUDD_H ${HAVE_CUDD_CUDD_H} +#endif + /* Define to 1 if you have the header file. */ #ifndef HAVE_CUDDINT_H #cmakedefine HAVE_CUDDINT_H ${HAVE_CUDDINT_H} diff --git a/packages/cplint/cplint.h b/packages/cplint/cplint.h index 500793da5..313bc17a6 100644 --- a/packages/cplint/cplint.h +++ b/packages/cplint/cplint.h @@ -12,7 +12,7 @@ for the relative license. #include "cudd_config.h" #if HAVE_CUDD_CUDDINT_H #include "cudd/cuddInt.h" -#else +#elif HAVE_CUDDINT_H #include "cuddInt.h" #endif #include "YapInterface.h" diff --git a/packages/real/real.pl b/packages/real/real.pl index de6905f7e..19985c71d 100755 --- a/packages/real/real.pl +++ b/packages/real/real.pl @@ -66,6 +66,7 @@ :- use_module(library(charsio)). :- use_module(library(readutil)). :- use_module(library(debug)). +:- use_module(library(system)). :- dynamic( real:r_started/1 ). diff --git a/packages/swig/python/setup.py.cmake b/packages/swig/python/setup.py.cmake index 788f06453..9856f5c82 100644 --- a/packages/swig/python/setup.py.cmake +++ b/packages/swig/python/setup.py.cmake @@ -4,7 +4,7 @@ import os import platform if platform.system() == 'Darwin': - my_extra_link_args = ['-Wl,-rpath','${dlls}'] + my_extra_link_args = ['-Wl,-rpath','-Wl,${dlls}'] else: my_extra_link_args = [] @@ -23,6 +23,7 @@ setup( extra_link_args=my_extra_link_args, libraries=['Yap++','Yap','YAPPython'], include_dirs=['../../..', + '${GMP_INCLUDE_DIRS}', '${CMAKE_SOURCE_DIR}/H', '${CMAKE_SOURCE_DIR}/H/generated', '${CMAKE_SOURCE_DIR}/OPTYap',