diff options
Diffstat (limited to 'Source/kwsys/SharedForward.h.in')
-rw-r--r-- | Source/kwsys/SharedForward.h.in | 451 |
1 files changed, 227 insertions, 224 deletions
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in index 0caf5e7..5716cd4 100644 --- a/Source/kwsys/SharedForward.h.in +++ b/Source/kwsys/SharedForward.h.in @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ #ifndef @KWSYS_NAMESPACE@_SharedForward_h -#define @KWSYS_NAMESPACE@_SharedForward_h +# define @KWSYS_NAMESPACE@_SharedForward_h /* This header is used to create a forwarding executable sets up the @@ -59,134 +59,134 @@ /* Disable -Wcast-qual warnings since they are too hard to fix in a cross-platform way. */ -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wcast-qual") -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" -#endif -#endif - -#if defined(__BORLANDC__) && !defined(__cplusplus) +# if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wcast-qual") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcast-qual" +# endif +# endif + +# if defined(__BORLANDC__) && !defined(__cplusplus) /* Code has no effect; raised by winnt.h in C (not C++) when ignoring an unused parameter using "(param)" syntax (i.e. no cast to void). */ -#pragma warn - 8019 -#endif +# pragma warn - 8019 +# endif /* Full path to the directory in which this executable is built. Do not include a trailing slash. */ -#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD) -#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD" -#endif -#if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD) -#define KWSYS_SHARED_FORWARD_DIR_BUILD \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD -#endif +# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD) +# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD" +# endif +# if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD) +# define KWSYS_SHARED_FORWARD_DIR_BUILD \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD +# endif /* Library search path for build tree. */ -#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD) -#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD" -#endif -#if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD) -#define KWSYS_SHARED_FORWARD_PATH_BUILD \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD -#endif +# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD) +# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD" +# endif +# if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD) +# define KWSYS_SHARED_FORWARD_PATH_BUILD \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD +# endif /* Library search path for install tree. */ -#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL) -#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL" -#endif -#if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL) -#define KWSYS_SHARED_FORWARD_PATH_INSTALL \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL -#endif +# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL) +# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL" +# endif +# if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL) +# define KWSYS_SHARED_FORWARD_PATH_INSTALL \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL +# endif /* The real executable to which to forward in the build tree. */ -#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD) -#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD" -#endif -#if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD) -#define KWSYS_SHARED_FORWARD_EXE_BUILD \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD -#endif +# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD) +# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD" +# endif +# if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD) +# define KWSYS_SHARED_FORWARD_EXE_BUILD \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD +# endif /* The real executable to which to forward in the install tree. */ -#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL) -#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL" -#endif -#if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL) -#define KWSYS_SHARED_FORWARD_EXE_INSTALL \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL -#endif +# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL) +# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL" +# endif +# if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL) +# define KWSYS_SHARED_FORWARD_EXE_INSTALL \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL +# endif /* The configuration name with which this executable was built (Debug/Release). */ -#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME) -#define KWSYS_SHARED_FORWARD_CONFIG_NAME \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME -#else -#undef KWSYS_SHARED_FORWARD_CONFIG_NAME -#endif +# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME) +# define KWSYS_SHARED_FORWARD_CONFIG_NAME \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME +# else +# undef KWSYS_SHARED_FORWARD_CONFIG_NAME +# endif /* Create command line option to replace executable. */ -#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND) -#if !defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND) -#define KWSYS_SHARED_FORWARD_OPTION_COMMAND \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND -#endif -#else -#undef KWSYS_SHARED_FORWARD_OPTION_COMMAND -#endif +# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND) +# if !defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND) +# define KWSYS_SHARED_FORWARD_OPTION_COMMAND \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND +# endif +# else +# undef KWSYS_SHARED_FORWARD_OPTION_COMMAND +# endif /* Create command line option to print environment setting and exit. */ -#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT) -#if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) -#define KWSYS_SHARED_FORWARD_OPTION_PRINT \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT -#endif -#else -#undef KWSYS_SHARED_FORWARD_OPTION_PRINT -#endif +# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT) +# if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) +# define KWSYS_SHARED_FORWARD_OPTION_PRINT \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT +# endif +# else +# undef KWSYS_SHARED_FORWARD_OPTION_PRINT +# endif /* Create command line option to run ldd or equivalent. */ -#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD) -#if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD) -#define KWSYS_SHARED_FORWARD_OPTION_LDD \ - @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD -#endif -#else -#undef KWSYS_SHARED_FORWARD_OPTION_LDD -#endif +# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD) +# if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD) +# define KWSYS_SHARED_FORWARD_OPTION_LDD \ + @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD +# endif +# else +# undef KWSYS_SHARED_FORWARD_OPTION_LDD +# endif /* Include needed system headers. */ -#include <errno.h> -#include <limits.h> -#include <stddef.h> /* size_t */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +# include <errno.h> +# include <limits.h> +# include <stddef.h> /* size_t */ +# include <stdio.h> +# include <stdlib.h> +# include <string.h> -#if defined(_WIN32) && !defined(__CYGWIN__) -#include <windows.h> +# if defined(_WIN32) && !defined(__CYGWIN__) +# include <windows.h> -#include <io.h> -#include <process.h> -#define KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* re-escape argv for execvp */ -#else -#include <sys/stat.h> -#include <unistd.h> -#endif +# include <io.h> +# include <process.h> +# define KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* re-escape argv for execvp */ +# else +# include <sys/stat.h> +# include <unistd.h> +# endif /* Configuration for this platform. */ /* The path separator for this platform. */ -#if defined(_WIN32) && !defined(__CYGWIN__) -#define KWSYS_SHARED_FORWARD_PATH_SEP ';' -#define KWSYS_SHARED_FORWARD_PATH_SLASH '\\' -#else -#define KWSYS_SHARED_FORWARD_PATH_SEP ':' -#define KWSYS_SHARED_FORWARD_PATH_SLASH '/' -#endif +# if defined(_WIN32) && !defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_PATH_SEP ';' +# define KWSYS_SHARED_FORWARD_PATH_SLASH '\\' +# else +# define KWSYS_SHARED_FORWARD_PATH_SEP ':' +# define KWSYS_SHARED_FORWARD_PATH_SLASH '/' +# endif static const char kwsys_shared_forward_path_sep[2] = { KWSYS_SHARED_FORWARD_PATH_SEP, 0 }; @@ -195,99 +195,101 @@ static const char kwsys_shared_forward_path_slash[2] = { }; /* The maximum length of a file name. */ -#if defined(PATH_MAX) -#define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX -#elif defined(MAXPATHLEN) -#define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN -#else -#define KWSYS_SHARED_FORWARD_MAXPATH 16384 -#endif +# if defined(PATH_MAX) +# define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX +# elif defined(MAXPATHLEN) +# define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN +# else +# define KWSYS_SHARED_FORWARD_MAXPATH 16384 +# endif /* Select the environment variable holding the shared library runtime search path for this platform and build configuration. Also select ldd command equivalent. */ /* Linux */ -#if defined(__linux) -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# if defined(__linux) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" /* FreeBSD */ -#elif defined(__FreeBSD__) -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif defined(__FreeBSD__) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" /* OpenBSD */ -#elif defined(__OpenBSD__) -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif defined(__OpenBSD__) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" /* OS X */ -#elif defined(__APPLE__) -#define KWSYS_SHARED_FORWARD_LDD "otool", "-L" -#define KWSYS_SHARED_FORWARD_LDD_N 2 -#define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH" +# elif defined(__APPLE__) +# define KWSYS_SHARED_FORWARD_LDD "otool", "-L" +# define KWSYS_SHARED_FORWARD_LDD_N 2 +# define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH" /* AIX */ -#elif defined(_AIX) -#define KWSYS_SHARED_FORWARD_LDD "dump", "-H" -#define KWSYS_SHARED_FORWARD_LDD_N 2 -#define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH" +# elif defined(_AIX) +# define KWSYS_SHARED_FORWARD_LDD "dump", "-H" +# define KWSYS_SHARED_FORWARD_LDD_N 2 +# define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH" /* SUN */ -#elif defined(__sun) -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#include <sys/isa_defs.h> -#if defined(_ILP32) -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#elif defined(_LP64) -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64" -#endif +# elif defined(__sun) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# include <sys/isa_defs.h> +# if defined(_ILP32) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif defined(_LP64) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64" +# endif /* HP-UX */ -#elif defined(__hpux) -#define KWSYS_SHARED_FORWARD_LDD "chatr" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#if defined(__LP64__) -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#else -#define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH" -#endif +# elif defined(__hpux) +# define KWSYS_SHARED_FORWARD_LDD "chatr" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# if defined(__LP64__) +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# else +# define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH" +# endif /* SGI MIPS */ -#elif defined(__sgi) && defined(_MIPS_SIM) -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#if _MIPS_SIM == _ABIO32 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#elif _MIPS_SIM == _ABIN32 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH" -#elif _MIPS_SIM == _ABI64 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH" -#endif +# elif defined(__sgi) && defined(_MIPS_SIM) +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# if _MIPS_SIM == _ABIO32 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# elif _MIPS_SIM == _ABIN32 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH" +# elif _MIPS_SIM == _ABI64 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH" +# endif /* Cygwin */ -#elif defined(__CYGWIN__) -#define KWSYS_SHARED_FORWARD_LDD "cygcheck" /* TODO: cygwin 1.7 has ldd */ -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#define KWSYS_SHARED_FORWARD_LDPATH "PATH" +# elif defined(__CYGWIN__) +# define KWSYS_SHARED_FORWARD_LDD \ + "cygcheck" /* TODO: cygwin 1.7 has ldd \ + */ +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "PATH" /* Windows */ -#elif defined(_WIN32) -#define KWSYS_SHARED_FORWARD_LDPATH "PATH" +# elif defined(_WIN32) +# define KWSYS_SHARED_FORWARD_LDPATH "PATH" /* Guess on this unknown system. */ -#else -#define KWSYS_SHARED_FORWARD_LDD "ldd" -#define KWSYS_SHARED_FORWARD_LDD_N 1 -#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -#endif +# else +# define KWSYS_SHARED_FORWARD_LDD "ldd" +# define KWSYS_SHARED_FORWARD_LDD_N 1 +# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" +# endif -#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV +# ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV typedef struct kwsys_sf_arg_info_s { const char* arg; @@ -404,25 +406,25 @@ static char* kwsys_sf_get_arg(kwsys_sf_arg_info info, char* out) return out; } -#endif +# endif /* Function to convert a logical or relative path to a physical full path. */ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path) { -#if defined(_WIN32) && !defined(__CYGWIN__) +# if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH, out_path, 0); return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH; -#else +# else /* Implementation for UNIX. */ return realpath(in_path, out_path) != 0; -#endif +# endif } static int kwsys_shared_forward_samepath(const char* file1, const char* file2) { -#if defined(_WIN32) +# if defined(_WIN32) int result = 0; HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); @@ -440,19 +442,19 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2) CloseHandle(h1); CloseHandle(h2); return result; -#else +# else struct stat fs1, fs2; return (stat(file1, &fs1) == 0 && stat(file2, &fs2) == 0 && memcmp(&fs2.st_dev, &fs1.st_dev, sizeof(fs1.st_dev)) == 0 && memcmp(&fs2.st_ino, &fs1.st_ino, sizeof(fs1.st_ino)) == 0 && fs2.st_size == fs1.st_size); -#endif +# endif } /* Function to report a system error message. */ static void kwsys_shared_forward_strerror(char* message) { -#if defined(_WIN32) && !defined(__CYGWIN__) +# if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ DWORD original = GetLastError(); DWORD length = @@ -465,17 +467,17 @@ static void kwsys_shared_forward_strerror(char* message) "Error 0x%X (FormatMessage failed with error 0x%X)", original, GetLastError()); } -#else +# else /* Implementation for UNIX. */ strcpy(message, strerror(errno)); -#endif +# endif } /* Functions to execute a child process. */ static void kwsys_shared_forward_execvp(const char* cmd, char const* const* argv) { -#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV +# ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* Count the number of arguments. */ int argc = 0; { @@ -498,16 +500,16 @@ static void kwsys_shared_forward_execvp(const char* cmd, /* Replace the command line to be used. */ argv = (char const* const*)nargv; } -#endif +# endif /* Invoke the child process. */ -#if defined(_MSC_VER) +# if defined(_MSC_VER) _execvp(cmd, argv); -#elif defined(__MINGW32__) && !defined(__MINGW64__) +# elif defined(__MINGW32__) && !defined(__MINGW64__) execvp(cmd, argv); -#else +# else execvp(cmd, (char* const*)argv); -#endif +# endif } /* Function to get the directory containing the given file or directory. */ @@ -530,14 +532,14 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result) /* Only one leading slash. */ strcpy(result, kwsys_shared_forward_path_slash); } -#if defined(_WIN32) +# if defined(_WIN32) else if (last_slash_index == 2 && begin[1] == ':') { /* Only one leading drive letter and slash. */ strncpy(result, begin, (size_t)last_slash_index); result[last_slash_index] = KWSYS_SHARED_FORWARD_PATH_SLASH; result[last_slash_index + 1] = 0; } -#endif +# endif else { /* A non-leading slash. */ strncpy(result, begin, (size_t)last_slash_index); @@ -548,16 +550,16 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result) /* Function to check if a file exists and is executable. */ static int kwsys_shared_forward_is_executable(const char* f) { -#if defined(_MSC_VER) -#define KWSYS_SHARED_FORWARD_ACCESS _access -#else -#define KWSYS_SHARED_FORWARD_ACCESS access -#endif -#if defined(X_OK) -#define KWSYS_SHARED_FORWARD_ACCESS_OK X_OK -#else -#define KWSYS_SHARED_FORWARD_ACCESS_OK 04 -#endif +# if defined(_MSC_VER) +# define KWSYS_SHARED_FORWARD_ACCESS _access +# else +# define KWSYS_SHARED_FORWARD_ACCESS access +# endif +# if defined(X_OK) +# define KWSYS_SHARED_FORWARD_ACCESS_OK X_OK +# else +# define KWSYS_SHARED_FORWARD_ACCESS_OK 04 +# endif if (KWSYS_SHARED_FORWARD_ACCESS(f, KWSYS_SHARED_FORWARD_ACCESS_OK) == 0) { return 1; } else { @@ -641,12 +643,12 @@ static int kwsys_shared_forward_fullpath(const char* self_path, /* Already a full path. */ strcpy(result, in_path); } -#if defined(_WIN32) +# if defined(_WIN32) else if (in_path[0] && in_path[1] == ':') { /* Already a full path. */ strcpy(result, in_path); } -#endif +# endif else { /* Relative to self path. */ char temp_path[KWSYS_SHARED_FORWARD_MAXPATH]; @@ -683,14 +685,14 @@ static int kwsys_shared_forward_get_settings(const char* self_path, const char* exe_path; /* Get the real name of the build and self paths. */ -#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) +# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) char build_path[] = KWSYS_SHARED_FORWARD_DIR_BUILD "/" KWSYS_SHARED_FORWARD_CONFIG_NAME; char self_path_logical[KWSYS_SHARED_FORWARD_MAXPATH]; -#else +# else char build_path[] = KWSYS_SHARED_FORWARD_DIR_BUILD; const char* self_path_logical = self_path; -#endif +# endif char build_path_real[KWSYS_SHARED_FORWARD_MAXPATH]; char self_path_real[KWSYS_SHARED_FORWARD_MAXPATH]; if (!kwsys_shared_forward_realpath(self_path, self_path_real)) { @@ -706,29 +708,29 @@ static int kwsys_shared_forward_get_settings(const char* self_path, kwsys_shared_forward_samepath(self_path_real, build_path_real)) { /* Running in build tree. Use the build path and exe. */ search_path = search_path_build; -#if defined(_WIN32) +# if defined(_WIN32) exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD ".exe"; -#else +# else exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD; -#endif +# endif -#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) +# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) /* Remove the configuration directory from self_path. */ kwsys_shared_forward_dirname(self_path, self_path_logical); -#endif +# endif } else { /* Running in install tree. Use the install path and exe. */ search_path = search_path_install; -#if defined(_WIN32) +# if defined(_WIN32) exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL ".exe"; -#else +# else exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL; -#endif +# endif -#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) +# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME) /* Use the original self path directory. */ strcpy(self_path_logical, self_path); -#endif +# endif } /* Construct the runtime search path. */ @@ -795,7 +797,7 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) /* Store the environment variable. */ putenv(kwsys_shared_forward_ldpath); -#if defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND) +# if defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND) /* Look for the command line replacement option. */ if (argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_COMMAND) == 0) { @@ -806,14 +808,15 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) argc -= 2; } else { /* The option was not given an executable. */ - fprintf(stderr, "Option " KWSYS_SHARED_FORWARD_OPTION_COMMAND - " must be followed by a command line.\n"); + fprintf(stderr, + "Option " KWSYS_SHARED_FORWARD_OPTION_COMMAND + " must be followed by a command line.\n"); return 1; } } -#endif +# endif -#if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) +# if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT) /* Look for the print command line option. */ if (argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_PRINT) == 0) { @@ -821,12 +824,12 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) fprintf(stdout, "%s\n", exe); return 0; } -#endif +# endif -#if defined(KWSYS_SHARED_FORWARD_OPTION_LDD) +# if defined(KWSYS_SHARED_FORWARD_OPTION_LDD) /* Look for the ldd command line option. */ if (argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_LDD) == 0) { -#if defined(KWSYS_SHARED_FORWARD_LDD) +# if defined(KWSYS_SHARED_FORWARD_LDD) /* Use the named ldd-like executable and arguments. */ char const* ldd_argv[] = { KWSYS_SHARED_FORWARD_LDD, 0, 0 }; ldd_argv[KWSYS_SHARED_FORWARD_LDD_N] = exe; @@ -835,13 +838,13 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) /* Report why execution failed. */ kwsys_shared_forward_print_failure(ldd_argv); return 1; -#else +# else /* We have no ldd-like executable available on this platform. */ fprintf(stderr, "No ldd-like tool is known to this executable.\n"); return 1; -#endif +# endif } -#endif +# endif /* Replace this process with the real executable. */ argv[0] = exe; @@ -865,12 +868,12 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) } /* Restore warning stack. */ -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wcast-qual") -#pragma clang diagnostic pop -#endif -#endif +# if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wcast-qual") +# pragma clang diagnostic pop +# endif +# endif #else -#error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once." +# error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once." #endif |