mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Merge branch 'master' of github.com:ashinn/chibi-scheme
This commit is contained in:
commit
83aefd12d0
3 changed files with 125 additions and 102 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -62,6 +62,7 @@ lib/srfi/160/uvprims.c
|
||||||
*.err
|
*.err
|
||||||
*.fasl
|
*.fasl
|
||||||
*.txt
|
*.txt
|
||||||
|
!CMakeLists.txt
|
||||||
*.test
|
*.test
|
||||||
*.train
|
*.train
|
||||||
*.h5
|
*.h5
|
||||||
|
|
221
CMakeLists.txt
221
CMakeLists.txt
|
@ -2,23 +2,18 @@
|
||||||
# FIXME: This CMakeLists.txt is only for Win32 platforms for now
|
# FIXME: This CMakeLists.txt is only for Win32 platforms for now
|
||||||
#
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.7)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project(chibi-scheme)
|
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION version)
|
||||||
|
string(STRIP ${version} version)
|
||||||
#
|
|
||||||
# Version setting
|
|
||||||
#
|
|
||||||
|
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/RELEASE release)
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/RELEASE release)
|
||||||
string(STRIP ${release} release)
|
string(STRIP ${release} release)
|
||||||
|
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION rawversion)
|
project(chibi-scheme LANGUAGES C VERSION ${version}
|
||||||
string(STRIP ${rawversion} rawversion)
|
DESCRIPTION "Chibi-Scheme: minimal r7rs implementation, release: ${release}")
|
||||||
set(version "${rawversion}-cmake")
|
|
||||||
|
|
||||||
set(chibischemelib "chibi-scheme-${rawversion}")
|
include(CheckIncludeFile)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
|
@ -30,38 +25,25 @@ if(UNIX)
|
||||||
"UNIX platforms are not supported with this CMakeLists.txt. Use Makefile instead.")
|
"UNIX platforms are not supported with this CMakeLists.txt. Use Makefile instead.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Features
|
# Features
|
||||||
#
|
#
|
||||||
|
|
||||||
check_include_file(poll.h HAVE_POLL_H)
|
check_include_file(poll.h HAVE_POLL_H)
|
||||||
check_include_file(stdint.h HAVE_STDINT_H)
|
check_include_file(stdint.h HAVE_STDINT_H)
|
||||||
# option(CHIBI_SCHEME_USE_DL "Use dynamic loading" ON)
|
|
||||||
set(CHIBI_SCHEME_USE_DL OFF)
|
|
||||||
option(CHIBI_SCHEME_SHARED "Build chibi-scheme as a shared library" ON)
|
|
||||||
|
|
||||||
if(NOT CHIBI_SCHEME_SHARED)
|
if (WIN32 AND NOT CYGWIN)
|
||||||
add_definitions(-DSEXP_STATIC_LIBRARY=1)
|
set(DEFAULT_SHARED_LIBS OFF)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CHIBI_SCHEME_USE_DL)
|
|
||||||
add_definitions(-DSEXP_USE_DL=1)
|
|
||||||
else()
|
else()
|
||||||
add_definitions(-DSEXP_USE_DL=0)
|
set(DEFAULT_SHARED_LIBS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_STDINT_H)
|
option(BUILD_SHARED_LIBS "Build chibi-scheme as a shared library" ${DEFAULT_SHARED_LIBS})
|
||||||
add_definitions(-DSEXP_USE_INTTYPES=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT HAVE_POLL_H)
|
|
||||||
# Disable green threads: It depends on non-blocking I/O
|
|
||||||
add_definitions(-DSEXP_USE_GREEN_THREADS=0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(chibi-scheme-exclude-modules)
|
set(chibi-scheme-exclude-modules)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DBUILDING_DLL)
|
|
||||||
set(chibi-scheme-exclude-modules
|
set(chibi-scheme-exclude-modules
|
||||||
# Following modules are not compatible with Win32
|
# Following modules are not compatible with Win32
|
||||||
lib/chibi/net.sld
|
lib/chibi/net.sld
|
||||||
|
@ -72,6 +54,43 @@ if(WIN32)
|
||||||
lib/chibi/pty.sld)
|
lib/chibi/pty.sld)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Default settings for all targets. We use an interface library here to not
|
||||||
|
# pollute/mutate global settings.
|
||||||
|
#
|
||||||
|
|
||||||
|
add_library(libchibi-common
|
||||||
|
INTERFACE)
|
||||||
|
|
||||||
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_STATIC_LIBRARY=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(libchibi-common
|
||||||
|
INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
|
|
||||||
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_DL=0)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_DL=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_STDINT_H)
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_INTTYPES)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_NTP_GETTIME)
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_NTPGETTIME)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT HAVE_POLL_H)
|
||||||
|
# Disable green threads: It depends on non-blocking I/O
|
||||||
|
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_GREEN_THREADS=0)
|
||||||
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Sources
|
# Sources
|
||||||
#
|
#
|
||||||
|
@ -89,38 +108,49 @@ set(chibi-scheme-srcs
|
||||||
eval.c
|
eval.c
|
||||||
simplify.c)
|
simplify.c)
|
||||||
|
|
||||||
include_directories(
|
|
||||||
include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bootstrap
|
# Bootstrap
|
||||||
#
|
#
|
||||||
|
|
||||||
add_executable(chibi-scheme-bootstrap
|
add_executable(chibi-scheme-bootstrap
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
${chibi-scheme-srcs}
|
${chibi-scheme-srcs}
|
||||||
main.c)
|
main.c)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(chibi-scheme-bootstrap ws2_32)
|
target_link_libraries(chibi-scheme-bootstrap
|
||||||
|
PRIVATE ws2_32 libchibi-common)
|
||||||
|
else()
|
||||||
|
target_link_libraries(chibi-scheme-bootstrap
|
||||||
|
PRIVATE libchibi-common)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CYGWIN OR WIN32)
|
|
||||||
set(soext ".dll")
|
#
|
||||||
else()
|
# Core library
|
||||||
set(soext ".so")
|
#
|
||||||
endif()
|
|
||||||
|
add_library(libchibi-scheme
|
||||||
|
${chibi-scheme-srcs})
|
||||||
|
|
||||||
|
target_link_libraries(libchibi-scheme
|
||||||
|
PUBLIC libchibi-common)
|
||||||
|
|
||||||
|
set_target_properties(libchibi-scheme
|
||||||
|
PROPERTIES
|
||||||
|
SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR}
|
||||||
|
VERSION ${CMAKE_PROJECT_VERSION})
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate modules
|
# Generate modules
|
||||||
#
|
#
|
||||||
|
|
||||||
# FIXME: Currently, it depends on GLOB thus we have to re-run CMake
|
# FIXME: Currently, it depends on GLOB thus we have to re-run CMake
|
||||||
# when we've gotten additional/removed library
|
# when we've gotten additional/removed library
|
||||||
|
|
||||||
file(GLOB_RECURSE stubs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/lib
|
file(GLOB_RECURSE stubs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/lib
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/*.stub)
|
${CMAKE_CURRENT_SOURCE_DIR}/lib/*.stub)
|
||||||
file(GLOB_RECURSE slds RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
file(GLOB_RECURSE slds RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/*.sld)
|
${CMAKE_CURRENT_SOURCE_DIR}/lib/*.sld)
|
||||||
list(REMOVE_ITEM slds ${chibi-scheme-exclude-modules})
|
list(REMOVE_ITEM slds ${chibi-scheme-exclude-modules})
|
||||||
|
|
||||||
|
@ -144,60 +174,58 @@ foreach(e ${stubs})
|
||||||
endforeach()
|
endforeach()
|
||||||
add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts})
|
add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_dependencies(libchibi-scheme chibi-scheme-stubs)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate clib.c for SEXP_USE_STATIC_LIBS
|
# Generate clib.c for SEXP_USE_STATIC_LIBS
|
||||||
#
|
#
|
||||||
|
|
||||||
string(REPLACE ";" "\n" genstatic-input "${slds}")
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
set(clibin ${CMAKE_CURRENT_BINARY_DIR}/clib-in.txt)
|
string(REPLACE ";" "\n" genstatic-input "${slds}")
|
||||||
set(clibout ${CMAKE_CURRENT_BINARY_DIR}/clib.c)
|
set(clibin ${CMAKE_CURRENT_BINARY_DIR}/clib-in.txt)
|
||||||
set(genstatic-helper
|
set(clibout ${CMAKE_CURRENT_BINARY_DIR}/clib.c)
|
||||||
${CMAKE_CURRENT_LIST_DIR}/contrib/chibi-genstatic-helper.cmake)
|
set(genstatic-helper
|
||||||
file(WRITE ${clibin} "${genstatic-input}")
|
${CMAKE_CURRENT_LIST_DIR}/contrib/chibi-genstatic-helper.cmake)
|
||||||
|
file(WRITE ${clibin} "${genstatic-input}")
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${clibout}
|
add_custom_command(OUTPUT ${clibout}
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND}
|
${CMAKE_COMMAND}
|
||||||
-DEXEC=$<TARGET_FILE:chibi-scheme-bootstrap>
|
-DEXEC=$<TARGET_FILE:chibi-scheme-bootstrap>
|
||||||
-DGENSTATIC=${chibi-genstatic}
|
-DGENSTATIC=${chibi-genstatic}
|
||||||
-DSTUBS=${clibin}
|
-DSTUBS=${clibin}
|
||||||
-DOUT=${clibout}
|
-DOUT=${clibout}
|
||||||
-P ${genstatic-helper}
|
-P ${genstatic-helper}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DEPENDS
|
DEPENDS
|
||||||
chibi-scheme-bootstrap
|
chibi-scheme-bootstrap
|
||||||
${chibi-genstatic}
|
${chibi-genstatic}
|
||||||
${genstatic-helper}
|
${genstatic-helper}
|
||||||
${slds})
|
${slds})
|
||||||
|
|
||||||
#
|
target_compile_definitions(libchibi-scheme
|
||||||
# Core library
|
PUBLIC
|
||||||
#
|
SEXP_USE_STATIC_LIBS=1)
|
||||||
|
|
||||||
if(CHIBI_SCHEME_SHARED)
|
target_sources(libchibi-scheme
|
||||||
set(libtype SHARED)
|
PUBLIC
|
||||||
else()
|
${clibout})
|
||||||
set(libtype STATIC)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(${chibischemelib} ${libtype}
|
target_include_directories(libchibi-common
|
||||||
${chibi-scheme-srcs}
|
INTERFACE
|
||||||
${clibout})
|
$<BUILD_INTERFACE:${stuboutdir}/..>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
set_target_properties(${chibischemelib}
|
elseif(WIN32)
|
||||||
PROPERTIES
|
target_link_libraries(libchibi-scheme ws2_32)
|
||||||
COMPILE_DEFINITIONS "SEXP_USE_STATIC_LIBS=1")
|
target_compile_definitions(libchibi-scheme PUBLIC BUILDING_DLL=1)
|
||||||
|
|
||||||
add_dependencies(${chibischemelib} chibi-scheme-stubs)
|
|
||||||
|
|
||||||
if(WIN32 AND CHIBI_SCHEME_SHARED)
|
|
||||||
target_link_libraries(${chibischemelib} ws2_32)
|
|
||||||
target_compile_definitions(${chibischemelib} PUBLIC -DBUILDING_DLL=1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(bless_chibi_scheme_executable tgt)
|
function(bless_chibi_scheme_executable tgt)
|
||||||
target_link_libraries(${tgt} ${chibischemelib})
|
target_link_libraries(${tgt} libchibi-scheme)
|
||||||
if(WIN32 AND NOT CHIBI_SCHEME_SHARED)
|
if(WIN32 AND NOT ${BUILD_SHARED_LIBS})
|
||||||
target_link_libraries(${tgt} ws2_32)
|
target_link_libraries(${tgt} ws2_32)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -206,16 +234,13 @@ endfunction()
|
||||||
# Interpreter
|
# Interpreter
|
||||||
#
|
#
|
||||||
|
|
||||||
include_directories(
|
|
||||||
.
|
|
||||||
${stuboutdir}/..)
|
|
||||||
add_executable(chibi-scheme
|
add_executable(chibi-scheme
|
||||||
main.c)
|
main.c)
|
||||||
|
|
||||||
bless_chibi_scheme_executable(chibi-scheme)
|
bless_chibi_scheme_executable(chibi-scheme)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate "chibi/install.h"
|
# Generate "chibi/install.h"
|
||||||
#
|
#
|
||||||
|
|
||||||
if(CYGWIN OR WIN32)
|
if(CYGWIN OR WIN32)
|
||||||
|
@ -242,17 +267,9 @@ set(default_module_path
|
||||||
#"${CMAKE_INSTALL_PREFIX}/${thePrefix}${pathsep}${CMAKE_INSTALL_PREFIX}/bin"
|
#"${CMAKE_INSTALL_PREFIX}/${thePrefix}${pathsep}${CMAKE_INSTALL_PREFIX}/bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/chibi)
|
configure_file(include/chibi/install.h.in include/chibi/install.h)
|
||||||
|
|
||||||
file(WRITE
|
#
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/include/chibi/install.h
|
|
||||||
"#define sexp_so_extension \"${soext}\"
|
|
||||||
#define sexp_default_module_path \"${default_module_path}\"
|
|
||||||
#define sexp_platform \"${platform}\"
|
|
||||||
#define sexp_version \"\"
|
|
||||||
#define sexp_release_name \"${release}\"")
|
|
||||||
|
|
||||||
#
|
|
||||||
# Testing
|
# Testing
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -315,7 +332,7 @@ foreach(e ${testlibs})
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Testing (embedding)
|
# Testing (embedding)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
5
include/chibi/install.h.in
Normal file
5
include/chibi/install.h.in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#define sexp_so_extension "@CMAKE_SHARED_LIBRARY_SUFFIX@"
|
||||||
|
#define sexp_default_module_path "@default_module_path@"
|
||||||
|
#define sexp_platform "@platform@"
|
||||||
|
#define sexp_version "@CMAKE_PROJECT_VERSION@"
|
||||||
|
#define sexp_release_name "@release@"
|
Loading…
Add table
Reference in a new issue