mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 15:39:00 +08:00
Add port for gnu scientific library
This commit is contained in:
parent
bf924ce9a6
commit
4b702645bd
165
ports/libgsl/0001-configure.patch
Normal file
165
ports/libgsl/0001-configure.patch
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
---
|
||||||
|
config.h.in => config.h | 50 ++++++++++++++++++++++++-------------------------
|
||||||
|
1 file changed, 25 insertions(+), 25 deletions(-)
|
||||||
|
rename config.h.in => config.h (92%)
|
||||||
|
|
||||||
|
diff --git a/config.h.in b/config.h
|
||||||
|
similarity index 92%
|
||||||
|
rename from config.h.in
|
||||||
|
rename to config.h
|
||||||
|
index d39c766..c650f5b 100644
|
||||||
|
--- a/config.h.in
|
||||||
|
+++ b/config.h
|
||||||
|
@@ -8,19 +8,19 @@
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `acosh', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_ACOSH
|
||||||
|
+#define HAVE_DECL_ACOSH 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `asinh', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_ASINH
|
||||||
|
+#define HAVE_DECL_ASINH 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `atanh', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_ATANH
|
||||||
|
+#define HAVE_DECL_ATANH 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `expm1', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_EXPM1
|
||||||
|
+#define HAVE_DECL_EXPM1 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `feenableexcept', and to 0 if
|
||||||
|
you don't. */
|
||||||
|
@@ -40,31 +40,31 @@
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `frexp', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_FREXP
|
||||||
|
+#define HAVE_DECL_FREXP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `hypot', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_HYPOT
|
||||||
|
+#define HAVE_DECL_HYPOT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `isfinite', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
-#undef HAVE_DECL_ISFINITE
|
||||||
|
+#define HAVE_DECL_ISFINITE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_ISINF
|
||||||
|
+#define HAVE_DECL_ISINF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_ISNAN
|
||||||
|
+#define HAVE_DECL_ISNAN 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `ldexp', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_LDEXP
|
||||||
|
+#define HAVE_DECL_LDEXP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `log1p', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
-#undef HAVE_DECL_LOG1P
|
||||||
|
+#define HAVE_DECL_LOG1P 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#undef HAVE_DLFCN_H
|
||||||
|
@@ -73,13 +73,13 @@
|
||||||
|
#undef HAVE_DOPRNT
|
||||||
|
|
||||||
|
/* Defined if you have ansi EXIT_SUCCESS and EXIT_FAILURE in stdlib.h */
|
||||||
|
-#undef HAVE_EXIT_SUCCESS_AND_FAILURE
|
||||||
|
+#define HAVE_EXIT_SUCCESS_AND_FAILURE 1
|
||||||
|
|
||||||
|
/* Defined on architectures with excess floating-point precision */
|
||||||
|
#undef HAVE_EXTENDED_PRECISION_REGISTERS
|
||||||
|
|
||||||
|
/* Define if x86 processor has sse extensions. */
|
||||||
|
-#undef HAVE_FPU_X86_SSE
|
||||||
|
+#define HAVE_FPU_X86_SSE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ieeefp.h> header file. */
|
||||||
|
#undef HAVE_IEEEFP_H
|
||||||
|
@@ -94,43 +94,43 @@
|
||||||
|
#undef HAVE_INLINE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
-#undef HAVE_INTTYPES_H
|
||||||
|
+#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `m' library (-lm). */
|
||||||
|
#undef HAVE_LIBM
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memcpy' function. */
|
||||||
|
-#undef HAVE_MEMCPY
|
||||||
|
+#define HAVE_MEMCPY 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
-#undef HAVE_MEMMOVE
|
||||||
|
+#define HAVE_MEMMOVE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
-#undef HAVE_MEMORY_H
|
||||||
|
+#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define this if printf can handle %Lf for long double */
|
||||||
|
#undef HAVE_PRINTF_LONGDOUBLE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
-#undef HAVE_STDINT_H
|
||||||
|
+#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
-#undef HAVE_STDLIB_H
|
||||||
|
+#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strdup' function. */
|
||||||
|
-#undef HAVE_STRDUP
|
||||||
|
+#define HAVE_STRDUP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
-#undef HAVE_STRING_H
|
||||||
|
+#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtol' function. */
|
||||||
|
-#undef HAVE_STRTOL
|
||||||
|
+#define HAVE_STRTOL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtoul' function. */
|
||||||
|
-#undef HAVE_STRTOUL
|
||||||
|
+#define HAVE_STRTOUL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
@@ -142,7 +142,7 @@
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vprintf' function. */
|
||||||
|
-#undef HAVE_VPRINTF
|
||||||
|
+#define HAVE_VPRINTF 1
|
||||||
|
|
||||||
|
/* Define if you need to hide the static definitions of inline functions */
|
||||||
|
#undef HIDE_INLINE_STATIC
|
||||||
|
@@ -176,7 +176,7 @@
|
||||||
|
#undef RELEASED
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
-#undef STDC_HEADERS
|
||||||
|
+#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#undef VERSION
|
||||||
|
--
|
||||||
|
|
97
ports/libgsl/0002-add-fp-control.patch
Normal file
97
ports/libgsl/0002-add-fp-control.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
---
|
||||||
|
ieee-utils/fp-win.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
ieee-utils/fp.c | 2 ++
|
||||||
|
2 files changed, 72 insertions(+)
|
||||||
|
create mode 100644 ieee-utils/fp-win.c
|
||||||
|
|
||||||
|
diff --git a/ieee-utils/fp-win.c b/ieee-utils/fp-win.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..e024eae
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/ieee-utils/fp-win.c
|
||||||
|
@@ -0,0 +1,70 @@
|
||||||
|
+/* fp-win.c
|
||||||
|
+ *
|
||||||
|
+ * Author: Brian Gladman
|
||||||
|
+ *
|
||||||
|
+ * This program is free software; you can redistribute it and/or modify
|
||||||
|
+ * it under the terms of the GNU General Public License as published by
|
||||||
|
+ * the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
+ * your option) any later version.
|
||||||
|
+ *
|
||||||
|
+ * This program is distributed in the hope that it will be useful, but
|
||||||
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
+ * General Public License for more details.
|
||||||
|
+ *
|
||||||
|
+ * You should have received a copy of the GNU General Public License
|
||||||
|
+ * along with this program; if not, write to the Free Software
|
||||||
|
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <float.h>
|
||||||
|
+
|
||||||
|
+#include <config.h>
|
||||||
|
+#include <gsl/gsl_ieee_utils.h>
|
||||||
|
+#include <gsl/gsl_errno.h>
|
||||||
|
+
|
||||||
|
+const char *fp_env_string = "round-to-nearest,double-precision,mask-all";
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+gsl_ieee_set_mode (int precision, int rounding, int exception_mask)
|
||||||
|
+{
|
||||||
|
+ unsigned int old, mode = _DN_SAVE, mask = _MCW_DN | _MCW_RC | _MCW_EM;
|
||||||
|
+
|
||||||
|
+ switch(precision)
|
||||||
|
+ {
|
||||||
|
+ case GSL_IEEE_SINGLE_PRECISION: mode |= _PC_24; break;
|
||||||
|
+ case GSL_IEEE_EXTENDED_PRECISION: mode |= _PC_64; break;
|
||||||
|
+ case GSL_IEEE_DOUBLE_PRECISION:
|
||||||
|
+ default: mode |= _PC_53;
|
||||||
|
+ }
|
||||||
|
+#ifndef _M_AMD64
|
||||||
|
+ mask |= _MCW_PC;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ switch(rounding)
|
||||||
|
+ {
|
||||||
|
+ case GSL_IEEE_ROUND_DOWN: mode |= _RC_DOWN; break;
|
||||||
|
+ case GSL_IEEE_ROUND_UP: mode |= _RC_UP; break;
|
||||||
|
+ case GSL_IEEE_ROUND_TO_ZERO: mode |= _RC_CHOP; break;
|
||||||
|
+ case GSL_IEEE_ROUND_TO_NEAREST:
|
||||||
|
+ default: mode |= _RC_NEAR;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(exception_mask & GSL_IEEE_MASK_INVALID)
|
||||||
|
+ mode |= _EM_INVALID;
|
||||||
|
+ if(exception_mask & GSL_IEEE_MASK_DENORMALIZED)
|
||||||
|
+ mode |= _EM_DENORMAL;
|
||||||
|
+ if(exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO)
|
||||||
|
+ mode |= _EM_ZERODIVIDE;
|
||||||
|
+ if(exception_mask & GSL_IEEE_MASK_OVERFLOW)
|
||||||
|
+ mode |= _EM_OVERFLOW;
|
||||||
|
+ if(exception_mask & GSL_IEEE_MASK_UNDERFLOW)
|
||||||
|
+ mode |= _EM_UNDERFLOW;
|
||||||
|
+ if(exception_mask & GSL_IEEE_TRAP_INEXACT)
|
||||||
|
+ mode &= ~_EM_INEXACT;
|
||||||
|
+ else
|
||||||
|
+ mode |= _EM_INEXACT;
|
||||||
|
+
|
||||||
|
+ _controlfp_s( &old, mode, mask);
|
||||||
|
+ return GSL_SUCCESS;
|
||||||
|
+}
|
||||||
|
diff --git a/ieee-utils/fp.c b/ieee-utils/fp.c
|
||||||
|
index 445a14f..b6ae5af 100644
|
||||||
|
--- a/ieee-utils/fp.c
|
||||||
|
+++ b/ieee-utils/fp.c
|
||||||
|
@@ -45,6 +45,8 @@
|
||||||
|
#endif
|
||||||
|
#elif HAVE_DECL_FEENABLEEXCEPT || HAVE_DECL_FESETTRAPENABLE
|
||||||
|
#include "fp-gnuc99.c"
|
||||||
|
+#elif _MSC_VER
|
||||||
|
+#include "fp-win.c"
|
||||||
|
#else
|
||||||
|
#include "fp-unknown.c"
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
|
71
ports/libgsl/CMakeLists.txt
Normal file
71
ports/libgsl/CMakeLists.txt
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(libgsl C)
|
||||||
|
|
||||||
|
option(INSTALL_HEADERS "Install public header files" ON)
|
||||||
|
set(WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
|
||||||
|
# Function to extract parameter from makefile. Space separated values are returned as lists
|
||||||
|
function(extract_from_makefile PATTERN RETURN FILEPATH)
|
||||||
|
file(READ ${FILEPATH} MAKEFILE_CONTENT)
|
||||||
|
string(REGEX MATCH "${PATTERN}" CONTENTS "${MAKEFILE_CONTENT}")
|
||||||
|
set(CONTENTS ${CMAKE_MATCH_1})
|
||||||
|
# Split string into list
|
||||||
|
string(REGEX REPLACE "[ \t]+" ";" CONTENTS "${CONTENTS}")
|
||||||
|
if("${CONTENTS}" STREQUAL "")
|
||||||
|
message(AUTHOR_WARNING "No match for \"${PATTERN}\" found in file ${FILEPATH}")
|
||||||
|
endif()
|
||||||
|
# Return
|
||||||
|
set(${RETURN} ${CONTENTS} PARENT_SCOPE)
|
||||||
|
endfunction(extract_from_makefile)
|
||||||
|
|
||||||
|
# Function to extract C sources from makefile
|
||||||
|
function(extract_sources SUBFOLDER ALLSOURCES)
|
||||||
|
extract_from_makefile("lib[a-zA-Z1-9_]*_la_SOURCES[ \t]*=[ \t]*([^\n]*)" SOURCEFILES "${SUBFOLDER}/Makefile.am")
|
||||||
|
# Add the folder in front of the file names
|
||||||
|
string(REGEX REPLACE "([^;]+)" "${SUBFOLDER}/\\1" SOURCEFILES "${SOURCEFILES}")
|
||||||
|
# Return
|
||||||
|
set(${ALLSOURCES} ${${ALLSOURCES}} ${SOURCEFILES} PARENT_SCOPE)
|
||||||
|
endfunction(extract_sources)
|
||||||
|
|
||||||
|
set(SOURCES)
|
||||||
|
extract_from_makefile("SUBDIRS = ([^\n]*)" FOLDERS "./Makefile.am")
|
||||||
|
extract_sources("." SOURCES)
|
||||||
|
foreach(DIR IN LISTS FOLDERS)
|
||||||
|
extract_sources("${DIR}" SOURCES)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(READ gsl_types.h GSLTYPES_H)
|
||||||
|
string(REPLACE "#ifdef WIN32" "#if 1 /*WIN32*/" GSLTYPES_H "${GSLTYPES_H}")
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
string(REPLACE "# ifdef GSL_DLL" "# if 1 /*GSL_DLL*/" GSLTYPES_H "${GSLTYPES_H}")
|
||||||
|
endif()
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gsl_types.h "${GSLTYPES_H}")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE PUBLIC_HEADERS gsl*.h)
|
||||||
|
list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/gsl_types.h)
|
||||||
|
|
||||||
|
add_library(libgsl ${SOURCES})
|
||||||
|
|
||||||
|
if(INSTALL_HEADERS)
|
||||||
|
set_target_properties(libgsl PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
|
||||||
|
endif()
|
||||||
|
target_include_directories(libgsl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
# For the build, we need to copy all headers to the gsl directory
|
||||||
|
file(COPY ${PUBLIC_HEADERS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/gsl")
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(libgsl PRIVATE -DDLL_EXPORT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set(TARGET_INSTALL_OPTIONS)
|
||||||
|
if(INSTALL_HEADERS)
|
||||||
|
set(TARGET_INSTALL_OPTIONS PUBLIC_HEADER DESTINATION include/gsl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS libgsl
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
${TARGET_INSTALL_OPTIONS}
|
||||||
|
)
|
3
ports/libgsl/CONTROL
Normal file
3
ports/libgsl/CONTROL
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Source: libgsl
|
||||||
|
Version: 2.3
|
||||||
|
Description: The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers
|
43
ports/libgsl/portfile.cmake
Normal file
43
ports/libgsl/portfile.cmake
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Common Ambient Variables:
|
||||||
|
# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT}
|
||||||
|
# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET}
|
||||||
|
# CURRENT_PORT DIR = ${VCPKG_ROOT_DIR}\ports\${PORT}
|
||||||
|
# PORT = current port name (zlib, etc)
|
||||||
|
# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc)
|
||||||
|
# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic)
|
||||||
|
# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic)
|
||||||
|
# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg>
|
||||||
|
# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm)
|
||||||
|
#
|
||||||
|
|
||||||
|
include(vcpkg_common_functions)
|
||||||
|
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/gsl-2.3)
|
||||||
|
vcpkg_download_distfile(ARCHIVE
|
||||||
|
URLS "ftp://ftp.gnu.org/gnu/gsl/gsl-2.3.tar.gz"
|
||||||
|
FILENAME "gsl-2.3.tar.gz"
|
||||||
|
SHA512 ada622079f4ac667d95f74b38aa368726fc1b18fd34555bcefe90920d3da93a9289ebff966be43325af806107001bc8973daf9f8418e6c97b866be2296b566ff
|
||||||
|
)
|
||||||
|
vcpkg_extract_source_archive(${ARCHIVE})
|
||||||
|
|
||||||
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||||
|
|
||||||
|
vcpkg_apply_patches(
|
||||||
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
|
PATCHES
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/0001-configure.patch
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/0002-add-fp-control.patch
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_configure_cmake(
|
||||||
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
|
PREFER_NINJA
|
||||||
|
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_install_cmake()
|
||||||
|
|
||||||
|
# Handle copyright
|
||||||
|
file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libgsl)
|
||||||
|
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libgsl/COPYING ${CURRENT_PACKAGES_DIR}/share/libgsl/copyright)
|
||||||
|
|
||||||
|
vcpkg_copy_pdbs()
|
Loading…
Reference in New Issue
Block a user