diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt index 1ecdd6500b5d4..e5cddf82110ed 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt @@ -8,6 +8,7 @@ builtin_jpeg=ON builtin_lz4=ON builtin_lzma=ON builtin_png=ON +builtin_unuran=ON builtin_vdt=ON builtin_zlib=ON builtin_zstd=ON diff --git a/builtins/unuran/0001-allow-compilation-from-CMake.patch b/builtins/unuran/0001-allow-compilation-from-CMake.patch new file mode 100644 index 0000000000000..813f9614dc575 --- /dev/null +++ b/builtins/unuran/0001-allow-compilation-from-CMake.patch @@ -0,0 +1,638 @@ +From e6103ed6aea96e50dcd47554b12a8f59f24fc480 Mon Sep 17 00:00:00 2001 +From: ferdymercury +Date: Thu, 16 Apr 2026 15:59:55 +0200 +Subject: [PATCH] allow compilation from CMake + +--- + src/CMakeLists.txt | 421 ++++++ + src/distr/discr.c | 1 + + src/distributions/d_geometric.c | 1 + + src/distributions/d_logarithmic.c | 1 + + src/distributions/d_negativebinomial.c | 1 + + src/distributions/d_poisson.c | 1 + + src/distributions/d_zipf.c | 1 + + src/methods/dari.c | 1 + + src/methods/dau.c | 1 + + src/methods/dgt.c | 1 + + src/methods/dss.c | 1 + + src/methods/dstd.c | 1 + + src/parser/stringparser.c | 2 + + src/unur_source.h | 4 +- + src/urng/urng.c | 1 + + src/urng/urng_unuran.c | 1 + + 15 files changed, 436 insertions(+), 2 deletions(-) + create mode 100644 src/CMakeLists.txt + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +new file mode 100644 +index 00000000..69d8599f +--- /dev/null ++++ b/src/CMakeLists.txt +@@ -0,0 +1,421 @@ ++cmake_minimum_required(VERSION 3.22) ++project(UNURAN VERSION 1.0) # The version does not matter here ++ ++add_library(unuran STATIC) ++ ++target_sources(unuran ++PRIVATE ++ distr/cemp.c ++ distr/condi.c ++ distr/cont.c ++ distr/corder.c ++ distr/cvec.c ++ distr/cvemp.c ++ distr/cxtrans.c ++ distr/deprecated_distr.c ++ distr/discr.c ++ distr/distr_info.c ++ distr/distr.c ++ distr/matr.c ++ distributions/c_beta_gen.c ++ distributions/c_beta.c ++ distributions/c_burr.c ++ distributions/c_cauchy.c ++ distributions/c_chi_gen.c ++ distributions/c_chi.c ++ distributions/c_chisquare.c ++ distributions/c_exponential_gen.c ++ distributions/c_exponential.c ++ distributions/c_extremeI.c ++ distributions/c_extremeII.c ++ distributions/c_F.c ++ distributions/c_gamma_gen.c ++ distributions/c_gamma.c ++ distributions/c_ghyp.c ++ distributions/c_gig_gen.c ++ distributions/c_gig.c ++ distributions/c_gig2.c ++ distributions/c_hyperbolic.c ++ distributions/c_ig.c ++ distributions/c_laplace.c ++ distributions/c_logistic.c ++ distributions/c_lognormal.c ++ distributions/c_lomax.c ++ distributions/c_meixner.c ++ distributions/c_normal_gen.c ++ distributions/c_normal.c ++ distributions/c_pareto.c ++ distributions/c_powerexponential_gen.c ++ distributions/c_powerexponential.c ++ distributions/c_rayleigh.c ++ distributions/c_slash_gen.c ++ distributions/c_slash.c ++ distributions/c_student_gen.c ++ distributions/c_student.c ++ distributions/c_triangular.c ++ distributions/c_uniform.c ++ distributions/c_vg.c ++ distributions/c_weibull.c ++ distributions/d_binomial_gen.c ++ distributions/d_binomial.c ++ distributions/d_geometric.c ++ distributions/d_hypergeometric_gen.c ++ distributions/d_hypergeometric.c ++ distributions/d_logarithmic_gen.c ++ distributions/d_logarithmic.c ++ distributions/d_negativebinomial.c ++ distributions/d_poisson_gen.c ++ distributions/d_poisson.c ++ distributions/d_zipf_gen.c ++ distributions/d_zipf.c ++ distributions/m_correlation.c ++ distributions/vc_copula.c ++ distributions/vc_multicauchy.c ++ distributions/vc_multiexponential.c ++ distributions/vc_multinormal_gen.c ++ distributions/vc_multinormal.c ++ distributions/vc_multistudent.c ++ methods/arou.c ++ methods/ars.c ++ methods/auto.c ++ methods/cext.c ++ methods/cstd.c ++ methods/dari.c ++ methods/dau.c ++ methods/deprecated_methods.c ++ methods/deprecated_vmt.c ++ methods/dext.c ++ methods/dgt.c ++ methods/dsrou.c ++ methods/dss.c ++ methods/dstd.c ++ methods/empk.c ++ methods/empl.c ++ methods/gibbs.c ++ methods/hinv.c ++ methods/hist.c ++ methods/hitro.c ++ methods/hrb.c ++ methods/hrd.c ++ methods/hri.c ++ methods/itdr.c ++ methods/mcorr.c ++ methods/mixt.c ++ methods/mvstd.c ++ methods/mvtdr.c ++ methods/ninv.c ++ methods/norta.c ++ methods/nrou.c ++ methods/pinv.c ++ methods/srou.c ++ methods/ssr.c ++ methods/tabl.c ++ methods/tdr.c ++ methods/unif.c ++ methods/utdr.c ++ methods/vempk.c ++ methods/vnrou.c ++ methods/x_gen.c ++ parser/functparser.c ++ parser/parser.c ++ parser/stringparser.c ++ specfunct/bessel_asympt.c ++ specfunct/cephes_gamma.c ++ specfunct/cephes_igam.c ++ specfunct/cephes_incbet.c ++ specfunct/cephes_ndtr.c ++ specfunct/cephes_ndtri.c ++ specfunct/cephes_polevl.c ++ specfunct/cgamma.c ++ specfunct/hypot.c ++ specfunct/log1p.c ++ tests/chi2test.c ++ tests/correlation.c ++ tests/countpdf.c ++ tests/counturn.c ++ tests/inverror.c ++ tests/moments.c ++ tests/printsample.c ++ tests/quantiles.c ++ tests/tests.c ++ tests/timing.c ++ uniform/fish.c ++ uniform/mrg31k3p.c ++ uniform/mstd.c ++ uniform/urng_builtin.c ++ uniform/urng_fvoid.c ++ uniform/urng_gsl.c ++ uniform/urng_gslqrng.c ++ uniform/urng_prng.c ++ uniform/urng_randomshift.c ++ uniform/urng_rngstreams.c ++ urng/urng_default.c ++ urng/urng_set.c ++ urng/urng_unuran.c ++ urng/urng.c ++ utils/debug.c ++ utils/eigensystem.c ++ utils/error.c ++ utils/fmax.c ++ utils/hooke.c ++ utils/lobatto.c ++ utils/matrix.c ++ utils/mrou_rectangle.c ++ utils/slist.c ++ utils/stream.c ++ utils/string.c ++ utils/umalloc.c ++ utils/umath.c ++ utils/unur_fp.c ++ utils/vector.c ++PUBLIC ++ FILE_SET HEADERS ++ BASE_DIRS ./ # distr distributions methods parser specfunct tests uniform urng utils ++ FILES ++ distr/cemp.h ++ distr/condi.h ++ distr/cont.h ++ distr/corder.h ++ distr/cvec.h ++ distr/cvemp.h ++ distr/cxtrans.h ++ distr/deprecated_distr.h ++ distr/discr.h ++ distr/distr_source.h ++ distr/distr_struct.h ++ distr/distr.h ++ distr/matr.h ++ distributions/unur_distributions_source.h ++ distributions/unur_distributions.h ++ distributions/unur_stddistr.h ++ methods/arou_struct.h ++ methods/arou.h ++ methods/ars_struct.h ++ methods/ars.h ++ methods/auto_struct.h ++ methods/auto.h ++ methods/cext_struct.h ++ methods/cext.h ++ methods/cstd_struct.h ++ methods/cstd.h ++ methods/dari_struct.h ++ methods/dari.h ++ methods/dau_struct.h ++ methods/dau.h ++ methods/deprecated_methods.h ++ methods/deprecated_tdrgw.h ++ methods/deprecated_vmt_struct.h ++ methods/deprecated_vmt.h ++ methods/dext_struct.h ++ methods/dext.h ++ methods/dgt_struct.h ++ methods/dgt.h ++ methods/dsrou_struct.h ++ methods/dsrou.h ++ methods/dss_struct.h ++ methods/dss.h ++ methods/dstd_struct.h ++ methods/dstd.h ++ methods/empk_struct.h ++ methods/empk.h ++ methods/empl_struct.h ++ methods/empl.h ++ methods/gibbs_struct.h ++ methods/gibbs.h ++ methods/hinv_struct.h ++ methods/hinv.h ++ methods/hist_struct.h ++ methods/hist.h ++ methods/hitro_struct.h ++ methods/hitro.h ++ methods/hrb_struct.h ++ methods/hrb.h ++ methods/hrd_struct.h ++ methods/hrd.h ++ methods/hri_struct.h ++ methods/hri.h ++ methods/itdr_struct.h ++ methods/itdr.h ++ methods/mcorr_struct.h ++ methods/mcorr.h ++ methods/mixt_struct.h ++ methods/mixt.h ++ methods/mvstd_struct.h ++ methods/mvstd.h ++ methods/mvtdr_struct.h ++ methods/mvtdr.h ++ methods/ninv_struct.h ++ methods/ninv.h ++ methods/norta_struct.h ++ methods/norta.h ++ methods/nrou_struct.h ++ methods/nrou.h ++ methods/pinv_struct.h ++ methods/pinv.h ++ methods/srou_struct.h ++ methods/srou.h ++ methods/ssr_struct.h ++ methods/ssr.h ++ methods/tabl_struct.h ++ methods/tabl.h ++ methods/tdr_struct.h ++ methods/tdr.h ++ methods/unif_struct.h ++ methods/unif.h ++ methods/unur_methods_source.h ++ methods/unur_methods.h ++ methods/utdr_struct.h ++ methods/utdr.h ++ methods/vempk_struct.h ++ methods/vempk.h ++ methods/vnrou_struct.h ++ methods/vnrou.h ++ methods/x_gen_source.h ++ methods/x_gen_struct.h ++ methods/x_gen.h ++ parser/functparser_source.h ++ parser/functparser_struct.h ++ parser/functparser_symbols.h ++ parser/parser_source.h ++ parser/parser.h ++ specfunct/cephes_source.h ++ specfunct/unur_specfunct_source.h ++ tests/unuran_tests.h ++ # uniform/unuran_urng_gsl.h # To enable this if GSL_LIBRARIES defined, add target_link_libraries(unuran PRIVATE ${GSL_LIBRARIES}) and add target_compile_definitions(unuran PUBLIC UNURAN_HAS_GSL) ++ # uniform/unuran_urng_prng.h ++ # uniform/unuran_urng_rngstreams.h ++ uniform/urng_builtin.h ++ uniform/urng_fvoid.h ++ uniform/urng_gsl.h ++ uniform/urng_gslqrng.h ++ uniform/urng_prng.h ++ uniform/urng_randomshift.h ++ uniform/urng_rngstreams.h ++ unur_cookies.h ++ unur_source.h ++ unur_struct.h ++ unur_typedefs.h ++ unuran_config.h ++ unuran.h ++ urng/urng_source.h ++ urng/urng_struct.h ++ urng/urng.h ++ utils/debug_source.h ++ utils/debug.h ++ utils/error_source.h ++ utils/error.h ++ utils/fmax_source.h ++ utils/hooke_source.h ++ utils/lobatto_source.h ++ utils/lobatto_struct.h ++ utils/matrix_source.h ++ utils/mrou_rectangle_source.h ++ utils/mrou_rectangle_struct.h ++ utils/slist_struct.h ++ utils/slist.h ++ utils/stream_source.h ++ utils/stream.h ++ utils/string_source.h ++ utils/string_struct.h ++ utils/umalloc_source.h ++ utils/umath_source.h ++ utils/umath.h ++ utils/unur_errno.h ++ utils/unur_fp_const_source.h ++ utils/unur_fp_source.h ++ utils/unur_math_source.h ++ utils/vector_source.h ++) ++ ++target_compile_definitions(unuran PRIVATE ++ HAVE_DECL_HUGE_VAL=1 ++ HAVE_DECL_SIGNAL=1 ++ HAVE_DECL_SNPRINTF=1 ++ HAVE_DECL_VSNPRINTF=1 ++ HAVE_FLOAT_H=1 ++ HAVE_FLOOR=1 ++ HAVE_IEEE_COMPARISONS=1 ++ HAVE_LIBM=1 ++ HAVE_LIMITS_H=1 ++ HAVE_POW=1 ++ HAVE_SIGNAL=1 ++ HAVE_SQRT=1 ++ HAVE_STDLIB_H=1 ++ HAVE_STRCHR=1 ++ HAVE_STRING_H=1 ++ HAVE_STRTOL=1 ++ HAVE_STRTOUL=1 ++ HAVE_SYS_STAT_H=1 ++ HAVE_SYS_TYPES_H=1 ++ #LT_OBJDIR=".libs/" ++ PACKAGE="unuran" ++ PACKAGE_BUGREPORT="unuran@statmath.wu.ac.at" ++ PACKAGE_NAME="unuran" ++ PACKAGE_STRING="unuran ${PROJECT_VERSION}" ++ PACKAGE_TARNAME="unuran" ++ PACKAGE_URL="" ++ PACKAGE_VERSION="${PROJECT_VERSION}" ++ STDC_HEADERS=1 ++ UNUR_ENABLE_INFO=1 ++ VERSION=${PROJECT_VERSION} ++) ++if(WIN32) ++target_compile_definitions(unuran PRIVATE ++ HAVE_MEMORY_H=1 ++ inline=__inline ++ #log1p=_unur_log1p ++) ++else() ++target_compile_definitions(unuran PRIVATE ++ HAVE_ALARM=1 ++ HAVE_DECL_ALARM=1 ++ HAVE_DECL_DBL_MAX=1 ++ HAVE_DECL_GETOPT=1 ++ HAVE_DECL_HYPOT=1 ++ HAVE_DECL_INFINITY=1 ++ HAVE_DECL_ISFINITE=1 ++ HAVE_DECL_ISINF=1 ++ HAVE_DECL_ISNAN=1 ++ HAVE_DECL_LOG1P=1 ++ HAVE_DIVIDE_BY_ZERO=1 ++ HAVE_DLFCN_H=1 ++ HAVE_GETTIMEOFDAY=1 ++ HAVE_INTTYPES_H=1 ++ HAVE_LIBGSL=1 ++ HAVE_LIBGSLCBLAS=1 ++ HAVE_MEMSET=1 ++ HAVE_STDINT_H=1 ++ HAVE_STDIO_H=1 ++ HAVE_STRCASECMP=1 ++ HAVE_STRINGS_H=1 ++ HAVE_SYS_TIME_H=1 ++ HAVE_UNISTD_H=1 ++) ++endif() ++ ++#---Define special compiler settings for unuran----------------------------------------------------- ++if(ROOT_ARCHITECTURE MATCHES hpuxia64acc) ++ set(UNR_CFLAGS "+DD64 -Ae") ++elseif(ROOT_ARCHITECTURE MATCHES linuxppc64gcc) ++ set(UNR_CFLAGS "-m64 -fPIC") ++elseif(ROOT_ARCHITECTURE MATCHES linuxx8664gcc) ++ set(UNR_CFLAGS "-m64 -fPIC") ++elseif(ROOT_ARCHITECTURE MATCHES linuxicc) ++ set(UNR_CFLAGS "-m32") ++elseif(ROOT_ARCHITECTURE MATCHES linuxx8664icc) ++ set(UNR_CFLAGS "-m64") ++elseif(ROOT_ARCHITECTURE MATCHES win32 OR ROOT_ARCHITECTURE MATCHES win64) ++ set(UNR_CFLAGS "-MD -G5 -GX") ++endif() ++if(CMAKE_OSX_SYSROOT) ++ set(UNR_CFLAGS "${UNR_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") ++endif() ++set(CMAKE_C_FLAGS ${UNR_CFLAGS}) ++ ++target_include_directories(unuran PUBLIC ./) ++ ++# Install the target and its file sets ++install(TARGETS unuran ++ FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_PREFIX}/include ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ++) +diff --git a/src/distr/discr.c b/src/distr/discr.c +index 938c17bc..ab3eb885 100644 +--- a/src/distr/discr.c ++++ b/src/distr/discr.c +@@ -42,6 +42,7 @@ + #include "distr_source.h" + #include "distr.h" + #include "discr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/distributions/d_geometric.c b/src/distributions/d_geometric.c +index 5ec863c3..04ea1f33 100644 +--- a/src/distributions/d_geometric.c ++++ b/src/distributions/d_geometric.c +@@ -54,6 +54,7 @@ + #include "unur_distributions.h" + #include "unur_distributions_source.h" + #include "unur_stddistr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/distributions/d_logarithmic.c b/src/distributions/d_logarithmic.c +index 147dfecf..284ec22c 100644 +--- a/src/distributions/d_logarithmic.c ++++ b/src/distributions/d_logarithmic.c +@@ -54,6 +54,7 @@ + #include "unur_distributions.h" + #include "unur_distributions_source.h" + #include "unur_stddistr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/distributions/d_negativebinomial.c b/src/distributions/d_negativebinomial.c +index c1b5a79a..eb8e8899 100644 +--- a/src/distributions/d_negativebinomial.c ++++ b/src/distributions/d_negativebinomial.c +@@ -55,6 +55,7 @@ + #include "unur_distributions.h" + #include "unur_distributions_source.h" + #include "unur_stddistr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/distributions/d_poisson.c b/src/distributions/d_poisson.c +index 5fe88215..f248bc82 100644 +--- a/src/distributions/d_poisson.c ++++ b/src/distributions/d_poisson.c +@@ -54,6 +54,7 @@ + #include "unur_distributions.h" + #include "unur_distributions_source.h" + #include "unur_stddistr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/distributions/d_zipf.c b/src/distributions/d_zipf.c +index 5dc08f3f..4e793256 100644 +--- a/src/distributions/d_zipf.c ++++ b/src/distributions/d_zipf.c +@@ -56,6 +56,7 @@ + #include "unur_distributions.h" + #include "unur_distributions_source.h" + #include "unur_stddistr.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + +diff --git a/src/methods/dari.c b/src/methods/dari.c +index e8cf2e9a..e0f3ca1b 100644 +--- a/src/methods/dari.c ++++ b/src/methods/dari.c +@@ -62,6 +62,7 @@ + #include "x_gen_source.h" + #include "dari.h" + #include "dari_struct.h" ++#include "limits.h" + + #ifdef UNUR_ENABLE_INFO + # include +diff --git a/src/methods/dau.c b/src/methods/dau.c +index b95a3110..fc85527c 100644 +--- a/src/methods/dau.c ++++ b/src/methods/dau.c +@@ -114,6 +114,7 @@ + #include "x_gen_source.h" + #include "dau.h" + #include "dau_struct.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + /* Variants: none */ +diff --git a/src/methods/dgt.c b/src/methods/dgt.c +index 89e9e7c9..62626d86 100644 +--- a/src/methods/dgt.c ++++ b/src/methods/dgt.c +@@ -92,6 +92,7 @@ + #include "x_gen_source.h" + #include "dgt.h" + #include "dgt_struct.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + /* Variants */ +diff --git a/src/methods/dss.c b/src/methods/dss.c +index 02d1feaa..36578c3a 100644 +--- a/src/methods/dss.c ++++ b/src/methods/dss.c +@@ -62,6 +62,7 @@ + #include "x_gen_source.h" + #include "dss.h" + #include "dss_struct.h" ++#include "limits.h" + + /*---------------------------------------------------------------------------*/ + /* Variants */ +diff --git a/src/methods/dstd.c b/src/methods/dstd.c +index c41307ff..5786d05e 100644 +--- a/src/methods/dstd.c ++++ b/src/methods/dstd.c +@@ -85,6 +85,7 @@ + #include "cstd.h" /* required for UNUR_STDGEN_* macros */ + #include "dstd.h" + #include "dstd_struct.h" ++#include "limits.h" + + #ifdef UNUR_ENABLE_INFO + # include +diff --git a/src/parser/stringparser.c b/src/parser/stringparser.c +index 682213a9..caed8b16 100644 +--- a/src/parser/stringparser.c ++++ b/src/parser/stringparser.c +@@ -182,6 +182,8 @@ + #include + #include + ++#include "limits.h" ++ + #if defined(UNUR_URNG_UNURAN) && defined(UNURAN_HAS_PRNG) + #include + #endif +diff --git a/src/unur_source.h b/src/unur_source.h +index 6d9a04f6..3af5bd19 100644 +--- a/src/unur_source.h ++++ b/src/unur_source.h +@@ -40,9 +40,9 @@ + /* config file generated be autoconf */ + + #ifdef HAVE_CONFIG_H +-# include ++// # include + #else +-# error "config.h" required ++// # error "config.h" required + #endif + + /*---------------------------------------------------------------------------*/ +diff --git a/src/urng/urng.c b/src/urng/urng.c +index 8f81ea3b..d843b469 100644 +--- a/src/urng/urng.c ++++ b/src/urng/urng.c +@@ -33,6 +33,7 @@ + /*---------------------------------------------------------------------------*/ + #include + #include "urng.h" ++#include "limits.h" + /*---------------------------------------------------------------------------*/ + + /*****************************************************************************/ +diff --git a/src/urng/urng_unuran.c b/src/urng/urng_unuran.c +index e1f04b04..1c29d3f5 100644 +--- a/src/urng/urng_unuran.c ++++ b/src/urng/urng_unuran.c +@@ -33,6 +33,7 @@ + /*---------------------------------------------------------------------------*/ + #include + #include "urng.h" ++#include "limits.h" + /*---------------------------------------------------------------------------*/ + #ifdef UNUR_URNG_UNURAN + /*---------------------------------------------------------------------------*/ +2.34.1 diff --git a/builtins/unuran/CMakeLists.txt b/builtins/unuran/CMakeLists.txt new file mode 100644 index 0000000000000..3d6c25a90a444 --- /dev/null +++ b/builtins/unuran/CMakeLists.txt @@ -0,0 +1,98 @@ +# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +# **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION** +# 20 Apr 2023, https://github.com/unuran/unuran/releases/tag/unuran-1.11.0 but using preprocessed configure and make ROOTdist option within this repo and then uploading to LCG +set(ROOT_UNURAN_VERSION 1.11.0) +set(ROOT_UNURAN_URL "${lcgpackages}/unuran-${ROOT_UNURAN_VERSION}.tar.gz") +set(ROOT_UNURAN_HASH "098793854c590b4c2c7e98bc48a45408875f48c5ad47650b5fabbd3e94dd8049") +set(ROOT_UNURAN_PREFIX ${CMAKE_BINARY_DIR}/builtins/UNURAN-prefix) +set(ROOT_UNURAN_LIBRARY ${ROOT_UNURAN_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}unuran${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(ROOT_UNURAN_PATCH_FILE_1 "${CMAKE_CURRENT_SOURCE_DIR}/0001-allow-compilation-from-CMake.patch") +if (NOT DEFINED GIT_EXECUTABLE) + set(GIT_EXECUTABLE "git") +endif() + + +include(ExternalProject) + +# Clear cache variables set by find_package(UNURAN) +# to ensure that we use the builtin version +foreach(var UNURAN_LIBRARIES UNURAN_LIBRARY UNURAN_LIBRARY_DEBUG UNURAN_LIBRARY_RELEASE UNURAN_FOUND UNURAN_VERSION UNURAN_INCLUDE_DIR UNURAN_LIBRARY UNURAN_LIBRARIES) + unset(${var}) + unset(${var} CACHE) +endforeach() + +if(WIN32 AND NOT CMAKE_GENERATOR MATCHES Ninja) + if(winrtdebug) + set(ROOT_UNURAN_BUILD_COMMAND_FLAGS "--config Debug") + else() + set(ROOT_UNURAN_BUILD_COMMAND_FLAGS "--config $,RelWithDebInfo,Release>") + endif() +endif() + +ExternalProject_Add( + BUILTIN_UNURAN + PREFIX ${ROOT_UNURAN_PREFIX} + URL ${ROOT_UNURAN_URL} + URL_HASH SHA256=${ROOT_UNURAN_HASH} + PATCH_COMMAND ${GIT_EXECUTABLE} apply --ignore-space-change --ignore-whitespace ${ROOT_UNURAN_PATCH_FILE_1} + SOURCE_SUBDIR src + LOG_DOWNLOAD TRUE +# The following three are disabled to avoid CI failure in Ubuntu22 that has outdated CMake version +# See https://github.com/root-project/root/issues/16733 +# LOG_CONFIGURE TRUE +# LOG_BUILD TRUE +# LOG_INSTALL TRUE + LOG_OUTPUT_ON_FAILURE TRUE + CMAKE_ARGS -G ${CMAKE_GENERATOR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_INSTALL_LIBDIR=/lib + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_C_VISIBILITY_PRESET=hidden + # -DGSL_LIBRARIES=${GSL_LIBRARIES} + -DROOT_ARCHITECTURE=${ROOT_ARCHITECTURE} + -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} + BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_UNURAN_BUILD_COMMAND_FLAGS} + INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_UNURAN_BUILD_COMMAND_FLAGS} --target install + BUILD_BYPRODUCTS + ${ROOT_UNURAN_LIBRARY} + TIMEOUT 600 +) + +set(ROOT_UNURAN_INCLUDE_DIR ${ROOT_UNURAN_PREFIX}/include) +file(MAKE_DIRECTORY ${ROOT_UNURAN_INCLUDE_DIR}) +add_library(Unuran::unuran IMPORTED STATIC GLOBAL) +add_dependencies(Unuran::unuran BUILTIN_UNURAN) +set_target_properties(Unuran::unuran PROPERTIES + IMPORTED_LOCATION ${ROOT_UNURAN_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_UNURAN_INCLUDE_DIR}) +# target_compile_options(Unuran::unuran INTERFACE +# Set the canonical output of find_package according to +# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names +set(Unuran_INCLUDE_DIRS ${ROOT_UNURAN_INCLUDE_DIR} PARENT_SCOPE) +set(Unuran_LIBRARIES ${ROOT_UNURAN_LIBRARY} PARENT_SCOPE) +set(Unuran_FOUND TRUE PARENT_SCOPE) +set(Unuran_VERSION ${ROOT_UNURAN_VERSION} PARENT_SCOPE) + +# For compatibility with non-standard case FindUnuran.cmake +set(UNURAN_INCLUDE_DIRS ${ROOT_UNURAN_INCLUDE_DIR} PARENT_SCOPE) +set(UNURAN_LIBRARIES ${ROOT_UNURAN_LIBRARY} PARENT_SCOPE) +set(UNURAN_FOUND TRUE PARENT_SCOPE) +set(UNURAN_VERSION ${ROOT_UNURAN_VERSION} PARENT_SCOPE) + +##---We need to disable some warnings------------------------------------------------------------------- +#string(REPLACE -Wall "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +#if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) +# ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-parentheses-equality) +# ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-deprecated-non-prototype) +#endif() +#if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU) +# ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-maybe-uninitialized) +# ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-alloc-size-larger-than) +# +#endif() diff --git a/cmake/modules/FindUnuran.cmake b/cmake/modules/FindUnuran.cmake index 1011616c61807..fddb4526b94a4 100644 --- a/cmake/modules/FindUnuran.cmake +++ b/cmake/modules/FindUnuran.cmake @@ -27,3 +27,10 @@ INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Unuran DEFAULT_MSG UNURAN_LIBRARY UNURAN_INCLUDE_DIR) mark_as_advanced(UNURAN_FOUND UNURAN_INCLUDE_DIR UNURAN_LIBRARY) + +if(UNURAN_FOUND AND NOT TARGET Unuran::unuran) + add_library(Unuran::unuran UNKNOWN IMPORTED) + set_target_properties(Unuran::unuran PROPERTIES + IMPORTED_LOCATION "${UNURAN_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${UNURAN_INCLUDE_DIR}") +endif() diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index ec812855ad905..865546635e2e5 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -243,6 +243,10 @@ if(unuran AND NOT builtin_unuran) endif() endif() endif() +if (builtin_unuran) + list(APPEND ROOT_BUILTINS BUILTIN_UNURAN) + add_subdirectory(builtins/unuran) +endif() #---Check for Freetype--------------------------------------------------------------- ROOT_FIND_REQUIRED_DEP(Freetype builtin_freetype) # needed for asimage, but also outside of it (for "graf" target) diff --git a/math/unuran/CMakeLists.txt b/math/unuran/CMakeLists.txt index 1fd1c742a71b3..2fe2ff0877ceb 100644 --- a/math/unuran/CMakeLists.txt +++ b/math/unuran/CMakeLists.txt @@ -5,85 +5,9 @@ # For the list of contributors see $ROOTSYS/README/CREDITS. ############################################################################ -# CMakeLists.txt file for building ROOT math/unurun package +# CMakeLists.txt file for building ROOT math/unuran package ############################################################################ -#---Define package related variables----------------------------------------------------------------- - -if(builtin_unuran) - -set(UNR_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/src) -set(UNR_VERSION "1.11.0") -set(UNR_TARNAME "unuran-${UNR_VERSION}") -set(UNR_TARGZFILE ${UNR_SRCDIR}/${UNR_TARNAME}.tar.gz) -set(UNR_TARFILE ${UNR_SRCDIR}/${UNR_TARNAME}.tar) -set(UNR_UNTARDIR ${CMAKE_CURRENT_BINARY_DIR}/${UNR_TARNAME}) - -#---Untar sources at configuration/generation time (needed for listing sources) -if(NOT EXISTS ${UNR_UNTARDIR}) - execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf ${UNR_TARGZFILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) -endif() - -if(WIN32) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.win.in ${UNR_UNTARDIR}/config.h) -else() - #---Define special compiler settings for unurun----------------------------------------------------- - set(UNR_CC ${CMAKE_C_COMPILER}) - if(ROOT_ARCHITECTURE MATCHES hpuxia64acc) - set(UNR_CC "${UNR_CC} +DD64 -Ae") - elseif(ROOT_ARCHITECTURE MATCHES linuxppc64gcc) - set(UNR_CC "${UNR_CC} -m64 -fPIC") - elseif(ROOT_ARCHITECTURE MATCHES linuxx8664gcc) - set(UNR_CFLAGS "-m64 -fPIC") - elseif(ROOT_ARCHITECTURE MATCHES linuxicc) - set(UNR_CFLAGS "-m32") - elseif(ROOT_ARCHITECTURE MATCHES linuxx8664icc) - set(UNR_CFLAGS "-m64") - elseif(ROOT_ARCHITECTURE MATCHES win32 OR ROOT_ARCHITECTURE MATCHES win64) - set(UNR_CFLAGS "-MD -G5 -GX") - endif() - if(CMAKE_OSX_SYSROOT) - set(UNR_CFLAGS "${UNR_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") - endif() - - #---configure unuran (required for creating the config.h used by unuran source files)---------------- - add_custom_command(OUTPUT ${UNR_UNTARDIR}/config.h - COMMAND GNUMAKE=make ./configure CC=${UNR_CC} CFLAGS=${UNR_CFLAGS} > /dev/null 2>& 1 - WORKING_DIRECTORY ${UNR_UNTARDIR}) -endif() - -#---We need to disable some warnings------------------------------------------------------------------- -string(REPLACE -Wall "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) - ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-parentheses-equality) - ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-deprecated-non-prototype) -endif() -if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU) - ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-maybe-uninitialized) - ROOT_ADD_C_FLAG(CMAKE_C_FLAGS -Wno-alloc-size-larger-than) - -endif() - -set(unrsources ${UNR_UNTARDIR}/src/utils/*.c - ${UNR_UNTARDIR}/src/methods/*.c - ${UNR_UNTARDIR}/src/specfunct/*.c - ${UNR_UNTARDIR}/src/distr/*.c - ${UNR_UNTARDIR}/src/distributions/*.c - ${UNR_UNTARDIR}/src/parser/*.c - ${UNR_UNTARDIR}/src/tests/*.c - ${UNR_UNTARDIR}/src/uniform/*.c - ${UNR_UNTARDIR}/src/urng/*.c ) -set(unrconfig ${UNR_UNTARDIR}/config.h) - -else() - -set(unrsources) -set(unrconfig) - -endif(builtin_unuran) - - ROOT_STANDARD_LIBRARY_PACKAGE(Unuran HEADERS TUnuran.h @@ -100,21 +24,12 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Unuran src/TUnuranEmpDist.cxx src/TUnuranMultiContDist.cxx src/TUnuranSampler.cxx - ${unrconfig} - ${unrsources} LIBRARIES - ${UNURAN_LIBRARIES} + Unuran::unuran DEPENDENCIES Core Hist MathCore ) -if(builtin_unuran) - target_include_directories(Unuran SYSTEM BEFORE PRIVATE ${UNR_UNTARDIR} ${UNR_UNTARDIR}/src ${UNR_UNTARDIR}/src/utils) - target_compile_definitions(Unuran PRIVATE HAVE_CONFIG_H) -else() - target_include_directories(Unuran SYSTEM PRIVATE ${UNURAN_INCLUDE_DIRS}) -endif() - ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/math/unuran/config.h.win.in b/math/unuran/config.h.win.in deleted file mode 100644 index 6db927ee07db4..0000000000000 --- a/math/unuran/config.h.win.in +++ /dev/null @@ -1,230 +0,0 @@ -/* config.h.win transformed into input to CMake configure_file() command */ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the `alarm' function. */ -/* #undef HAVE_ALARM */ - -/* Define to 1 if you have the declaration of `alarm', and to 0 if you don't. - */ -#define HAVE_DECL_ALARM 0 - -/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. - */ -#define HAVE_DECL_GETOPT 0 - -/* Define to 1 if you have the declaration of `HUGE_VAL', and to 0 if you - don't. */ -#define HAVE_DECL_HUGE_VAL 1 - -/* Define to 1 if you have the declaration of `INFINITY', and to 0 if you - don't. */ -#define HAVE_DECL_INFINITY 0 - -/* Define to 1 if you have the declaration of `isfinite', and to 0 if you - don't. */ -#define HAVE_DECL_ISFINITE 0 - -/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. - */ -#define HAVE_DECL_ISINF 0 - -/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. - */ -#define HAVE_DECL_ISNAN 0 - -/* Define to 1 if you have the declaration of `log1p', and to 0 if you don't. - */ -#define HAVE_DECL_LOG1P 0 - -/* Define to 1 if you have the declaration of `signal', and to 0 if you don't. - */ -#define HAVE_DECL_SIGNAL 1 - -/* Define to 1 if you have the declaration of `snprintf', and to 0 if you - don't. */ -#define HAVE_DECL_SNPRINTF 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FLOAT_H 1 - -/* Define to 1 if you have the `floor' function. */ -#define HAVE_FLOOR 1 - -/* Define to 1 if you have the `gettimeofday' function. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_GSL_GSL_RNG_H */ - -/* Define to 1 if "x != x" is true for NaNs */ -#define HAVE_IEEE_COMPARISONS 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_INTTYPES_H */ - -/* Define to 1 if you have the `gsl' library (-lgsl). */ -/* #undef HAVE_LIBGSL */ - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the `prng' library (-lprng). */ -/* #undef HAVE_LIBPRNG */ - -/* Define to 1 if you have the `Rmath' library (-lRmath). */ -/* #undef HAVE_LIBRMATH */ - -/* Define to 1 if you have the `rngstreams' library (-lrngstreams). */ -/* #undef HAVE_LIBRNGSTREAMS */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `pow' function. */ -#define HAVE_POW 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_PRNG_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_RNGSTREAM_H */ - -/* Define to 1 if you have the `signal' function. */ -#define HAVE_SIGNAL 1 - -/* Define to 1 if you have the `sqrt' function. */ -#define HAVE_SQRT 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDINT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -/* #undef HAVE_STRCASECMP */ - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TIME_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "unuran" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "unuran@statmath.wu.ac.at" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "unuran" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "unuran @UNR_VERSION@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@UNR_TARNAME@" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@UNR_VERSION@" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define to 1 if you use random number generators from GNU Scientific - Library. */ -/* #undef UNURAN_HAS_GSL */ - -/* Define to 1 if you use Otmar Lendl's PRNG library. */ -/* #undef UNURAN_HAS_PRNG */ - -/* Define to 1 if you use Pierre L'Ecuyer's RNGSTREAM library. */ -/* #undef UNURAN_HAS_RNGSTREAM */ - -/* Define to 1 if you want to use magic cookies to validate type of a pointer - */ -/* #undef UNUR_COOKIES */ - -/* Define to 1 if you want to perform additional checks against an invalid - NULL pointer */ -/* #undef UNUR_ENABLE_CHECKNULL */ - -/* Define to 1 if you want to use the info routine for printing information - about UNU.RAN objects */ -#define UNUR_ENABLE_INFO 1 - -/* Define to 1 if you want to use a logfile for logging information about - UNU.RAN objects */ -/* #undef UNUR_ENABLE_LOGGING */ - -/* Define to 1 if you use RNGSTREAM as global URNG. */ -/* #undef UNUR_URNG_DEFAULT_RNGSTREAM */ - -/* Define to 1 if you want to use deprecated code. */ -/* #undef USE_DEPRECATED_CODE */ - -/* Define to 1 if you want to use experimental code */ -/* #undef USE_EXPERIMENTAL_CODE */ - -/* Version number of package */ -#define VERSION "@UNR_VERSION@" - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#define inline __inline -#endif - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Substitute UNU.RAN functions for missing system functions */ - -#if !HAVE_DECL_LOG1P -#define log1p _unur_log1p -#endif diff --git a/math/unuran/src/unuran-1.11.0.tar.gz b/math/unuran/src/unuran-1.11.0.tar.gz deleted file mode 100644 index 891ccc0858210..0000000000000 Binary files a/math/unuran/src/unuran-1.11.0.tar.gz and /dev/null differ