From: Alexei Sheplyakov Date: Mon, 30 May 2011 23:50:01 +0000 (+0300) Subject: [build] GiNaC can be built with CMake now. X-Git-Tag: release_1-6-3~58 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=bf0d26572edecc37d98aec715e14fbd71a8c0315 [build] GiNaC can be built with CMake now. Known issues: * no make dist * no make install-pdf --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..86d76fac --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,177 @@ +cmake_minimum_required(VERSION 2.6) +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") + +project(GiNaC) +file(STRINGS ${CMAKE_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINACLIB_.*_VERSION.*") +string(REGEX REPLACE "^.*GINACLIB_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MAJOR_VERSION "${_ginac_vinfo}") +string(REGEX REPLACE "^.*GINACLIB_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MINOR_VERSION "${_ginac_vinfo}") +string(REGEX REPLACE "^.*GINACLIB_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MICRO_VERSION "${_ginac_vinfo}") +set(GINAC_VERSION "${GINAC_MAJOR_VERSION}.${GINAC_MINOR_VERSION}.${GINAC_MICRO_VERSION}") + +# Library versioning info +file(STRINGS ${CMAKE_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINAC_LT_.*") +string(REGEX REPLACE "^.*GINAC_LT_CURRENT[ \t]+([0-9]+).*" "\\1" ginac_lt_current "${_ginac_vinfo}") +string(REGEX REPLACE "^.*GINAC_LT_AGE[ \t]+([0-9]+).*" "\\1" ginac_lt_age "${_ginac_vinfo}") +string(REGEX REPLACE "^.*GINAC_LT_REVISION[ \t]+([0-9]+).*" "\\1" ginac_lt_revision "${_ginac_vinfo}") +# XXX: it looks like we need to set this for every platform? +math(EXPR ginaclib_soversion "${ginac_lt_current} - ${ginac_lt_age}") +set(ginaclib_version ${ginaclib_soversion}.${ginac_lt_age}.${ginac_lt_revision}) + +# make check +enable_testing() +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +# make info +add_custom_target(info ALL) +add_custom_target(html) +add_custom_target(pdf) + +find_package(CLN 1.2.2 REQUIRED) +include_directories(${CLN_INCLUDE_DIR}) + +include(CheckIncludeFile) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("unistd.h" HAVE_UNISTD_H) + +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/ginac) + +# This macro implements some very special logic how to deal with the cache. +# By default the various install locations inherit their value from their +#"parent" variable, so if you set CMAKE_INSTALL_PREFIX, then +# EXEC_INSTALL_PREFIX, BIN_INSTALL_DIR, LIB_INSTALL_DIR, etc will calculate +# their value by appending subdirs to CMAKE_INSTALL_PREFIX. +# This would work just fine without using the cache. +# But if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value +# has to go into the cache, otherwise it will be forgotten on the next cmake +# run. Once a variable is in the cache, it doesn't depend on its "parent" +# variables anymore and you can only change it by editing it directly. +# This macro helps in this regard, because as long as you don't set one +# of the variables explicitly to some location, the value will be computed +# from parents of the variable in question. So modifying CMAKE_INSTALL_PREFIX +# later on will have the desired effect. +# But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special +# location this will go into the cache and it will no longer depend on +# CMAKE_INSTALL_PREFIX. + +macro(_set_fancy _var _value _comment) + set(predefinedvalue "${_value}") + if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "${GINAC_INSTALL_DIR}" AND DEFINED GINAC_${_var}) + set(predefinedvalue "${GINAC_${_var}}") + endif() + if (NOT DEFINED ${_var}) + set(${_var} ${predefinedvalue}) + else() + set(${_var} "${${_var}}" CACHE PATH "${_comment}") + endif() +endmacro(_set_fancy) + +_set_fancy(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" + "Base directory for libraries and executables") +_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib" + "Libraries installation directory") +_set_fancy(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" + "Binaries installation directory") +_set_fancy(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" + "Base directory for architecture independent files") +_set_fancy(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" + "Headers installation directory") + +if (NOT DEFINED BUILD_SHARED_LIBS) + if (NOT MSVC) + set(BUILD_SHARED_LIBS true) + else() + set(BUILD_SHARED_LIBS false) + endif() +endif() + +# Set proper rpath so tools will Just Work(TM) after make install. +# Also take care to add -Wl,-rpath, stanza into the *.pc file so that +# +# g++ `pkg-config --cflags --libs ginac` +# +# will Just Work (TM), too. +# Distro packagers should use -DCMAKE_INSTALL_RPATH="" to avoid +# setting rpath on installed binaries. + +# rpath for making binaries/libraries relocatable +set(_ginac_rpath_reloc "$ORIGIN/../lib") +set(_wl_rpath "${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}") + +# rpath for the pkg-config meta-data. +set(_ginaclib_rpath "${_wl_rpath}${_ginac_rpath_reloc}") +list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" isSystemDir) +if ("${isSystemDir}" STREQUAL "-1") + list(APPEND _ginaclib_rpath "${_wl_rpath}\${libdir}") +endif() +set(GINACLIB_RPATH) +if (NOT CMAKE_SKIP_RPATH) + if (_wl_rpath) + set(GINACLIB_RPATH "${_ginaclib_rpath}") + endif() +endif() + +configure_file(${CMAKE_SOURCE_DIR}/ginac.pc.cmake ${CMAKE_BINARY_DIR}/ginac.pc @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/ginac.pc DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") + +# rpath for libginac.so itself, ginsh, and friends +set(_ginac_rpath ${_ginac_rpath_reloc}) +foreach(_d ${CLN_LIBRARY_DIRS} ${LIB_INSTALL_DIR}) + list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_d}" isSystemDir) + if ("${isSystemDir}" STREQUAL "-1") + list(APPEND _ginac_rpath "${_d}") + endif() +endforeach() +list(REMOVE_DUPLICATES _ginac_rpath) +string(REPLACE ";" ":" ginac_rpath "${_ginac_rpath}") + +if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_RPATH) + set(CMAKE_INSTALL_RPATH_USE_LINK_RPATH TRUE) +endif() +if (NOT DEFINED CMAKE_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH ${ginac_rpath}) +endif() +if (APPLE AND NOT DEFINED CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) +endif() + +list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" isSystemDir) +if ("${isSystemDir}" STREQUAL "-1") + string(REPLACE ":" ";" _install_rpath "${CMAKE_INSTALL_RPATH}") + list(FIND _install_rpath "${LIB_INSTALL_DIR}" _is_rpath_consistent) + if ("${_is_rpath_consistent}" STREQUAL "-1") + message(WARNING "the libginac.so library will be installed into " + "a non-standard directory (${LIB_INSTALL_DIR}), " + "however, the rpath (${_install_rpath}) " + "does not contain that directory. Most likely " + "things won't work without extra configuration " + "(tweaking LD_LIBRARY_PATH, /etc/ld.so.conf, etc).") + endif() +endif() + + +include(FindFLEX) +include(FindBISON) +find_package(BISON) +find_package(FLEX) +find_package(Readline) +if (READLINE_FOUND) + set(HAVE_LIBREADLINE 1) + set(HAVE_READLINE_READLINE_H 1) + set(HAVE_READLINE_HISTORY_H 1) +endif() + +find_program(MAKEINFO makeinfo) +find_program(FIG2DEV fig2dev) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +add_definitions(-DHAVE_CONFIG_H) + +add_subdirectory(ginac) +add_subdirectory(tools) +add_subdirectory(check) +if (BISON_FOUND AND FLEX_FOUND) + add_subdirectory(ginsh) +endif() +if (MAKEINFO) + add_subdirectory(doc) +endif() + diff --git a/INSTALL b/INSTALL index bfa4bdd9..d36c8e9d 100644 --- a/INSTALL +++ b/INSTALL @@ -31,7 +31,7 @@ Known not to work with: is missing there. If you install from git, you also need GNU autoconf (>=2.59), automake (>=1.8), -libtool (>= 1.5), bison (>= 2.3), flex (>= 2.5.33) to be installed. +libtool (>= 1.5), python (>= 2.5), bison (>= 2.3), flex (>= 2.5.33) to be installed. INSTALLATION diff --git a/INSTALL.CMake b/INSTALL.CMake new file mode 100644 index 00000000..1ea525f6 --- /dev/null +++ b/INSTALL.CMake @@ -0,0 +1,64 @@ +PREREQUISITES +============= + +1. A decent ANSI-compliant C++ compiler. GCC (version >= 4.4) is recommended. +2. CLN library (http://www.ginac.de/CLN), version >= 1.2.2 +3. CMake, version >= 2.8 (version 2.6.x might work too). +4. Python, version >= 2.6 +5. (optional) pkg-config utility (http://pkg-config.freedesktop.org) +6. (optional) bison (>= 2.3), flex (2.5.33), GNU readline (>= 4.3). These + are necessary to build ginsh, the GiNaC interactive shell, and can be + skipped if you don't intend to use ginsh (i.e. you need the GiNaC library + for compiling another piece of a software). +7. (optional) To build the GiNaC tutorial and reference manual the doxygen + utility (it can be downloaded from http://www.stack.nl/~dimitri/doxygen) + and TeX are necessary. + +INSTALLATION +============ + +To install from a source distribution: +-------------------------------------- + +1) Unpack the tarball + + $ tar xaf GiNaC-x.y.z.tar.bz2 + +2) Create a build directory + + $ mkdir ginac_build + +3) Run CMake to generate Makefile's + + $ cd ginac_build + $ cmake ../GiNaC-x.y.z + +4) Actually build GiNaC + + $ make + +5) Run the test and benchmark suite (not mandatory, but strongly recommended) + + $ make check + +6) Install GiNaC + + [become root if necessary] + # make install + +To install from git: +-------------------- + +The steps are essentially the same as compiling from the tarball, the only +difference is using git to get the code. + +1) Download the code: + + $ git clone git://www.ginac.de/ginac.git ginac + + or, if you have already cloned the repository, + + $ git pull + +Subsequent steps are the same as compiling from a source tarball. + diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt new file mode 100644 index 00000000..4e9e7454 --- /dev/null +++ b/check/CMakeLists.txt @@ -0,0 +1,94 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ginac) +add_definitions(-DIN_GINAC) + +set(ginac_tests + check_numeric + check_inifcns + check_matrices + check_lsolve + heur_gcd_bug + exam_paranoia + exam_heur_gcd + match_bug + parser_bugs + exam_numeric_archive + exam_numeric + exam_powerlaws + exam_inifcns + exam_inifcns_nstdsums + exam_differentiation + exam_polygcd + exam_normalization + exam_factor + exam_pseries + exam_matrices + exam_lsolve + exam_indexed + exam_color + exam_clifford + exam_archive + exam_structure + exam_hashmap + exam_misc + exam_mod_gcd + exam_cra + bugme_chinrem_gcd + pgcd_relatively_prime_bug + pgcd_infinite_loop) + +set(ginac_timings + time_dennyfliegner + time_gammaseries + time_vandermonde + time_toeplitz + time_hashmap + time_lw_A + time_lw_B + time_lw_C + time_lw_D + time_lw_E + time_lw_F + time_lw_G + time_lw_H + time_lw_IJKL + time_lw_M1 + time_lw_M2 + time_lw_N + time_lw_O + time_lw_P + time_lw_Pprime + time_lw_Q + time_lw_Qprime + time_antipode + time_fateman_expand + time_uvar_gcd + time_parser) + +macro(add_ginac_test thename) + if ("${${thename}_sources}" STREQUAL "") + set(${thename}_sources ${thename}.cpp ${${thename}_extra_src}) + endif() + add_executable(${thename} EXCLUDE_FROM_ALL ${${thename}_sources}) + target_link_libraries(${thename} ginac) + add_dependencies(check ${thename}) + add_test(${thename} ${thename}) +endmacro() + +macro(add_ginac_timing thename) + set(${thename}_extra_src timer.cpp randomize_serials.cpp) + add_ginac_test(${thename}) +endmacro() + +set(check_matrices_extra_src genex.cpp) +set(check_lsolve_extra_src genex.cpp) +set(exam_heur_gcd_sources heur_gcd_bug.cpp) +set(exam_numeric_archive_sources numeric_archive.cpp) + +foreach(tst ${ginac_tests}) + add_ginac_test(${tst}) +endforeach() + +foreach(tmr ${ginac_timings}) + add_ginac_timing(${tmr}) +endforeach() + diff --git a/cmake/modules/FindCLN.cmake b/cmake/modules/FindCLN.cmake new file mode 100644 index 00000000..663d3850 --- /dev/null +++ b/cmake/modules/FindCLN.cmake @@ -0,0 +1,118 @@ +# CLN_FOUND CLN has been successfully found +# CLN_INCLUDE_DIR the include directories +# CLN_LIBRARIES CLN library and its dependencies (if any) + +if (CLN_INCLUDE_DIR AND CLN_LIBRARIES) + set(CLN_FIND_QUIETLY TRUE) +endif() + +function(_cl_get_version _out_major _out_minor _out_patch _cl_version_h) + file(STRINGS ${_cl_version_h} _cl_vinfo REGEX "^#define[\t ]+CL_VERSION_.*") + if (NOT _cl_vinfo) + message(FATAL_ERROR "include file ${_cl_version_h} does not exist") + endif() + string(REGEX REPLACE "^.*CL_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" ${_out_major} "${_cl_vinfo}") + string(REGEX REPLACE "^.*CL_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" ${_out_minor} "${_cl_vinfo}") + string(REGEX REPLACE "^.*CL_VERSION_PATCHLEVEL[ \t]+([0-9]+).*" "\\1" ${_out_patch} "${_cl_vinfo}") + if (NOT ${_out_major} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine CL_VERSION_MAJOR, " + "expected a number, got ${${_out_major}}") + endif() + if (NOT ${_out_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine CL_VERSION_MINOR, " + "expected a number, got ${${_out_minor}}") + endif() + if (NOT ${_out_patch} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine CL_VERSION_PATCHLEVEL, " + "expected a number, got ${${_out_patch}}") + endif() + message(STATUS "found CLN [${_cl_version_h}], version ${${_out_major}}.${${_out_minor}}.${${_out_patch}}") + set(${_out_major} ${${_out_major}} PARENT_SCOPE) + set(${_out_minor} ${${_out_minor}} PARENT_SCOPE) + set(${_out_patch} ${${_out_patch}} PARENT_SCOPE) +endfunction() + +set(CLN_FOUND) +set(CLN_INCLUDE_DIR) +set(CLN_LIBRARIES) + +include(FindPkgConfig) +if (PKG_CONFIG_FOUND) + pkg_check_modules(_cln cln) +endif() + +find_path(CLN_INCLUDE_DIR NAMES cln/cln.h + HINTS ${_cln_INCLUDE_DIRS} + $ENV{CLN_DIR}/include) +find_library(CLN_LIBRARIES NAMES libcln cln + HINTS ${_cln_LIBRARY_DIR} + ${_cln_LIBRARY_DIRS} + $ENV{CLN_DIR}/lib) + +if (CLN_INCLUDE_DIR) + _cl_get_version(CLN_VERSION_MAJOR + CLN_VERSION_MINOR + CLN_VERSION_PATCHLEVEL + ${CLN_INCLUDE_DIR}/cln/version.h) + set(CLN_VERSION ${CLN_VERSION_MAJOR}.${CLN_VERSION_MINOR}.${CLN_VERSION_PATCHLEVEL}) + # Check if the version reported by pkg-config is the same + # as the one read from the header. This prevents us from + # picking the wrong version of CLN (say, if several versions + # are installed) + if (PKG_CONFIG_FOUND AND NOT CLN_VERSION VERSION_EQUAL _cln_VERSION) + if (NOT CLN_FIND_QUIETLY) + message(ERROR "pkg-config and version.h disagree, " + "${_cln_VERSION} vs ${CLN_VERSION}, " + "please check your installation") + endif() + set(CLN_LIBRARIES CLN-NOTFOUND) + set(CLN_INCLUDE_DIR CLN-NOTFOUND) + set(CLN_LIBRARY_DIRS) + set(CLN_VERSION) + endif() +endif() + +# Check if the version embedded into the library is the same as the one in the headers. +if (CLN_INCLUDE_DIR AND CLN_LIBRARIES AND NOT CMAKE_CROSSCOMPILING) + include(CheckCXXSourceRuns) + set(_save_required_includes ${CMAKE_REQUIRED_INCLUDES}) + set(_save_required_libraries ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CLN_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CLN_LIBRARIES}) + check_cxx_source_runs(" + #include + int main() { + return (CL_VERSION_MAJOR == cln::version_major) && + (CL_VERSION_MINOR == cln::version_minor) && + (CL_VERSION_PATCHLEVEL == cln::version_patchlevel) ? 0 : 1; + } + " + _cl_version_matches) + set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries}) + set(CMAKE_REQUIRED_INCLUDES ${_save_required_includes}) + if (NOT _cl_version_matches) + if (NOT CLN_FIND_QUIETLY) + message(ERROR "header (version differs from the library one, " + "please check your installation.") + endif() + set(CLN_INCLUDE_DIR CLN-NOTFOUND) + set(CLN_LIBRARIES CLN-NOTFOUND) + set(CLN_LIBRARY_DIRS) + set(CLN_VERSION) + endif() +endif() + +if (CLN_LIBRARIES AND CLN_INCLUDE_DIR) + set(_cln_library_dirs) + foreach(_l ${CLN_LIBRARIES}) + get_filename_component(_d "${_l}" PATH) + list(APPEND _cln_library_dirs "${_d}") + endforeach() + list(REMOVE_DUPLICATES _cln_library_dirs) + set(CLN_LIBRARY_DIRS ${_cln_library_dirs}) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLN REQUIRED_VARS CLN_LIBRARIES CLN_INCLUDE_DIR + VERSION_VAR CLN_VERSION) + diff --git a/cmake/modules/FindGiNaC.cmake b/cmake/modules/FindGiNaC.cmake new file mode 100644 index 00000000..e12ed686 --- /dev/null +++ b/cmake/modules/FindGiNaC.cmake @@ -0,0 +1,157 @@ +# GINAC_FOUND CiNaC has been successfully found +# GINAC_INCLUDE_DIRS the include directories +# GINAC_LIBRARIES GiNaC library and its dependencies + +if (GINAC_INCLUDE_DIRS AND GINAC_LIBRARIES) + set(GINAC_FIND_QUIETLY TRUE) +endif() + +function(_ginac_headers_version _out_major _out_minor _out_patch _version_h) + file(STRINGS ${_version_h} _ginac_vinfo REGEX "^#define[\t ]+GINACLIB_.*_VERSION.*") + if (NOT _ginac_vinfo) + message(FATAL_ERROR "include file ${_version_h} does not exist") + endif() + string(REGEX REPLACE "^.*GINACLIB_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_out_major} "${_ginac_vinfo}") + string(REGEX REPLACE "^.*GINACLIB_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_out_minor} "${_ginac_vinfo}") + string(REGEX REPLACE "^.*GINACLIB_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" ${_out_patch} "${_ginac_vinfo}") + if (NOT ${_out_major} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine GINACLIB_MAJOR_VERSION, " + "expected a number, got ${${_out_major}}") + endif() + if (NOT ${_out_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine GINACLIB_MINOR_VERSION, " + "expected a number, got ${${_out_minor}}") + endif() + if (NOT ${_out_patch} MATCHES "[0-9]+") + message(FATAL_ERROR "failed to determine GINACLIB_MINOR_VERSION, " + "expected a number, got ${${_out_patch}}") + endif() + set(${_out_major} ${${_out_major}} PARENT_SCOPE) + set(${_out_minor} ${${_out_minor}} PARENT_SCOPE) + set(${_out_patch} ${${_out_patch}} PARENT_SCOPE) +endfunction() + +set(GINAC_FOUND) +set(GINAC_INCLUDE_DIRS) +set(GINAC_LIBRARIES) +set(GINAC_LIBRARY_DIRS) +set(GINAC_VERSION) + +include(FindPkgConfig) +find_package(CLN 1.2.2) + +if (PKG_CONFIG_FOUND) + pkg_check_modules(_ginac ginac) +else() + set(_ginac_LIBRARIES ginac cln gmp) +endif() + +if (NOT CLN_FOUND) + set(GINAC_INCLUDE_DIRS GINAC-NOTFOUND) + set(GINAC_LIBRARIES GINAC-NOTFOUND) +else() + find_path(_ginac_include_dir NAMES ginac/ginac.h + HINTS ${_ginac_INCLUDE_DIRS} + $ENV{GINAC_DIR}/include) + if (_ginac_include_dir) + set(GINAC_INCLUDE_DIRS ${_ginac_include_dir} + ${_ginac_INCLUDE_DIRS} + ${CLN_INCLUDE_DIR}) + list(REMOVE_DUPLICATES GINAC_INCLUDE_DIRS) + else() + set(GINAC_INCLUDE_DIRS GINAC-NOTFOUND) + set(GINAC_LIBRARIES GINAC-NOTFOUND) + if (NOT GINAC_FIND_QUIETLY) + message(ERROR "couldn't find ginac.h") + endif() + endif() + + if (GINAC_INCLUDE_DIRS) + find_library(_ginac_lib NAMES libginac ginac + HINTS ${_ginac_LIBRARY_DIRS} + $ENV{GINAC_DIR}/lib) + if (_ginac_lib) + set(GINAC_LIBRARIES ${_ginac_lib} ${CLN_LIBRARIES}) + list(REMOVE_DUPLICATES GINAC_LIBRARIES) + else() + set(GINAC_LIBRARIES GINAC-NOTFOUND) + set(GINAC_INCLUDE_DIRS GINAC-NOTFOUND) + if (NOT GINAC_FIND_QUIETLY) + message(ERROR "couldn't find libginac") + endif() + endif() + endif() +endif() + +if (GINAC_INCLUDE_DIRS) + _ginac_headers_version(GINACLIB_MAJOR_VERSION + GINACLIB_MINOR_VERSION + GINACLIB_MICRO_VERSION + ${_ginac_include_dir}/ginac/version.h) + set(GINAC_VERSION ${GINACLIB_MAJOR_VERSION}.${GINACLIB_MINOR_VERSION}.${GINACLIB_MICRO_VERSION}) + # Check if the version reported by pkg-config is the same + # as the one read from the header. This prevents us from + # picking the wrong version of GINAC (say, if several versions + # are installed) + if (PKG_CONFIG_FOUND AND NOT GINAC_VERSION VERSION_EQUAL _ginac_VERSION) + if (NOT CLN_FIND_QUIETLY) + message(ERROR "pkg-config and version.h disagree, " + "${_ginac_VERSION} vs ${GINAC_VERSION}, " + "please check your installation") + endif() + set(GINAC_LIBRARIES GINAC-NOTFOUND) + set(GINAC_INCLUDE_DIRS GINAC-NOTFOUND) + set(GINAC_LIBRARY_DIRS) + set(GINAC_VERSION) + endif() +endif() + +# Check if the version embedded into the library is the same as the one in the headers. +if (GINAC_INCLUDE_DIRS AND GINAC_LIBRARIES AND NOT CMAKE_CROSSCOMPILING) + include(CheckCXXSourceRuns) + set(_save_required_includes ${CMAKE_REQUIRED_INCLUDES}) + set(_save_required_libraries ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GINAC_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GINAC_LIBRARIES}) + check_cxx_source_runs(" + #include + #include + #include + int main() { + return (CL_VERSION_MAJOR == cln::version_major) && + (CL_VERSION_MINOR == cln::version_minor) && + (CL_VERSION_PATCHLEVEL == cln::version_patchlevel) && + (GINACLIB_MAJOR_VERSION == GiNaC::version_major) && + (GINACLIB_MINOR_VERSION == GiNaC::version_minor) && + (GINACLIB_MICRO_VERSION == GiNaC::version_micro) ? 0 : 1; + } + " + _ginac_version_matches) + set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries}) + set(CMAKE_REQUIRED_INCLUDES ${_save_required_includes}) + if (NOT _ginac_version_matches) + if (NOT GINAC_FIND_QUIETLY) + message(ERROR "header version differs from the library one, " + "please check your installation.") + endif() + set(GINAC_INCLUDE_DIRS GINAC-NOTFOUND) + set(GINAC_LIBRARIES GINAC_NOTFOUND) + set(GINAC_LIBRARY_DIRS) + set(GINAC_VERSION) + endif() +endif() + +if (GINAC_LIBRARIES AND GINAC_INCLUDE_DIRS) + set(_ginac_library_dirs) + foreach(_l ${GINAC_LIBRARIES}) + get_filename_component(_d "${_l}" PATH) + list(APPEND _ginac_library_dirs "${_d}") + endforeach() + list(REMOVE_DUPLICATES _ginac_library_dirs) + set(GINAC_LIBRARY_DIRS ${_ginac_library_dirs}) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GiNaC REQUIRED_VARS GINAC_LIBRARIES GINAC_INCLUDE_DIRS + VERSION_VAR GINAC_VERSION) + diff --git a/cmake/modules/FindReadline.cmake b/cmake/modules/FindReadline.cmake new file mode 100644 index 00000000..ab3e8f91 --- /dev/null +++ b/cmake/modules/FindReadline.cmake @@ -0,0 +1,49 @@ +# READLINE_FOUND +# READLINE_INCLUDE_DIRS +# READLINE_LIBRARIES + +if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES) + set(READLINE_FIND_QUIETLY TRUE) +endif() + +include(CheckCXXSourceCompiles) + +find_path(READLINE_INCLUDE_DIRS NAMES readline/readline.h) +if (NOT READLINE_INCLUDE_DIRS AND NOT READLINE_FIND_QUIETLY) + message(ERROR "couldn't find the readline/readline.h header") +endif() +find_library(READLINE_LIBRARIES NAMES libreadline readline) +if (NOT READLINE_LIBRARIES AND NOT READLINE_FIND_QUIETLY) + message(ERROR "couldn't find libreadline") +endif() + +if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES) + set(_save_req_includes ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${READLINE_INCLUDE_DIR}) + check_cxx_source_compiles(" + #include + #include + #if !defined(RL_VERSION_MAJOR) || !defined(RL_VERSION_MINOR) + #error Ancient version of readline + #endif + int main() { return 0; } + " + _rl_version_check) + set(CMAKE_REQUIRED_INCLUDES ${_save_req_includes}) + if (NOT _rl_version_check) + set(READLINE_INCLUDE_DIRS READLINE-NOTFOUND) + set(READLINE_LIBRARIES READLINE-NOTFOUND) + if (NOT READLINE_FIND_QUIETLY) + message(ERROR "Ancient/unsupported version of readline") + endif() + endif() +endif() + +if (NOT READLINE_INCLUDE_DIRS OR NOT READLINE_LIBRARIES) + set(READLINE_LIBRARIES READLINE-NOTFOUND) + set(READLINE_INCLUDE_DIRS READLINE-NOTFOUND) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(READLINE REQUIRED_VARS READLINE_INCLUDE_DIRS READLINE_LIBRARIES) + diff --git a/config.cmake.in b/config.cmake.in new file mode 100644 index 00000000..73fca28a --- /dev/null +++ b/config.cmake.in @@ -0,0 +1,5 @@ +#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_LIBREADLINE +#cmakedefine HAVE_READLINE_READLINE_H +#cmakedefine HAVE_READLINE_HISTORY_H diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..fdfc193f --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,63 @@ +find_package(Doxygen) +find_program(FIG2DEV fig2dev) +find_program(TEXI2DVI texi2dvi) +find_package(LATEX) +if (PDFLATEX_COMPILER AND MAKEINDEX_COMPILER) + set(LATEX_FOUND true) +endif() + +macro(add_info_file thename) + set(${thename}_INFO ${CMAKE_CURRENT_BINARY_DIR}/${thename}.info) + set(${thename}_HTML ${CMAKE_CURRENT_BINARY_DIR}/${thename}.html) + set(${thename}_TEXINFO ${CMAKE_CURRENT_SOURCE_DIR}/${thename}.texi) + add_custom_command( + OUTPUT ${${thename}_INFO} + COMMAND ${MAKEINFO} --no-split -o ${${thename}_INFO} ${${thename}_TEXINFO} + DEPENDS ${${thename}_TEXINFO} + COMMENT "MAKEFINO ${thename}.texi" + VERBATIM) + add_custom_command( + OUTPUT ${${thename}_HTML} + COMMAND ${MAKEINFO} --html --no-split -o ${${thename}_HTML} ${${thename}_TEXINFO} + DEPENDS ${${thename}_TEXINFO} ${${thename}_HTML_EXTRA_DEPS} + COMMENT "MAKEINFOHTML ${thename}.texi" + VERBATIM) + add_custom_target(${thename}_info ALL DEPENDS ${${thename}_INFO}) + add_custom_target(${thename}_html DEPENDS ${${thename}_HTML}) + add_dependencies(info ${thename}_info) + add_dependencies(html ${thename}_html) + install(FILES ${${thename}_INFO} DESTINATION "${SHARE_INSTALL_PREFIX}/info") +endmacro() + +macro(pdflatex_process texfile) + get_filename_component(_dirname "${texfile}" PATH) + get_filename_component(_basename "${texfile}" NAME_WE) + set(_idx ${_dirname}/${_basename}.idx) + set(_ind ${_dirname}/${_basename}.ind) + set(_pdf ${_dirname}/${_basename}.pdf) + add_custom_command( + OUTPUT ${_idx} + COMMAND ${PDFLATEX_COMPILER} ${texfile} + WORKING_DIRECTORY ${_dirname} + DEPENDS ${texfile} + COMMENT "PDFLATEX ${_basename}.tex (1)") + add_custom_command( + OUTPUT ${_ind} + COMMAND ${MAKEINDEX_COMPILER} ${_idx} + WORKING_DIRECTORY ${_dirname} + DEPENDS ${texfile} ${_idx} + COMMENT "MAKEINDEX ${_basename}.idx") + add_custom_command( + OUTPUT ${_pdf} + COMMAND ${PDFLATEX_COMPILER} ${texfile} + WORKING_DIRECTORY ${_dirname} + DEPENDS ${texfile} ${_ind} + COMMENT "PDFLATEX ${_basename}.tex (2)") +endmacro() + +add_subdirectory(tutorial) +add_subdirectory(examples) +if (DOXYGEN_FOUND) + add_subdirectory(reference) +endif() + diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt new file mode 100644 index 00000000..851c61ce --- /dev/null +++ b/doc/examples/CMakeLists.txt @@ -0,0 +1 @@ +add_info_file(ginac-examples) diff --git a/doc/reference/CMakeLists.txt b/doc/reference/CMakeLists.txt new file mode 100644 index 00000000..1fb38e50 --- /dev/null +++ b/doc/reference/CMakeLists.txt @@ -0,0 +1,40 @@ +set(VERSION ${GINAC_VERSION}) +set(top_srcdir ${CMAKE_SOURCE_DIR}) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DoxyfileHTML.in + ${CMAKE_CURRENT_BINARY_DIR}/DoxyfileHTML + @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DoxyfilePDF.in + ${CMAKE_CURRENT_BINARY_DIR}/DoxyfilePDF + @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DoxyfileTEX.in + ${CMAKE_CURRENT_BINARY_DIR}/DoxyfileTEX + @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfooter.in + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfooter + @ONLY) + +add_custom_target(html_dox + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/DoxyfileHTML + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "DOXYGEN DoxyfileHTML") +add_dependencies(html html_dox) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdflatex/refman.tex + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/DoxyfilePDF + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "DOXYGEN DoxyfilePDF") +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdflatex/reference.tex + COMMAND ${CMAKE_COMMAND} -E copy refman.tex reference.tex + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pdflatex/refman.tex + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdflatex) + + +if (LATEX_FOUND) + pdflatex_process(${CMAKE_CURRENT_BINARY_DIR}/pdflatex/reference.tex) + add_custom_target(pdf_dox DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pdflatex/reference.pdf) + add_dependencies(pdf pdf_dox) +endif() + + diff --git a/doc/tutorial/CMakeLists.txt b/doc/tutorial/CMakeLists.txt new file mode 100644 index 00000000..caf171f9 --- /dev/null +++ b/doc/tutorial/CMakeLists.txt @@ -0,0 +1,59 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.texi.cmake + ${CMAKE_CURRENT_BINARY_DIR}/version.texi @ONLY) + +set(_ginac_tutorial_figures classhierarchy repnaive reppair repreal) +set(_ginac_tutorial_figures_pdf) +set(_ginac_tutorial_figures_png) +set(_ginac_tutorial_figures_eps) + +macro(add_xfig_figure thename) + set(${thename}_XFIG ${CMAKE_CURRENT_SOURCE_DIR}/${thename}.fig) + set(${thename}_PDF ${CMAKE_CURRENT_BINARY_DIR}/${thename}.pdf) + set(${thename}_EPS ${CMAKE_CURRENT_BINARY_DIR}/${thename}.eps) + set(${thename}_PNG ${CMAKE_CURRENT_BINARY_DIR}/${thename}.png) + list(APPEND _ginac_tutorial_figures_pdf ${${thename}_PDF}) + list(APPEND _ginac_tutorial_figures_png ${${thename}_PNG}) + list(APPEND _ginac_tutorial_figures_png ${${thename}_EPS}) + add_custom_command( + OUTPUT ${${thename}_PDF} + COMMAND ${FIG2DEV} -L pdf -m 0.9 ${${thename}_XFIG} ${${thename}_PDF} + DEPENDS ${${thename}_XFIG} + COMMENT "FIG2DEV ${thename}.xfig ==> ${thename}.pdf" + VERBATIM) + add_custom_command( + OUTPUT ${${thename}_EPS} + COMMAND ${FIG2DEV} -L eps -m 0.9 ${${thename}_XFIG} ${${thename}_EPS} + DEPENDS ${${thename}_XFIG} + COMMENT "FIG2DEV ${thename}.xfig ==> ${thename}.eps" + VERBATIM) + add_custom_command( + OUTPUT ${${thename}_PNG} + COMMAND ${FIG2DEV} -L png -m 0.9 ${${thename}_XFIG} ${${thename}_PNG} + DEPENDS ${${thename}_XFIG} + COMMENT "FIG2DEV ${thename}.xfig ==> ${thename}.png" + VERBATIM) +endmacro() + +macro(add_doc_format src fmt) + set(_out ${CMAKE_CURRENT_BINARY_DIR}/${src}.${fmt}) + set(_src ${CMAKE_CURRENT_SOURCE_DIR}/${src}.texi) + add_custom_command( + OUTPUT ${_out} + COMMAND ${TEXI2DVI} --${fmt} --batch -o ${_out} ${_src} + DEPENDS ${_src} ${_${src}_tutorial_figures_${fmt}} + COMMENT "TEXI2DVI ${src}.texi => ${src}.${fmt}" + VERBATIM) + add_custom_target(${fmt}_${src}_tutorial DEPENDS ${_out}) + add_dependencies(${fmt} ${fmt}_${src}_tutorial) +endmacro() + +if (TEXI2DVI AND FIG2DEV) + foreach(_f ${_ginac_tutorial_figures}) + add_xfig_figure(${_f}) + endforeach() + set(ginac_HTML_EXTRA_DEPS ${_ginac_tutorial_figures_png}) + add_doc_format(ginac pdf) +endif() + +add_info_file(ginac) + diff --git a/doc/tutorial/version.texi.cmake b/doc/tutorial/version.texi.cmake new file mode 100644 index 00000000..346b796d --- /dev/null +++ b/doc/tutorial/version.texi.cmake @@ -0,0 +1,2 @@ +@set VERSION @GINAC_VERSION@ +@set EDITION @GINAC_VERSION@ diff --git a/ginac.pc.cmake b/ginac.pc.cmake new file mode 100644 index 00000000..4b168bea --- /dev/null +++ b/ginac.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@EXEC_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: GiNaC +Description: C++ library for symbolic calculations +Version: @GINAC_VERSION@ +Requires: cln >= 1.2.2 +Libs: -L${libdir} -lginac @GINACLIB_RPATH@ +Cflags: -I${includedir} diff --git a/ginac/CMakeLists.txt b/ginac/CMakeLists.txt new file mode 100644 index 00000000..ed6ac119 --- /dev/null +++ b/ginac/CMakeLists.txt @@ -0,0 +1,176 @@ +cmake_minimum_required(VERSION 2.6) + +set(ginaclib_sources + add.cpp + archive.cpp + basic.cpp + clifford.cpp + color.cpp + constant.cpp + excompiler.cpp + ex.cpp + expair.cpp + expairseq.cpp + exprseq.cpp + factor.cpp + fail.cpp + fderivative.cpp + function.cpp + idx.cpp + indexed.cpp + inifcns.cpp + inifcns_gamma.cpp + inifcns_nstdsums.cpp + inifcns_trans.cpp + integral.cpp + lst.cpp + matrix.cpp + mul.cpp + ncmul.cpp + normal.cpp + numeric.cpp + operators.cpp + parser/default_reader.cpp + parser/lexer.cpp + parser/parse_binop_rhs.cpp + parser/parse_context.cpp + parser/parser_compat.cpp + parser/parser.cpp + polynomial/chinrem_gcd.cpp + polynomial/collect_vargs.cpp + polynomial/cra_garner.cpp + polynomial/divide_in_z_p.cpp + polynomial/gcd_uvar.cpp + polynomial/mgcd.cpp + polynomial/mod_gcd.cpp + polynomial/optimal_vars_finder.cpp + polynomial/pgcd.cpp + polynomial/primpart_content.cpp + polynomial/upoly_io.cpp + power.cpp + print.cpp + pseries.cpp + registrar.cpp + relational.cpp + remember.cpp + symbol.cpp + symmetry.cpp + tensor.cpp + utils.cpp + wildcard.cpp +) + +set(ginaclib_public_headers + ginac.h + add.h + archive.h + assertion.h + basic.h + class_info.h + clifford.h + color.h + constant.h + container.h + ex.h + excompiler.h + expair.h + expairseq.h + exprseq.h + fail.h + factor.h + fderivative.h + flags.h + ${CMAKE_CURRENT_BINARY_DIR}/function.h + hash_map.h + idx.h + indexed.h + inifcns.h + integral.h + lst.h + matrix.h + mul.h + ncmul.h + normal.h + numeric.h + operators.h + power.h + print.h + pseries.h + ptr.h + registrar.h + relational.h + structure.h + symbol.h + symmetry.h + tensor.h + version.h + wildcard.h + parser/parser.h + parser/parse_context.h +) + +set(ginaclib_private_headers + remember.h + tostring.h + utils.h + crc32.h + hash_seed.h + compiler.h + parser/lexer.h + parser/debug.h + polynomial/gcd_euclid.h + polynomial/remainder.h + polynomial/normalize.h + polynomial/upoly.h + polynomial/ring_traits.h + polynomial/mod_gcd.h + polynomial/cra_garner.h + polynomial/upoly_io.h + polynomial/prem_uvar.h + polynomial/eval_uvar.h + polynomial/interpolate_padic_uvar.h + polynomial/sr_gcd_uvar.h + polynomial/heur_gcd_uvar.h + polynomial/chinrem_gcd.h + polynomial/collect_vargs.h + polynomial/divide_in_z_p.h + polynomial/euclid_gcd_wrap.h + polynomial/eval_point_finder.h + polynomial/newton_interpolate.h + polynomial/optimal_vars_finder.h + polynomial/pgcd.h + polynomial/poly_cra.h + polynomial/primes_factory.h + polynomial/smod_helpers.h + polynomial/debug.h +) + +add_library(ginac ${ginaclib_sources}) +set_target_properties(ginac PROPERTIES + SOVERSION ${ginaclib_soversion} + VERSION ${ginaclib_version}) +target_link_libraries(ginac ${CLN_LIBRARIES}) +include_directories(${CMAKE_SOURCE_DIR}/ginac) + +if (NOT BUILD_SHARED_LIBS) + set_target_properties(ginac PROPERTIES OUTPUT_NAME "ginac") + # Avoid the static library vs import library conflict (necessary for + # m$ toolchain). + set_target_properties(ginac PROPERTIES PREFIX "lib") +endif() + +install(TARGETS ginac LIBRARY DESTINATION "${LIB_INSTALL_DIR}" + RUNTIME DESTINATION "${BIN_INSTALL_DIR}" + ARCHIVE DESTINATION "${LIB_INSTALL_DIR}") +install(FILES ${ginaclib_public_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/ginac") + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.h + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.cpp + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.cpp ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py) + diff --git a/ginac/version.h b/ginac/version.h index 018d4615..7ce9d5c7 100644 --- a/ginac/version.h +++ b/ginac/version.h @@ -74,6 +74,13 @@ #define GINACLIB_ARCHIVE_VERSION 3 #define GINACLIB_ARCHIVE_AGE 3 +#define GINACLIB_STR_HELPER(x) #x +#define GINACLIB_STR(x) GINACLIB_STR_HELPER(x) +#define GINACLIB_VERSION \ + GINACLIB_STR(GINACLIB_MAJOR_VERSION) "." \ + GINACLIB_STR(GINACLIB_MINOR_VERSION) "." \ + GINACLIB_STR(GINACLIB_MICRO_VERSION) + namespace GiNaC { extern const int version_major; diff --git a/ginsh/CMakeLists.txt b/ginsh/CMakeLists.txt new file mode 100644 index 00000000..dda2e00c --- /dev/null +++ b/ginsh/CMakeLists.txt @@ -0,0 +1,66 @@ +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../ginac + ${CMAKE_CURRENT_BINARY_DIR}/../ginac + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}) +add_definitions(-DIN_GINAC) + +bison_target(ginsh_parser + ginsh_parser.yy + ${CMAKE_CURRENT_BINARY_DIR}/ginsh_parser.cpp) +flex_target(ginsh_lexer + ginsh_lexer.ll + ${CMAKE_CURRENT_BINARY_DIR}/ginsh_lexer.cpp) +add_flex_bison_dependency(ginsh_lexer ginsh_parser) + +set(ginsh_SOURCES + ginsh_parser.cpp + ginsh_lexer.cpp +) + +set(ginsh_HEADERS + ginsh_parser.h + ginsh.h + ginsh_fcn_help.h + ginsh_op_help.h +) + +set(ginsh_DISTRIB + ${ginsh_SOURCES} + ${ginsh_HEADERS} + ginsh_parser.yy + ginsh_lexer.ll + ginsh.1.in + ginsh_fcn_help.py + ginsh_op_help.py +) +if (READLINE_FOUND) + include_directories(${READLINE_INCLUDE_DIRS}) +endif() + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_fcn_help.h + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_op_help.h + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_parser.h + COMMAND ${CMAKE_COMMAND} -E copy ginsh_parser.hpp ginsh_parser.h + DEPENDS ${BISON_ginsh_parser_OUTPUTS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +set(ginsh_extra_libs) +if (READLINE_FOUND) + set(ginsh_extra_libs ${READLINE_LIBRARIES}) +endif() + +add_executable(ginsh ${ginsh_SOURCES} ${ginsh_HEADERS}) +target_link_libraries(ginsh ginac ${ginsh_extra_libs}) +install(TARGETS ginsh RUNTIME DESTINATION "${BIN_INSTALL_DIR}") diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index eb184b7f..88aa9843 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -36,7 +36,7 @@ #include #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H #include #include #endif @@ -901,7 +901,7 @@ static void ginsh_readline_init(char* name) void greeting(void) { - cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " V" << VERSION << ")" << endl; + cout << "ginsh - GiNaC Interactive Shell (GiNaC V" << GINACLIB_VERSION << ")" << endl; cout << " __, _______ Copyright (C) 1999-2011 Johannes Gutenberg University Mainz,\n" << " (__) * | Germany. This is free software with ABSOLUTELY NO WARRANTY.\n" << " ._) i N a C | You are welcome to redistribute it under certain conditions.\n" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 00000000..8ad8a072 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ginac) +add_definitions(-DIN_GINAC) + +add_executable(viewgar viewgar.cpp) +target_link_libraries(viewgar ginac) +install(TARGETS viewgar RUNTIME DESTINATION "${BIN_INSTALL_DIR}") +