|
1 | 1 | #!/usr/bin/env Rscript |
2 | 2 |
|
3 | | -# Set platform specific name of RcppTskit library and add appropriate flags |
| 3 | +# TODO: Make configure.R::setRcppTskitLibAndFlags() portable across Unix/Linux/macOS/Windows platforms #19 |
| 4 | +# https://github.com/HighlanderLab/RcppTskit/issues/19 |
| 5 | + |
| 6 | +# Set platform-specific linker flags for RcppTskit |
4 | 7 | setRcppTskitLibAndFlags <- function() { |
5 | | - if (.Platform$OS.type == "unix") { |
6 | | - # Unix/Linux & macOS |
| 8 | + sysname <- Sys.info()[["sysname"]] |
| 9 | + os_type <- .Platform$OS.type |
| 10 | + if (os_type == "unix") { |
7 | 11 | libname <- "RcppTskit.so" |
8 | | - } else if (.Platform$OS.type == "windows") { |
9 | | - libname <- "RcppTskit.dll.a" # MinGW/Rtools (default) |
10 | | - # "RcppTskit.lib" # MSVC (backup to MinGW/Rtools) |
11 | | - # "RcppTskit.dll" # DLL (backup to MinGW/Rtools) |
| 12 | + if (sysname == "Darwin") { |
| 13 | + # macOS: Use -install_name with @rpath for better portability |
| 14 | + return(paste0("-Wl,-install_name,@rpath/", libname)) |
| 15 | + } else { |
| 16 | + # Linux/Solaris/FreeBSD: Use -soname for shared library versioning |
| 17 | + return(paste0("-Wl,-soname,", libname)) |
| 18 | + } |
| 19 | + } else if (os_type == "windows") { |
| 20 | + # Windows: Rtools 4.x/5.x uses --out-implib for import libraries |
| 21 | + # libname should typically be the import library .dll.a |
| 22 | + libname <- "RcppTskit.dll.a" |
| 23 | + return(paste0("-Wl,--out-implib,", libname)) |
12 | 24 | } else { |
13 | | - stop("Unknown .Platform$OS.type!") |
| 25 | + stop(sprintf("Unsupported platform: %s (%s)", sysname, os_type)) |
14 | 26 | } |
15 | | - # TODO: Make configure.R::setRcppTskitLibAndFlags() portable across Unix/Linux/macOS/Windows platforms #19 |
16 | | - # https://github.com/HighlanderLab/RcppTskit/issues/19 |
17 | | - ret <- paste0("-Wl,-install_name,@rpath/", libname) |
18 | | - return(ret) |
19 | 27 | } |
20 | 28 |
|
21 | 29 | # Render a Makevars file from a template by replacing placeholders. |
|
0 commit comments