[brlcad-commits] SF.net SVN: brlcad:[41257] brlcad/branches/cmake/src/other/incrTcl/itcl
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2010-11-05 21:08:26
|
Revision: 41257 http://brlcad.svn.sourceforge.net/brlcad/?rev=41257&view=rev Author: starseeker Date: 2010-11-05 21:08:18 +0000 (Fri, 05 Nov 2010) Log Message: ----------- Get closer to a proper itcl build - not there yet, need to compare with a standard itcl build and install. Modified Paths: -------------- brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/CheckSystemFunctionality.cmake brlcad/branches/cmake/src/other/incrTcl/itcl/CMakeLists.txt Added Paths: ----------- brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/tcl.cmake Removed Paths: ------------- brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/test_sources/ Modified: brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/CheckSystemFunctionality.cmake =================================================================== --- brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/CheckSystemFunctionality.cmake 2010-11-05 20:18:39 UTC (rev 41256) +++ brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/CheckSystemFunctionality.cmake 2010-11-05 21:08:18 UTC (rev 41257) @@ -1,21 +1,44 @@ -# CMake does not by default include functionality similar to autoheader in -# GNU Autotools, but is it not difficult to reproduce. There are two aspects -# to these tests - the first being the generation of a header file defining -# variables, and the second being the running of various custom tests to establish -# whether features actually work on a given platform. The first step is handled -# by creating wrapper macros for the standard CMake functions that also write -# to a CONFIG_H_FILE if it is defined, with a couple extra conveniences. The second -# and more labor intensive step is to create tests using the CMake functions -# that reproduce the functionality tests expected by source code using variables -# defined by Autotools tests. This file does not have all such tests, for each project -# has its own requirements and many thousands of these tests can be devised. The macro -# collection below covers the requirements of the projects that have thus far been -# converted to use this particular compilation mechanism, and will be added to as -# needed. +# Checking compiler flags benefits from some macro logic +INCLUDE(CheckCCompilerFlag) -# Automate putting variables from tests into a config.h.in file, +MACRO(CHECK_C_FLAG flag) + STRING(TOUPPER ${flag} UPPER_FLAG) + STRING(REGEX REPLACE " " "_" UPPER_FLAG ${UPPER_FLAG}) + STRING(REGEX REPLACE "=" "_" UPPER_FLAG ${UPPER_FLAG}) + IF(${ARGC} LESS 2) + CHECK_C_COMPILER_FLAG(-${flag} ${UPPER_FLAG}_COMPILER_FLAG) + ELSE(${ARGC} LESS 2) + IF(NOT ${ARGV1}) + CHECK_C_COMPILER_FLAG(-${flag} ${UPPER_FLAG}_COMPILER_FLAG) + IF(${UPPER_FLAG}_COMPILER_FLAG) + MESSAGE("- Found ${ARGV1} - setting to -${flag}") + SET(${ARGV1} "-${flag}" CACHE STRING "${ARGV1}" FORCE) + ENDIF(${UPPER_FLAG}_COMPILER_FLAG) + ENDIF(NOT ${ARGV1}) + ENDIF(${ARGC} LESS 2) + IF(${UPPER_FLAG}_COMPILER_FLAG) + SET(${UPPER_FLAG}_COMPILER_FLAG "-${flag}") + ENDIF(${UPPER_FLAG}_COMPILER_FLAG) +ENDMACRO() + +MACRO(CHECK_C_FLAG_GATHER flag FLAGS) + STRING(TOUPPER ${flag} UPPER_FLAG) + STRING(REGEX REPLACE " " "_" UPPER_FLAG ${UPPER_FLAG}) + CHECK_C_COMPILER_FLAG(-${flag} ${UPPER_FLAG}_COMPILER_FLAG) + IF(${UPPER_FLAG}_COMPILER_FLAG) + SET(${FLAGS} "${${FLAGS}} -${flag}") + ENDIF(${UPPER_FLAG}_COMPILER_FLAG) +ENDMACRO() + + +# Automate putting variables from tests into CFLAGS, # and otherwise wrap check macros in extra logic as needed +# These functions will do either of two jobs - if a +# CONFIG_H_FILE is defined, they will append cmakedefine +# (or occasionally straight define) statements to that file. +# If a CONFIG_CFLAGS variable is defined, they will append +# an appropriate definition to that variable. INCLUDE(CheckFunctionExists) INCLUDE(CheckIncludeFile) @@ -27,22 +50,32 @@ INCLUDE(CheckCSourceCompiles) INCLUDE(ResolveCompilerPaths) -MACRO(CHECK_FUNCTION_EXISTS_H function var) - CHECK_FUNCTION_EXISTS(${function} ${var}) - if(CONFIG_H_FILE AND ${var}) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") - endif(CONFIG_H_FILE AND ${var}) -ENDMACRO(CHECK_FUNCTION_EXISTS_H) +MACRO(CONFIG_CHECK_FUNCTION_EXISTS function var) + CHECK_FUNCTION_EXISTS(${function} ${var}) + IF(${var}) + IF(CONFIG_H_FILE) + FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") + ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -D${var}=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) + ENDIF(${var}) +ENDMACRO(CONFIG_CHECK_FUNCTION_EXISTS) -MACRO(CHECK_INCLUDE_FILE_H filename var) - CHECK_INCLUDE_FILE(${filename} ${var}) - if(CONFIG_H_FILE AND ${var}) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") - endif(CONFIG_H_FILE AND ${var}) -ENDMACRO(CHECK_INCLUDE_FILE_H) +MACRO(CONFIG_CHECK_INCLUDE_FILE filename var) + CHECK_INCLUDE_FILE(${filename} ${var}) + IF(${var}) + IF(CONFIG_H_FILE) + FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") + ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -D${var}=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) + ENDIF(${var}) +ENDMACRO(CONFIG_CHECK_INCLUDE_FILE) -MACRO(CHECK_INCLUDE_FILE_USABILITY_H filename var) - CHECK_INCLUDE_FILE_H(${filename} HAVE_${var}) +MACRO(CONFIG_CHECK_INCLUDE_FILE_USABILITY filename var) + CHECK_INCLUDE_FILE(${filename} HAVE_${var}) IF(HAVE_${var}) SET(HEADER_SRC " #include <${filename}> @@ -54,226 +87,62 @@ IF(CONFIG_H_FILE) FILE(APPEND ${CONFIG_H_FILE} "#define NO_${var} 1\n") ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -DNO_${var}=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) ENDIF(NOT HAVE_${var} OR NOT ${var}_USABLE) -ENDMACRO(CHECK_INCLUDE_FILE_USABILITY_H filename var) +ENDMACRO(CONFIG_CHECK_INCLUDE_FILE_USABILITY filename var) -MACRO(CHECK_INCLUDE_FILE_CXX_H filename var) - CHECK_INCLUDE_FILE_CXX(${filename} ${var}) - if(CONFIG_H_FILE AND ${var}) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") - endif(CONFIG_H_FILE AND ${var}) -ENDMACRO(CHECK_INCLUDE_FILE_CXX_H) +MACRO(CONFIG_CHECK_INCLUDE_FILE_CXX filename var) + CHECK_INCLUDE_FILE_CXX(${filename} ${var}) + IF(${var}) + IF(CONFIG_H_FILE) + FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ${var} 1\n") + ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -D${var}=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) + ENDIF(${var}) +ENDMACRO(CONFIG_CHECK_INCLUDE_FILE_CXX) -MACRO(CHECK_TYPE_SIZE_H typename var) +MACRO(CONFIG_CHECK_TYPE_SIZE typename var) FOREACH(arg ${ARGN}) SET(headers ${headers} ${arg}) ENDFOREACH(arg ${ARGN}) SET(CHECK_EXTRA_INCLUDE_FILES ${headers}) CHECK_TYPE_SIZE(${typename} HAVE_${var}_T) SET(CHECK_EXTRA_INCLUDE_FILES) - if(CONFIG_H_FILE AND HAVE_${var}_T) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_${var}_T 1\n") - FILE(APPEND ${CONFIG_H_FILE} "#define SIZEOF_${var} ${HAVE_${var}_T}\n") - endif(CONFIG_H_FILE AND HAVE_${var}_T) -ENDMACRO(CHECK_TYPE_SIZE_H) + IF(HAVE_${var}_T) + IF(CONFIG_H_FILE) + FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_${var}_T 1\n") + FILE(APPEND ${CONFIG_H_FILE} "#define SIZEOF_${var} ${HAVE_${var}_T}\n") + ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -DHAVE_${var}_T=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -DSIZEOF${var}=${HAVE_${var}_T}" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) + ENDIF(HAVE_${var}_T) +ENDMACRO(CONFIG_CHECK_TYPE_SIZE) -MACRO(CHECK_STRUCT_HAS_MEMBER_H structname member header var) +MACRO(CONFIG_CHECK_STRUCT_HAS_MEMBER structname member header var) CHECK_STRUCT_HAS_MEMBER(${structname} ${member} ${header} HAVE_${var}) - if(CONFIG_H_FILE AND HAVE_${var}) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_${var} 1\n") - endif(CONFIG_H_FILE AND HAVE_${var}) -ENDMACRO(CHECK_STRUCT_HAS_MEMBER_H) + IF(HAVE_${var}) + IF(CONFIG_H_FILE) + FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_${var} 1\n") + ENDIF(CONFIG_H_FILE) + IF(CONFIG_CFLAGS) + SET(${CONFIG_CFLAGS} "${${CONFIG_CFLAGS}} -DHAVE_${var}=1" CACHE STRING "${CONFIG_CFLAGS}" FORCE) + ENDIF(CONFIG_CFLAGS) + ENDIF(HAVE_${var}) +ENDMACRO(CONFIG_CHECK_STRUCT_HAS_MEMBER) -MACRO(CHECK_LIBRARY targetname lname func) +MACRO(CONFIG_CHECK_LIBRARY targetname lname func) IF(NOT ${targetname}_LIBRARY) CHECK_LIBRARY_EXISTS(${lname} ${func} "" HAVE_${targetname}_${lname}) IF(HAVE_${targetname}_${lname}) - RESOLVE_LIBRARIES (${targetname}_LIBRARY "-l${lname}") + RESOLVE_LIBRARIES(${targetname}_LIBRARY "-l${lname}") SET(${targetname}_LINKOPT "-l${lname}") ENDIF(HAVE_${targetname}_${lname}) ENDIF(NOT ${targetname}_LIBRARY) -ENDMACRO(CHECK_LIBRARY lname func) +ENDMACRO(CONFIG_CHECK_LIBRARY lname func) -# Functionality testing macros - these also assume a CONFIG_H file. In some -# cases the minimal test code can be included in-line, but in others the problem -# of quoting it correctly becomes rather involved. In those cases, rather than -# complicate the maintainance of the test, the code itself is stored in a file. -# These files need to be present in a directory called test_sources, in one of -# the directories in the CMAKE_MODULE_PATH variable. The first step is to -# locate such a directory. - -SET(CMAKE_TEST_SRCS_DIR "NOTFOUND") -FOREACH($candidate_dir ${CMAKE_MODULE_PATH}) - IF(NOT CMAKE_TEST_SRCS_DIR) - IF(EXISTS "${candidate_dir}/test_sources" AND IS_DIRECTORY "${candidate_dir}/test_sources") - SET(CMAKE_TEST_SRCS_DIR ${candidate_dir}/test_sources) - ENDIF(EXISTS "${candidate_dir}/test_sources" AND IS_DIRECTORY "${candidate_dir}/test_sources") - ENDIF(NOT CMAKE_TEST_SRCS_DIR) -ENDFOREACH($candidate_dir ${CMAKE_MODULE_PATH}) - -INCLUDE(CheckPrototypeExists) -INCLUDE(CheckCSourceRuns) -INCLUDE(CheckCFileRuns) - -MACRO(CHECK_BASENAME) - SET(BASENAME_SRC " - #include <libgen.h> - int main(int argc, char *argv[]) { - (void)basename(argv[0]); - return 0; - }") - CHECK_C_SOURCE_RUNS("${BASENAME_SRC}" HAVE_BASENAME) - IF(HAVE_BASENAME) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_BASENAME 1\n") - ENDIF(HAVE_BASENAME) -ENDMACRO(CHECK_BASENAME var) - -MACRO(CHECK_DIRNAME) - SET(DIRNAME_SRC " - #include <libgen.h> - int main(int argc, char *argv[]) { - (void)dirname(argv[0]); - return 0; - }") - CHECK_C_SOURCE_RUNS("${DIRNAME_SRC}" HAVE_DIRNAME) - IF(HAVE_DIRNAME) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_DIRNAME 1\n") - ENDIF(HAVE_DIRNAME) -ENDMACRO(CHECK_DIRNAME var) - -# Based on AC_HEADER_STDC - using the source code for ctype -# checking found in the generated configure file -MACRO(CMAKE_HEADER_STDC) - CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_STDLIB_H 1\n") - CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H) - CHECK_INCLUDE_FILE(string.h HAVE_STRING_H) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_STRING_H 1\n") - CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H) - FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_STRINGS_H 1\n") - CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H) - CHECK_PROTOTYPE_EXISTS(memchr string.h HAVE_STRING_H_MEMCHR) - CHECK_PROTOTYPE_EXISTS(free stdlib.h HAVE_STDLIB_H_FREE) - CHECK_C_FILE_RUNS(${CMAKE_TEST_SRCS_DIR}/ctypes_test.c WORKING_CTYPE_MACROS) - IF(HAVE_STDLIB_H AND HAVE_STDARG_H AND HAVE_STRING_H AND HAVE_FLOAT_H AND WORKING_CTYPE_MACROS) - FILE(APPEND ${CONFIG_H_FILE} "#define STDC_HEADERS 1\n") - ENDIF(HAVE_STDLIB_H AND HAVE_STDARG_H AND HAVE_STRING_H AND HAVE_FLOAT_H AND WORKING_CTYPE_MACROS) -ENDMACRO(CMAKE_HEADER_STDC) - -# Based on AC_HEADER_SYS_WAIT -MACRO(CMAKE_HEADER_SYS_WAIT) - CHECK_C_FILE_RUNS(${CMAKE_TEST_SRCS_DIR}/sys_wait_test.c WORKING_SYS_WAIT) - IF(WORKING_SYS_WAIT) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_SYS_WAIT_H 1\n") - ENDIF(WORKING_SYS_WAIT) -ENDMACRO(CMAKE_HEADER_SYS_WAIT) - -# Based on AC_FUNC_ALLOCA -MACRO(CMAKE_ALLOCA) - CHECK_C_FILE_RUNS(${CMAKE_TEST_SRCS_DIR}/alloca_header_test.c WORKING_ALLOCA_H) - IF(WORKING_ALLOCA_H) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_ALLOCA_H 1\n") - SET(FILE_RUN_DEFINITIONS "-DHAVE_ALLOCA_H") - ENDIF(WORKING_ALLOCA_H) - CHECK_C_FILE_RUNS(${CMAKE_TEST_SRCS_DIR}/alloca_test.c WORKING_ALLOCA) - IF(WORKING_ALLOCA) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_ALLOCA 1\n") - ENDIF(WORKING_ALLOCA) -ENDMACRO(CMAKE_ALLOCA) - -MACRO(CHECK_COMPILER_SUPPORTS_HIDDEN) - SET(TEST_SRC" - #define MODULE_SCOPE extern __attribute__((__visibility__("hidden"))) - main(){}; - ") - CHECK_C_SOURCE_COMPILES("${TEST_SRC}" COMPILER_SUPPORTS_HIDDEN) -ENDMACRO(CHECK_COMPILER_SUPPORTS_HIDDEN) - -MACRO(CHECK_GETADDERINFO_WORKING) - SET(GETADDERINFO_SRC " - #include <netdb.h> - int main () { - const char *name, *port; - struct addrinfo *aiPtr, hints; - (void)getaddrinfo(name,port, &hints, &aiPtr); - (void)freeaddrinfo(aiPtr); - return 0; - }") - CHECK_C_SOURCE_COMPILES("${GETADDERINFO_SRC}" WORKING_GETADDERINFO) - IF(WORKING_GETADDERINFO) - FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_GETADDERINFO 1\n") - ENDIF(WORKING_GETADDERINFO) -ENDMACRO(CHECK_GETADDERINFO_WORKING) - - -MACRO(TERMIOS_TERMIO_SGTTY) - SET(TERMIOS_SRC " - #include <termios.h> - int main() { - struct termios t; - if (tcgetattr(0, &t) == 0) { - cfsetospeed(&t, 0); - t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; - } - ") - SET(TERMIO_SRC " - #include <termio.h> - int main() { - struct termio t; - if (ioctl(0, TCGETA, &t) == 0) { - t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; - } - ") - SET(SGTTY_SRC " - #include <sgtty.h> - int main() { - struct sgttyb t; - if (ioctl(0, TIOCGETP, &t) == 0) { - t.sg_ospeed = 0; - t.sg_flags |= ODDP | EVENP | RAW; - return 0; - } - return 1; - } - ") - CHECK_C_SOURCE_RUNS("${TERMIOS_SRC}" HAVE_TERMIOS) - IF(NOT HAVE_TERMIOS) - CHECK_C_SOURCE_RUNS("${TERMIO_SRC}" HAVE_TERMIO) - ENDIF(NOT HAVE_TERMIOS) - IF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) - CHECK_C_SOURCE_RUNS("${SGTTY_SRC}" HAVE_SGTTY) - ENDIF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) -ENDMACRO(TERMIOS_TERMIO_SGTTY) - -MACRO(CHECK_FD_SET_IN_TYPES_H) - SET(TEST_SRC " - #include <sys/types.h> - int main () - { - fd_set readMask, writeMask; - return 0; - } - ") - CHECK_C_SOURCE_COMPILES("${TEST_SRC}" FD_SET_IN_TYPES_H) -ENDMACRO(CHECK_FD_SET_IN_TYPES_H) - -MACRO(CHECK_TIME_AND_SYS_TIME) - SET(TEST_SRC " - #include <sys/types.h> - #include <sys/time.h> - #include <time.h> - int main() { - if ((struct tm *) 0) - return 0; - return 0; - } - ") - CHECK_C_SOURCE_COMPILES("${TEST_SRC}" TIME_AND_SYS_TIME) -ENDMACRO(CHECK_TIME_AND_SYS_TIME) - Added: brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/tcl.cmake =================================================================== --- brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/tcl.cmake (rev 0) +++ brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/tcl.cmake 2010-11-05 21:08:18 UTC (rev 41257) @@ -0,0 +1,818 @@ +# CMake version of the tcl.m4 logic, insofar as it maps to CMake and has been +# needed. + +INCLUDE(CheckCCompilerFlag) +INCLUDE(CheckFunctionExists) +INCLUDE(CheckIncludeFile) +INCLUDE(CheckIncludeFiles) +INCLUDE(CheckIncludeFileCXX) +INCLUDE(CheckTypeSize) +INCLUDE(CheckLibraryExists) +INCLUDE(CheckStructHasMember) +INCLUDE(CheckCSourceCompiles) +INCLUDE(ResolveCompilerPaths) +INCLUDE(CheckPrototypeExists) +INCLUDE(CheckCSourceRuns) +INCLUDE(CheckCFileRuns) + +INCLUDE(ac_std_funcs) + +MACRO(ADD_TCL_CFLAG TCL_CFLAG) + SET(TCL_CFLAGS "${TCL_CFLAGS} -D${TCL_CFLAG}=1" CACHE STRING "TCL CFLAGS" FORCE) +ENDMACRO(ADD_TCL_CFLAG) + +# Note - for these path and load functions, should move the FindTCL.cmake +# logic that applies to here + +#------------------------------------------------------------------------ +# SC_PATH_TCLCONFIG +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_PATH_TKCONFIG +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_LOAD_TCLCONFIG +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_LOAD_TKCONFIG +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_PROG_TCLSH +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_BUILD_TCLSH +#------------------------------------------------------------------------ + +# TODO + +#------------------------------------------------------------------------ +# SC_ENABLE_SHARED +#------------------------------------------------------------------------ + +# This will probably be handled by CMake variables rather than a +# specific SC command + +#------------------------------------------------------------------------ +# SC_ENABLE_FRAMEWORK +#------------------------------------------------------------------------ + +# Not immediately clear how this will work in CMake + + +#------------------------------------------------------------------------ +# SC_ENABLE_THREADS +#------------------------------------------------------------------------ +MACRO(SC_ENABLE_THREADS) + OPTION(TCL_THREADS "Enable Tcl Thread support" ON) + IF(TCL_THREADS) + ADD_TCL_CFLAG(TCL_THREADS) + ADD_TCL_CFLAG(USE_THREAD_ALLOC) + ADD_TCL_CFLAG(_REENTRANT) + ADD_TCL_CFLAG(_THREAD_SAFE) + IF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") + ADD_TCL_CFLAG(_POSIX_PTHREAD_SEMANTICS) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") + FIND_PACKAGE(Threads) + CHECK_FUNCTION_EXISTS(pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE) + IF(HAVE_PTHREAD_ATTR_SETSTACKSIZE) + ADD_TCL_CFLAG(HAVE_PTHREAD_ATTR_SETSTACKSIZE) + ENDIF(HAVE_PTHREAD_ATTR_SETSTACKSIZE) + CHECK_FUNCTION_EXISTS(pthread_attr_get_np HAVE_PTHREAD_ATTR_GET_NP) + CHECK_FUNCTION_EXISTS(pthread_getattr_np HAVE_PTHREAD_GETATTR_NP) + IF(HAVE_PTHREAD_ATTR_GET_NP) + ADD_TCL_CFLAG(HAVE_PTHREAD_ATTR_GET_NP) + ELSEIF(HAVE_PTHREAD_GETATTR_NP) + ADD_TCL_CFLAG(HAVE_PTHREAD_GETATTR_NP) + ENDIF(HAVE_PTHREAD_ATTR_GET_NP) + IF(NOT HAVE_PTHREAD_ATTR_GET_NP AND NOT HAVE_PTHREAD_GETATTR_NP) + CHECK_FUNCTION_EXISTS(pthread_get_stacksize_np HAVE_PTHREAD_GET_STACKSIZE_NP) + IF(HAVE_PTHREAD_GET_STACKSIZE_NP) + ADD_TCL_CFLAG(HAVE_PTHREAD_GET_STACKSIZE_NP) + ENDIF(HAVE_PTHREAD_GET_STACKSIZE_NP) + ENDIF(NOT HAVE_PTHREAD_ATTR_GET_NP AND NOT HAVE_PTHREAD_GETATTR_NP) + ENDIF(TCL_THREADS) +ENDMACRO(SC_ENABLE_THREADS) + +#------------------------------------------------------------------------ +# SC_ENABLE_SYMBOLS +#------------------------------------------------------------------------ + +# TODO - this may be replaced by other CMake mechanisms + +#------------------------------------------------------------------------ +# SC_ENABLE_LANGINFO +#------------------------------------------------------------------------ +MACRO(SC_ENABLE_LANGINFO) + OPTION(ENABLE_LANGINFO "Trigger use of nl_langinfo if available." ON) + IF(ENABLE_LANGINFO) + CHECK_INCLUDE_FILE(langinfo.h HAVE_LANGINFO) + IF(HAVE_LANGINFO) + SET(LANGINFO_SRC " + #include <langinfo.h> + int main() { + nl_langinfo(CODESET); + } + ") + CHECK_C_SOURCE_COMPILES("${LANGINFO_SRC}" LANGINFO_COMPILES) + IF(LANGINFO_COMPILES) + ADD_TCL_CFLAG(HAVE_LANGINFO) + ELSE(LANGINFO_COMPILES) + SET(ENABLE_LANGINFO OFF CACHE STRING "Langinfo off" FORCE) + ENDIF(LANGINFO_COMPILES) + ELSE(HAVE_LANGINFO) + SET(ENABLE_LANGINFO OFF CACHE STRING "Langinfo off" FORCE) + ENDIF(HAVE_LANGINFO) + ENDIF(ENABLE_LANGINFO) +ENDMACRO(SC_ENABLE_LANGINFO) + +#-------------------------------------------------------------------- +# SC_CONFIG_MANPAGES +#-------------------------------------------------------------------- + +# TODO + +#-------------------------------------------------------------------- +# SC_CONFIG_SYSTEM +#-------------------------------------------------------------------- + +# Replaced by CMake functionality + + +#-------------------------------------------------------------------- +# SC_CONFIG_CFLAGS +#-------------------------------------------------------------------- + +# TODO - many of these are either automatically handled or handled +# elsewhere, but should still handle what we need to + +#-------------------------------------------------------------------- +# SC_SERIAL_PORT +#-------------------------------------------------------------------- +MACRO(SC_SERIAL_PORT) + SET(TERMIOS_SRC_1 " +#include <termios.h> +int main() { +struct termios t; +if (tcgetattr(0, &t) == 0) { + cfsetospeed(&t, 0); + t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; + return 0; +} + return 1; +} + ") + SET(TERMIOS_SRC_2 " +#include <termios.h> +#include <errno.h> + +int main() { +struct termios t; +if (tcgetattr(0, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + cfsetospeed(&t, 0); + t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; +} + ") + SET(TERMIO_SRC_1 " +#include <termio.h> +int main() { +struct termio t; +if (ioctl(0, TCGETA, &t) == 0) { + t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; + return 0; +} + return 1; +} + ") + SET(TERMIO_SRC_2 " +#include <termio.h> +#include <errno.h> + +int main() { +struct termio t; +if (ioctl(0, TCGETA, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; + return 0; + } + return 1; +} + ") + SET(SGTTY_SRC_1 " +#include <sgtty.h> +int main() { +struct sgttyb t; +if (ioctl(0, TIOCGETP, &t) == 0) { + t.sg_ospeed = 0; + t.sg_flags |= ODDP | EVENP | RAW; + return 0; +} + return 1; +} + ") + SET(SGTTY_SRC_2 " +#include <sgtty.h> +#include <errno.h> + +int main() { +struct sgttyb t; +if (ioctl(0, TIOCGETP, &t) == 0 + || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { + t.sg_ospeed = 0; + t.sg_flags |= ODDP | EVENP | RAW; + return 0; + } + return 1; +} + ") + CHECK_C_SOURCE_RUNS("${TERMIOS_SRC_1}" HAVE_TERMIOS) + IF(NOT HAVE_TERMIOS) + CHECK_C_SOURCE_RUNS("${TERMIO_SRC_1}" HAVE_TERMIO) + ENDIF(NOT HAVE_TERMIOS) + IF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) + CHECK_C_SOURCE_RUNS("${SGTTY_SRC_1}" HAVE_SGTTY) + ENDIF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) + IF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS AND NOT HAVE_SGTTY) + CHECK_C_SOURCE_RUNS("${TERMIOS_SRC_2}" HAVE_TERMIOS) + IF(NOT HAVE_TERMIOS) + CHECK_C_SOURCE_RUNS("${TERMIO_SRC_2}" HAVE_TERMIO) + ENDIF(NOT HAVE_TERMIOS) + IF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) + CHECK_C_SOURCE_RUNS("${SGTTY_SRC_2}" HAVE_SGTTY) + ENDIF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS) + ENDIF(NOT HAVE_TERMIO AND NOT HAVE_TERMIOS AND NOT HAVE_SGTTY) + + IF(HAVE_TERMIOS) + ADD_TCL_CFLAG(USE_TERMIOS) + ELSE(HAVE_TERMIOS) + IF(HAVE_TERMIO) + ADD_TCL_CFLAG(USE_TERMIO) + ELSE(HAVE_TERMIO) + IF(HAVE_SGTTY) + ADD_TCL_CFLAG(USE_SGTTY) + ENDIF(HAVE_SGTTY) + ENDIF(HAVE_TERMIO) + ENDIF(HAVE_TERMIOS) +ENDMACRO(SC_SERIAL_PORT) + + +#-------------------------------------------------------------------- +# SC_MISSING_POSIX_HEADERS +#-------------------------------------------------------------------- +MACRO(SC_MISSING_POSIX_HEADERS) + CONFIG_CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) + IF(NOT HAVE_DIRENT_H) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_DIRENT_H=1") + ENDIF(NOT HAVE_DIRENT_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(float.h FLOAT_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(values.h VALUES_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(limits.h LIMITS_H) + CONFIG_CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H) + CONFIG_CHECK_INCLUDE_FILE(string.h HAVE_STRING_H) + IF(NOT HAVE_STRING_H) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_STRING_H=1") + ENDIF(NOT HAVE_STRING_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(sys/wait.h SYS_WAIT_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(dlfcn.h DLFCN_H) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(sys/param.h SYS_PARAM_H) +ENDMACRO(SC_MISSING_POSIX_HEADERS) + + +#-------------------------------------------------------------------- +# SC_PATH_X +#-------------------------------------------------------------------- + +# Replaced by CMake's FindX11 + +#-------------------------------------------------------------------- +# SC_BLOCKING_STYLE +#-------------------------------------------------------------------- +CONFIG_CHECK_INCLUDE_FILE(sys/ioctl.h HAVE_SYS_IOCTL_H) +CONFIG_CHECK_INCLUDE_FILE(sys/filio.h HAVE_SYS_FILIO_H) +IF(${CMAKE_SYSTEM_NAME} MATCHES "^OSF.*") + ADD_TCL_CFLAG(USE_FIONBIO) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^OSF.*") +IF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") + STRING(REGEX REPLACE "\\..*" "" CMAKE_SYSTEM_MAJOR_VERSION ${CMAKE_SYSTEM_VERSION}) + IF (${CMAKE_SYSTEM_MAJOR_VERSION} LESS 5) + ADD_TCL_CFLAG(USE_FIONBIO) + ENDIF (${CMAKE_SYSTEM_MAJOR_VERSION} LESS 5) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") + +#-------------------------------------------------------------------- +# SC_TIME_HANLDER +# +# The TEA version of this macro calls AC_HEADER_TIME, but Autotools +# docs list it as obsolete. +# +# TODO - tzname testing from AC_STRUCT_TIMEZONE is incomplete +# +#-------------------------------------------------------------------- +MACRO(SC_TIME_HANDLER) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(sys/time.h SYS_TIME_H) + CONFIG_CHECK_STRUCT_HAS_MEMBER("struct tm" tm_zone time.h STRUCT_TM_TM_ZONE) + IF(HAVE_STRUCT_TM_TM_ZONE) + ADD_TCL_CFLAG(HAVE_TM_ZONE) + ELSE(HAVE_STRUCT_TM_TM_ZONE) + SET(TZNAME_SRC " +#include <time.h> +int main () { +#ifndef tzname + (void) tzname; +#endif +return 0; +}") + CHECK_C_SOURCE_COMPILES("${TZNAME_SRC}" HAVE_TZNAME) + IF(HAVE_TZNAME) + ADD_TCL_CFLAG(HAVE_DECL_TZNAME) + ENDIF(HAVE_TZNAME) + ENDIF(HAVE_STRUCT_TM_TM_ZONE) + CONFIG_CHECK_FUNCTION_EXISTS(gmtime_r HAVE_GMTIME_R) + CONFIG_CHECK_FUNCTION_EXISTS(localtime_r HAVE_LOCALTIME_R) + CONFIG_CHECK_FUNCTION_EXISTS(mktime HAVE_MKTIME) + CONFIG_CHECK_STRUCT_HAS_MEMBER("struct tm" tm_tzadj time.h TM_TZADJ) + CONFIG_CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff time.h TM_GMTOFF) + SET(TZONE_SRC_1 " +#include <time.h> +int main () { +extern long timezone; +timezone += 1; +exit (0); +return 0; +} + ") + CHECK_C_SOURCE_COMPILES("${TZONE_SRC_1}" HAVE_TIMEZONE_VAR) + IF(HAVE_TIMEZONE_VAR) + ADD_TCL_CFLAG(HAVE_TIMEZONE_VAR) + ELSE(HAVE_TIMEZONE_VAR) + SET(TZONE_SRC_2 " +#include <time.h> +int main() { +extern time_t timezone; +timezone += 1; +exit (0); +return 0; +} + ") + CHECK_C_SOURCE_COMPILES("${TZONE_SRC_2}" HAVE_TIMEZONE_VAR) + IF(HAVE_TIMEZONE_VAR) + ADD_TCL_CFLAG(HAVE_TIMEZONE_VAR) + ENDIF(HAVE_TIMEZONE_VAR) + ENDIF(HAVE_TIMEZONE_VAR) +ENDMACRO(SC_TIME_HANDLER) + +#-------------------------------------------------------------------- +# SC_BUGGY_STRTOD +#-------------------------------------------------------------------- + +# TODO + + +#-------------------------------------------------------------------- +# SC_TCL_LINK_LIBS +#-------------------------------------------------------------------- +MACRO(SC_TCL_LINK_LIBS) + SET(TCL_LINK_LIBS "") + CHECK_FUNCTION_EXISTS(sin, HAVE_MATHLIB) + IF(NOT HAVE_MATHLIB) + CONFIG_CHECK_LIBRARY(M m sin) + ENDIF(NOT HAVE_MATHLIB) + IF(NOT IEEE_LIBRARY AND NOT IEEE_QUIET) + MESSAGE("-- Looking for IEEE library") + RESOLVE_LIBRARIES(IEEE_LIBRARY "-lieee") + IF(IEEE_LIBRARY) + MESSAGE("-- Found IEEE library: ${IEEE_LIBRARY}") + ELSE(IEEE_LIBRARY) + MESSAGE("-- Looking for IEEE library - not found") + ENDIF(IEEE_LIBRARY) + SET(IEEE_QUIET 1 CACHE STRING "IEEE quiet") + ENDIF(NOT IEEE_LIBRARY AND NOT IEEE_QUIET) + IF(NOT INET_LIBRARY AND NOT INET_QUIET) + MESSAGE("-- Looking for INET library") + RESOLVE_LIBRARIES(INET_LIBRARY "-linet") + IF(INET_LIBRARY) + MESSAGE("-- Found INET library: ${INET_LIBRARY}") + ELSE(INET_LIBRARY) + MESSAGE("-- Looking for INET library - not found") + ENDIF(INET_LIBRARY) + SET(INET_QUIET 1 CACHE STRING "INET quiet") + ENDIF(NOT INET_LIBRARY AND NOT INET_QUIET) + + SET(TCL_LINK_LIBS ${TCL_LINK_LIBS} ${IEEE_LIBRARY} ${M_LIBRARY} ${INET_LIBRARY} CACHE STRING "TCL CFLAGS" FORCE) + + CONFIG_CHECK_INCLUDE_FILE_USABILITY(net/errno.h NET_ERRNO_H) + CHECK_FUNCTION_EXISTS(connect HAVE_CONNECT) + IF(NOT HAVE_CONNECT) + CHECK_FUNCTION_EXISTS(setsockopt HAVE_SETSOCKOPT) + IF(NOT HAVE_SETSOCKOPT) + CONFIG_CHECK_LIBRARY(SOCKET socket setsocket) + SET(TCL_LINK_LIBS ${TCL_LINK_LIBS} ${SOCKET_LIBRARY} CACHE STRING "TCL CFLAGS" FORCE) + ENDIF(NOT HAVE_SETSOCKOPT) + ENDIF(NOT HAVE_CONNECT) + CHECK_FUNCTION_EXISTS(gethostbyname HAVE_GETHOSTBYNAME) + IF(NOT HAVE_GETHOSTBYNAME) + CONFIG_CHECK_LIBRARY(NLS nls gethostbyname) + SET(TCL_LINK_LIBS ${TCL_LINK_LIBS} ${NLS_LIBRARY} CACHE STRING "TCL CFLAGS" FORCE) + ENDIF(NOT HAVE_GETHOSTBYNAME) + +ENDMACRO(SC_TCL_LINK_LIBS) + +#-------------------------------------------------------------------- +# SC_TCL_EARLY_FLAGS +#-------------------------------------------------------------------- + +# TODO - needed at all for CMake? + +#-------------------------------------------------------------------- +# SC_TCL_64BIT_FLAGS +# +# Detect and set up 64 bit compiling here. LOTS of TODO here +#-------------------------------------------------------------------- +MACRO(SC_TCL_64BIT_FLAGS) + OPTION(ENABLE_64_BIT "64 bit void pointer" ON) + IF(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$" AND ENABLE_64_BIT) + IF(ENABLE_64_BIT) + IF(NOT 64BIT_FLAG) + MESSAGE("Checking for 64-bit support:") + CHECK_C_FLAG("arch x86_64" 64BIT_FLAG) + CHECK_C_FLAG(64 64BIT_FLAG) + CHECK_C_FLAG("mabi=64" 64BIT_FLAG) + CHECK_C_FLAG(m64 64BIT_FLAG) + CHECK_C_FLAG(q64 64BIT_FLAG) + ENDIF(NOT 64BIT_FLAG) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${64BIT_FLAG}" CACHE STRING "CMake CFLAGS" FORCE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${64BIT_FLAG}" CACHE STRING "CMake CXXFLAGS" FORCE) + ENDIF(ENABLE_64_BIT) + ELSE(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$" AND ENABLE_64_BIT) + SET(ENABLE_64_BIT OFF) + ENDIF(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$" AND ENABLE_64_BIT) +ENDMACRO(SC_TCL_64BIT_FLAGS) + +#-------------------------------------------------------------------- +# SC_TCL_CFG_ENCODING TIP #59 +#-------------------------------------------------------------------- +MACRO(SC_TCL_CFG_ENCODING) + IF(NOT TCL_CFGVAL_ENCODING) + SET(TCL_CFGVAL_ENCODING "iso8859-1") + ENDIF(NOT TCL_CFGVAL_ENCODING) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DTCL_CFGVAL_ENCODING=\\\"${TCL_CFGVAL_ENCODING}\\\"" CACHE STRING "TCL CFLAGS" FORCE) +ENDMACRO(SC_TCL_CFG_ENCODING) + + +#-------------------------------------------------------------------- +# SC_TCL_CHECK_BROKEN_FUNC +#-------------------------------------------------------------------- +MACRO(SC_TCL_CHECK_BROKEN_FUNC) + CHECK_FUNCTION_EXISTS(${ARGV0} HAVE_${ARGV0}) + IF(HAVE_${ARGV0}) + SET(COMPILE_SRC " + int main() { + ${ARGV1} + }") + CHECK_C_SOURCE_RUNS("${COMPILE_SRC}" WORKING_${ARGV0}) + IF(NOT WORKING_${ARGV0}) + SET(COMPAT_SRCS ${COMPAT_SRCS} compat/${ARGV0}.c CACHE STRING "Compatibility srcs" FORCE) + ENDIF(NOT WORKING_${ARGV0}) + ELSE(HAVE_${ARGV0}) + SET(COMPAT_SRCS ${COMPAT_SRCS} compat/${ARGV0}.c CACHE STRING "Compatibility srcs" FORCE) + ENDIF(HAVE_${ARGV0}) +ENDMACRO(SC_TCL_CHECK_BROKEN_FUNC) + +#-------------------------------------------------------------------- +# SC_TCL_GETHOSTBYADDR_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETHOSTBYADDR_R) + CONFIG_CHECK_FUNCTION_EXISTS(gethostbyaddr_r HAVE_GETHOSTBYADDR_R) + IF(HAVE_GETHOSTBYADDR_R) + SET(HAVE_GETHOSTBYADDR_R_7_SRC " +#include <netdb.h> +int main(){ +char *addr; +int length; +int type; +struct hostent *result; +char buffer[2048]; +int buflen = 2048; +int h_errnop; + +(void) gethostbyaddr_r(addr, length, type, result, buffer, buflen, &h_errnop); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETHOSTBYADDR_R_7_SRC}" HAVE_GETHOSTBYADDR_R_7) + IF(HAVE_GETHOSTBYADDR_R_7) + ADD_TCL_CFLAG(HAVE_GETHOSTBYADDR_R_7) + ELSE(HAVE_GETHOSTBYADDR_R_7) + SET(HAVE_GETHOSTBYADDR_R_8_SRC " +#include <netdb.h> +int main(){ +char *addr; +int length; +int type; +struct hostent *result, *resultp; +char buffer[2048]; +int buflen = 2048; +int h_errnop; + +(void) gethostbyaddr_r(addr, length, type, result, buffer, buflen, &resultp, &h_errnop); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETHOSTBYADDR_R_8_SRC}" HAVE_GETHOSTBYADDR_R_8) + IF(HAVE_GETHOSTBYADDR_R_8) + ADD_TCL_CFLAG(HAVE_GETHOSTBYADDR_R_8) + ENDIF(HAVE_GETHOSTBYADDR_R_8) + ENDIF(HAVE_GETHOSTBYADDR_R_7) + ENDIF(HAVE_GETHOSTBYADDR_R) +ENDMACRO(SC_TCL_GETHOSTBYADDR_R) + +#-------------------------------------------------------------------- +# SC_TCL_GETHOSTBYNAME_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETHOSTBYNAME_R) + CONFIG_CHECK_FUNCTION_EXISTS(gethostbyname_r HAVE_GETHOSTBYNAME_R) + IF(HAVE_GETHOSTBYNAME_R) + SET(HAVE_GETHOSTBYNAME_R_6_SRC " +#include <netdb.h> +int main(){ +char *name; +struct hostent *he, *res; +char buffer[2048]; +int buflen = 2048; +int h_errnop; + +(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETHOSTBYNAME_R_6_SRC}" HAVE_GETHOSTBYNAME_R_5) + IF(HAVE_GETHOSTBYNAME_R_6) + ADD_TCL_CFLAG(HAVE_GETHOSTBYNAME_R_6) + ELSE(HAVE_GETHOSTBYNAME_R_6) + SET(HAVE_GETHOSTBYNAME_R_5_SRC " +#include <netdb.h> +int main(){ +char *name; +struct hostent *he; +char buffer[2048]; +int buflen = 2048; +int h_errnop; + +(void) gethostbyname_r(name, he, buffer, buflen, &h_errnop); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETHOSTBYNAME_R_5_SRC}" HAVE_GETHOSTBYNAME_R_5) + + IF(HAVE_GETHOSTBYNAME_R_5) + ADD_TCL_CFLAG(HAVE_GETHOSTBYNAME_R_5) + ELSE(HAVE_GETHOSTBYNAME_R_5) + SET(HAVE_GETHOSTBYNAME_R_3_SRC " +#include <netdb.h> +int main(){ +char *name; +struct hostent *he; +struct hostent_data data; + +(void) gethostbyname_r(name, he, &data); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETHOSTBYNAME_R_3_SRC}" HAVE_GETHOSTBYNAME_R_3) + IF(HAVE_GETHOSTBYNAME_R_3) + ADD_TCL_CFLAG(HAVE_GETHOSTBYNAME_R_3) + ENDIF(HAVE_GETHOSTBYNAME_R_3) + ENDIF(HAVE_GETHOSTBYNAME_R_5) + ENDIF(HAVE_GETHOSTBYNAME_R_6) + ENDIF(HAVE_GETHOSTBYNAME_R) +ENDMACRO(SC_TCL_GETHOSTBYNAME_R) + +#-------------------------------------------------------------------- +# SC_TCL_GETADDRINFO +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETADDRINFO) + CHECK_FUNCTION_EXISTS(getaddrinfo HAVE_GETADDRINFO) + IF(HAVE_GETADDRINFO) + SET(GETADDRINFO_SRC " +#include <netdb.h> +int main () { +const char *name, *port; +struct addrinfo *aiPtr, hints; +(void)getaddrinfo(name,port, &hints, &aiPtr); +(void)freeaddrinfo(aiPtr); +return 0; +} + ") + CHECK_C_SOURCE_COMPILES("${GETADDRINFO_SRC}" WORKING_GETADDRINFO) + IF(WORKING_GETADDRINFO) + ADD_TCL_CFLAG(HAVE_GETADDRINFO) + ENDIF(WORKING_GETADDRINFO) + ENDIF(HAVE_GETADDRINFO) +ENDMACRO(SC_TCL_GETADDRINFO) + +#-------------------------------------------------------------------- +# SC_TCL_GETPWUID_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETPWUID_R) + CONFIG_CHECK_FUNCTION_EXISTS(getpwuid_r HAVE_GETPWUID_R) + IF(HAVE_GETPWUID_R) + SET(HAVE_GETPWUID_R_5_SRC " +#include <sys/types.h> +#include <pwd.h> +int main(){ +uid_t uid; +struct passwd pw, *pwp; +char buf[512]; +int buflen = 512; + +(void) getpwuid_r(uid, &pw, buf, buflen, &pwp); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETPWUID_R_5_SRC}" HAVE_GETPWUID_R_5) + IF(HAVE_GETPWUID_R_5) + ADD_TCL_CFLAG(HAVE_GETPWUID_R_5) + ELSE(HAVE_GETPWUID_R_5) + SET(HAVE_GETPWUID_R_4_SRC " +#include <sys/types.h> +#include <pwd.h> +int main(){ +uid_t uid; +struct passwd pw; +char buf[512]; +int buflen = 512; + +(void) getpwuid_r(uid, &pw, buf, buflen); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETPWUID_R_4_SRC}" HAVE_GETPWUID_R_4) + IF(HAVE_GETPWUID_R_4) + ADD_TCL_CFLAG(HAVE_GETPWUID_R_4) + ENDIF(HAVE_GETPWUID_R_4) + ENDIF(HAVE_GETPWUID_R_5) + ENDIF(HAVE_GETPWUID_R) +ENDMACRO(SC_TCL_GETPWUID_R) + +#-------------------------------------------------------------------- +# SC_TCL_GETPWNAM_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETPWNAM_R) + CONFIG_CHECK_FUNCTION_EXISTS(getpwnam_r HAVE_GETPWNAM_R) + IF(HAVE_GETPWNAM_R) + SET(HAVE_GETPWNAM_R_5_SRC " +#include <sys/types.h> +#include <pwd.h> +int main(){ +char *name; +struct passwd pw, *pwp; +char buf[512]; +int buflen = 512; + +(void) getpwnam_r(name, &pw, buf, buflen, &pwp); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETPWNAM_R_5_SRC}" HAVE_GETPWNAM_R_5) + IF(HAVE_GETPWNAM_R_5) + ADD_TCL_CFLAG(HAVE_GETPWNAM_R_5) + ELSE(HAVE_GETPWNAM_R_5) + SET(HAVE_GETPWNAM_R_4_SRC " +#include <sys/types.h> +#include <pwd.h> +int main(){ +char *name; +struct passwd pw; +char buf[512]; +int buflen = 512; + +(void)getpwnam_r(name, &pw, buf, buflen); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETPWNAM_R_4_SRC}" HAVE_GETPWNAM_R_4) + IF(HAVE_GETPWNAM_R_4) + ADD_TCL_CFLAG(HAVE_GETPWNAM_R_4) + ENDIF(HAVE_GETPWNAM_R_4) + ENDIF(HAVE_GETPWNAM_R_5) + ENDIF(HAVE_GETPWNAM_R) +ENDMACRO(SC_TCL_GETPWNAM_R) + +#-------------------------------------------------------------------- +# SC_TCL_GETGRGID_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETGRGID_R) + CONFIG_CHECK_FUNCTION_EXISTS(getgrgid_r HAVE_GETGRGID_R) + IF(HAVE_GETGRGID_R) + SET(HAVE_GETGRGID_R_5_SRC " +#include <sys/types.h> +#include <grp.h> +int main(){ +gid_t gid; +struct group gr, *grp; +char buf[512]; +int buflen = 512; + +(void) getgrgid_r(gid, &gr, buf, buflen, &grp); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETGRGID_R_5_SRC}" HAVE_GETGRGID_R_5) + IF(HAVE_GETGRGID_R_5) + ADD_TCL_CFLAG(HAVE_GETGRGID_R_5) + ELSE(HAVE_GETGRGID_R_5) + SET(HAVE_GETGRGID_R_4_SRC " +#include <sys/types.h> +#include <grp.h> +int main(){ +gid_t gid; +struct group gr; +char buf[512]; +int buflen = 512; + +(void)getgrgid_r(gid, &gr, buf, buflen); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETGRGID_R_4_SRC}" HAVE_GETGRGID_R_4) + IF(HAVE_GETGRGID_R_4) + ADD_TCL_CFLAG(HAVE_GETGRGID_R_4) + ENDIF(HAVE_GETGRGID_R_4) + ENDIF(HAVE_GETGRGID_R_5) + ENDIF(HAVE_GETGRGID_R) +ENDMACRO(SC_TCL_GETGRGID_R) + +#-------------------------------------------------------------------- +# SC_TCL_GETGRNAM_R +#-------------------------------------------------------------------- +MACRO(SC_TCL_GETGRNAM_R) + CONFIG_CHECK_FUNCTION_EXISTS(getgrnam_r HAVE_GETGRNAM_R) + IF(HAVE_GETGRNAM_R) + SET(HAVE_GETGRNAM_R_5_SRC " +#include <sys/types.h> +#include <grp.h> +int main(){ +char *name; +struct group gr, *grp; +char buf[512]; +int buflen = 512; + +(void) getgrnam_r(name, &gr, buf, buflen, &grp); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETGRNAM_R_5_SRC}" HAVE_GETGRNAM_R_5) + IF(HAVE_GETGRNAM_R_5) + ADD_TCL_CFLAG(HAVE_GETGRNAM_R_5) + ELSE(HAVE_GETGRNAM_R_5) + SET(HAVE_GETGRNAM_R_4_SRC " +#include <sys/types.h> +#include <grp.h> +int main(){ +char *name; +struct group gr; +char buf[512]; +int buflen = 512; + +(void)getgrnam_r(name, &gr, buf, buflen); +return 0;} + ") + CHECK_C_SOURCE_COMPILES("${HAVE_GETGRNAM_R_4_SRC}" HAVE_GETGRNAM_R_4) + IF(HAVE_GETGRNAM_R_4) + ADD_TCL_CFLAG(HAVE_GETGRNAM_R_4) + ENDIF(HAVE_GETGRNAM_R_4) + ENDIF(HAVE_GETGRNAM_R_5) + ENDIF(HAVE_GETGRNAM_R) +ENDMACRO(SC_TCL_GETGRNAM_R) + + + + +MACRO(CHECK_FD_SET_IN_TYPES_D) + SET(TEST_SRC " + #include <sys/types.h> + int main () + { + fd_set readMask, writeMask; + return 0; + } + ") + CHECK_C_SOURCE_COMPILES("${TEST_SRC}" FD_SET_IN_TYPES_H) +ENDMACRO(CHECK_FD_SET_IN_TYPES_D) + +MACRO(CHECK_COMPILER_SUPPORTS_HIDDEN_D) + SET(TEST_SRC" + #define MODULE_SCOPE extern __attribute__((__visibility__("hidden"))) + main(){}; + ") + CHECK_C_SOURCE_COMPILES("${TEST_SRC}" COMPILER_SUPPORTS_HIDDEN) +ENDMACRO(CHECK_COMPILER_SUPPORTS_HIDDEN_D) + + + Property changes on: brlcad/branches/cmake/src/other/incrTcl/itcl/CMake/tcl.cmake ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: brlcad/branches/cmake/src/other/incrTcl/itcl/CMakeLists.txt =================================================================== --- brlcad/branches/cmake/src/other/incrTcl/itcl/CMakeLists.txt 2010-11-05 20:18:39 UTC (rev 41256) +++ brlcad/branches/cmake/src/other/incrTcl/itcl/CMakeLists.txt 2010-11-05 21:08:18 UTC (rev 41257) @@ -1,5 +1,5 @@ # C M A K E L I S T S . T X T -# SCL +# ITCL # # Copyright (c) 2010 United States Government as represented by # the U.S. Army Research Laboratory. @@ -33,7 +33,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ******************************************************************* -# *** Tcl CMakeLists.txt *** +# *** ITCL CMakeLists.txt *** # ******************************************************************* # Minimum required version of CMake @@ -45,6 +45,11 @@ # set CMake project name PROJECT(ITCL) +# set local CFLAGS name +SET(CFLAGS_NAME ITCL) +SET(ITCL_CFLAGS "") +SET(CONFIG_CFLAGS ITCL_CFLAGS) + # build shared libs by default OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) @@ -92,180 +97,319 @@ SET(CMAKE_MODULE_PATH "${TCL_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") #----------------------------------------------------------------------------- -# Unlike the autotools based builds, CMake will always use itclConfig.h - -add_definitions( - -DHAVE_ITCL_CONFIG_H -) - -# We will need a tclConfig.h.in file to hold all the #cmakedefine statements, -# which will in turn be used to generate a tclConfig.h file. To succeed, the -# file must first be present, which we take care of here: - -SET(CONFIG_H_FILE "${CMAKE_BINARY_DIR}/include/itclConfig.h.in") -FILE(WRITE ${CONFIG_H_FILE} "/**** itcl define statements from CMake ****/\n") -FILE(APPEND ${CONFIG_H_FILE} "#ifndef _ITCLCONFIG\n") -FILE(APPEND ${CONFIG_H_FILE} "#define _ITCLCONFIG\n") - +# Tcl/Tk's normal build system uses autotools macros, referred to as the +# TEA system. An attempt to duplicate the required functionality from +# TEA is found in tcl.cmake INCLUDE(${ITCL_SOURCE_DIR}/CMake/CheckSystemFunctionality.cmake) +INCLUDE(${ITCL_SOURCE_DIR}/CMake/tcl.cmake) #---------------------------------------------------------------------------- # First, get some standard options out of the way - things that are constant # between various platforms or pertain to specific OS definitions -FILE(APPEND ${CONFIG_H_FILE} "#define PACKAGE_NAME \"Itcl\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define PACKAGE_TARNAME \"Itcl\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define PACKAGE_VERSION \"${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define PACKAGE_STRING \"Itcl ${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define PACKAGE_BUGREPORT \"\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define STDC_HEADERS 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#define ITCL_LIBRARY \"${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}itcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#define USE_TCL_STUBS 1\n") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DPACKAGE_NAME=\\\"Itcl\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DPACKAGE_TARNAME=\\\"Itcl\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DPACKAGE_VERSION=\\\"${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DPACKAGE_STRING=\\\"Itcl\\ ${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DPACKAGE_BUGREPORT=\\\"\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DSTDC_HEADERS=1") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DITCL_LIBRARY=\\\"${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}itcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}\\\"") +SET(ITCL_CFLAGS "${ITCL_CFLAGS} -DUSE_TCL_STUBS=1") #---------------------------------------------------------------------------- -# Define a number of variables to be controlled by options -OPTION(TCL_THREADS "Enable Tcl Thread support" ON) -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine TCL_THREADS 1\n") + +SET(TCL_CFLAGS "") + +SC_MISSING_POSIX_HEADERS() + +SC_ENABLE_THREADS() + + +SC_TCL_CFG_ENCODING() + +SC_TCL_LINK_LIBS() + +# TODO - look over SC_ENABLE_SHARED, SC_CONFIG_CFLAGS and SC_ENABLE_SYMBOLS +# need to decide how much of that logic is needed + +SC_TCL_64BIT_FLAGS() + +# Test endianness +INCLUDE(TestBigEndian) +TEST_BIG_ENDIAN(WORDS_BIGENDIAN) +IF(WORDS_BIGENDIAN) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DWORDS_BIGENDIAN=1") +ENDIF(WORDS_BIGENDIAN) + +# POSIX substitutes +CONFIG_CHECK_FUNCTION_EXISTS(getcwd HAVE_GETCWD) +IF(NOT HAVE_GETCWD) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DUSEGETWD=1") +ENDIF(NOT HAVE_GETCWD) +IF(NOT HAVE_GETCWD) + CONFIG_CHECK_FUNCTION_EXISTS(getwd HAVE_GETWD) + IF(NOT HAVE_GETWD) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_GETWD=1") + ENDIF(NOT HAVE_GETWD) +ENDIF(NOT HAVE_GETCWD) +CONFIG_CHECK_FUNCTION_EXISTS(opendir HAVE_OPENDIR) +IF(NOT HAVE_OPENDIR) + SET(COMPAT_SRCS ${COMPAT_SRCS} compat/opendir.c) + ADD_TCL_CFLAG(USE_DIRENT2_H) +ENDIF(NOT HAVE_OPENDIR) +CONFIG_CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL) +IF(NOT HAVE_STRTOL) + SET(COMPAT_SRCS ${COMPAT_SRCS} compat/strtol.c) +ENDIF(NOT HAVE_STRTOL) +CONFIG_CHECK_FUNCTION_EXISTS(waitpid HAVE_WAITPID) +IF(NOT HAVE_WAITPID) + SET(COMPAT_SRCS ${COMPAT_SRCS} compat/waitpid.c) +ENDIF(NOT HAVE_WAITPID) +CONFIG_CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) +IF(NOT HAVE_STRERROR) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_STRERROR=1") +ENDIF(NOT HAVE_STRERROR) +CHECK_FUNCTION_EXISTS(wait3 HAVE_WAIT3) +IF(NOT HAVE_WAIT3) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_WAIT3=1") +ENDIF(NOT HAVE_WAIT3) +CONFIG_CHECK_FUNCTION_EXISTS(uname HAVE_UNAME) +IF(NOT HAVE_UNAME) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_UNAME=1") +ENDIF(NOT HAVE_UNAME) +# Should be checking for early Darwin version here - realpath +# is not threadsafe prior to Darwin 7 +CHECK_FUNCTION_EXISTS(realpath HAVE_REALPATH) +IF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$" AND TCL_THREADS AND HAVE_REALPATH) + STRING(REGEX REPLACE "\\..*" "" CMAKE_SYSTEM_MAJOR_VERSION ${CMAKE_SYSTEM_VERSION}) + IF (${CMAKE_SYSTEM_MAJOR_VERSION} LESS 7) + MESSAGE("realpath is not threadsafe in Darwin versions prior to 7, disabling") + SET(HAVE_REALPATH) + ENDIF (${CMAKE_SYSTEM_MAJOR_VERSION} LESS 7) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$" AND TCL_THREADS AND HAVE_REALPATH) +IF(NOT HAVE_REALPATH) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_REALPATH=1") +ENDIF(NOT HAVE_REALPATH) + +SC_TCL_GETADDRINFO() + +# Thread safe tests - need to go over macros and +# get the right logic going here IF(TCL_THREADS) - FILE(APPEND ${CONFIG_H_FILE} "#define USE_THREAD_ALLOC 1\n") - FILE(APPEND ${CONFIG_H_FILE} "#define _REENTRANT 1\n") - FILE(APPEND ${CONFIG_H_FILE} "#define _THREAD_SAFE 1\n") - IF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") - FILE(APPEND ${CONFIG_H_FILE} "#define _POSIX_PTHREAD_SEMANTICS 1\n") - ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^SunOS$") + + SC_TCL_GETPWUID_R() + + SC_TCL_GETPWNAM_R() + + SC_TCL_GETGRGID_R() + + SC_TCL_GETGRNAM_R() + + IF(NOT HAVE_GETHOSTBYNAME) + CHECK_LIBRARY(GHBN lnsl gethostbyname) + SET(HAVE_GETHOSTBYNAME ${GHBN}) + ENDIF(NOT HAVE_GETHOSTBYNAME) + + SC_TCL_GETHOSTBYADDR_R() + SC_TCL_GETHOSTBYNAME_R() + + IF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$") + STRING(REGEX REPLACE "\\..*" "" CMAKE_SYSTEM_MAJOR_VERSION ${CMAKE_SYSTEM_VERSION}) + IF (${CMAKE_SYSTEM_MAJOR_VERSION} GREATER 5) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DHAVE_MTSAFE_GETHOSTBYNAME=1") + SET(TCL_CFLAGS "${TCL_CFLAGS} -DHAVE_MTSAFE_GETHOSTBYADDR=1") + ENDIF (${CMAKE_SYSTEM_MAJOR_VERSION} GREATER 5) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$") + + IF(${CMAKE_SYSTEM_NAME} MATCHES "^HP-UX$") + STRING(REGEX REPLACE "\\..*" "" CMAKE_SYSTEM_MAJOR_VERSION ${CMAKE_SYSTEM_VERSION}) + IF (${CMAKE_SYSTEM_MAJOR_VERSION} GREATER 10) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DHAVE_MTSAFE_GETHOSTBYNAME=1") + SET(TCL_CFLAGS "${TCL_CFLAGS} -DHAVE_MTSAFE_GETHOSTBYADDR=1") + ENDIF (${CMAKE_SYSTEM_MAJOR_VERSION} GREATER 10) + ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^HP-UX$") + ENDIF(TCL_THREADS) -#---------------------------------------------------------------------------- -# Run tests for system headers and functionality -CHECK_INCLUDE_FILE_H(sys/types.h HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE_H(sys/stat.h HAVE_SYS_STAT_H) -CHECK_INCLUDE_FILE_H(sys/fstatfs.h HAVE_SYS_FSTATFS_H) -IF(NOT HAVE_SYS_FSTATFS_H) - FILE(APPEND ${CONFIG_H_FILE} "#define NO_FSTATFS 1\n") -ENDIF(NOT HAVE_SYS_FSTATFS_H) -CHECK_INCLUDE_FILE_H(stdlib.h HAVE_STDLIB_H) -CHECK_INCLUDE_FILE_H(string.h HAVE_STRING_H) -CHECK_INCLUDE_FILE_H(memory.h HAVE_MEMORY_H) -CHECK_INCLUDE_FILE_H(strings.h HAVE_STRINGS_H) -CHECK_INCLUDE_FILE_H(inttypes.h HAVE_INTTYPES_H) -CHECK_INCLUDE_FILE_H(stdint.h HAVE_STDINT_H) -CHECK_INCLUDE_FILE_H(unistd.h HAVE_UNISTD_H) +# Determine which interface to use to talk to the serial port. +SC_SERIAL_PORT() -CHECK_INCLUDE_FILE_H(dirent.h HAVE_DIRENT_H) -IF(NOT HAVE_DIRENT_H) - FILE(APPEND ${CONFIG_H_FILE} "#define NO_DIRENT_H 1\n") -ENDIF(NOT HAVE_DIRENT_H) +# Do we need the sys/select.h check these days? -CHECK_INCLUDE_FILE_USABILITY_H(float.h FLOAT_H) -CHECK_INCLUDE_FILE_USABILITY_H(values.h VALUES_H) -CHECK_INCLUDE_FILE_USABILITY_H(limits.h LIMITS_H) -CHECK_INCLUDE_FILE_USABILITY_H(sys/wait.h SYS_WAIT_H) -CHECK_INCLUDE_FILE_USABILITY_H(dlfcn.h DLFCN_H) -CHECK_INCLUDE_FILE_USABILITY_H(sys/param.h SYS_PARAM_H) +# Handle time +SC_TIME_HANDLER() -CHECK_LIBRARY(M m sin) -CHECK_LIBRARY(IEEE ieee main) -CHECK_LIBRARY(INET inet main) +# memove check - need to revisit this, not finding memmove +# on OSX +#CHECK_FUNCTION_EXISTS(memmove, HAVE_MEMMOVE) +#IF(NOT HAVE_MEMMOVE) +# SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_MEMMOVE=1") +# SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_STRING_H=1") +#ENDIF(NOT HAVE_MEMMOVE) -CHECK_INCLUDE_FILE_USABILITY_H(net/errno.h NET_ERRNO_H) -CHECK_FUNCTION_EXISTS(connect HAVE_CONNECT) -CHECK_FUNCTION_EXISTS(gethostbyname HAVE_GETHOSTBYNAME) -IF(NOT HAVE_GETHOSTBYNAME) - CHECK_LIBRARY(GHBN lnsl gethostbyname) - SET(HAVE_GETHOSTBYNAME ${GHBN}) -ENDIF(NOT HAVE_GETHOSTBYNAME) +# Test for bad functions +SC_TCL_CHECK_BROKEN_FUNC( + strstr " + extern int strstr(); + exit(strstr(\"\\\0test\", \"test\") ? 1 : 0);" +) -CHECK_COMPILER_SUPPORTS_HIDDEN() -CHECK_LIBRARY(DL dl dlopen) +SC_TCL_CHECK_BROKEN_FUNC( + strtoul " + extern int strtoul(); + char *term, *string = \"0\"; + exit(strtoul(string,&term,0) != 0 || term != string+1);" +) -CHECK_FUNCTION_EXISTS_H(getcwd HAVE_GETCWD) -CHECK_FUNCTION_EXISTS_H(opendir HAVE_OPENDIR) -CHECK_FUNCTION_EXISTS_H(strtol HAVE_STRTOL) -CHECK_FUNCTION_EXISTS_H(waitpid HAVE_WAITPID) -CHECK_FUNCTION_EXISTS_H(strerror HAVE_STRERROR) -CHECK_FUNCTION_EXISTS_H(getwd HAVE_GETWD) -CHECK_FUNCTION_EXISTS_H(wait3 HAVE_WAIT3) -CHECK_FUNCTION_EXISTS_H(uname HAVE_UNAME) -CHECK_FUNCTION_EXISTS_H(realpath HAVE_REALPATH) -CHECK_FUNCTION_EXISTS(getaddrinfo HAVE_GETADDRINFO) -IF(HAVE_GETADDRINFO) - CHECK_GETADDERINFO_WORKING() -ENDIF(HAVE_GETADDRINFO) +# Check for types - TODO: still need to define substitutes if these +# are not found +CONFIG_CHECK_TYPE_SIZE(mode_t MODE) +CONFIG_CHECK_TYPE_SIZE(pid_t PID) +CONFIG_CHECK_TYPE_SIZE(size_t SIZE) +CONFIG_CHECK_TYPE_SIZE(uid_t UID) +CONFIG_CHECK_TYPE_SIZE(blkcnt_t BLKCNT) +CONFIG_CHECK_TYPE_SIZE(intptr_t INTPTR) +CONFIG_CHECK_TYPE_SIZE(uintptr_t UINTPTR) -CHECK_INCLUDE_FILE_USABILITY_H(sys/modem.h SYS_MODEM_H) -TERMIOS_TERMIO_SGTTY() +SC_ENABLE_LANGINFO() -CHECK_FD_SET_IN_TYPES_H() +IF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$") + CONFIG_CHECK_FUNCTION_EXISTS(getattrlist HAVE_GETATTRLIST) + CONFIG_CHECK_INCLUDE_FILE(copyfile.h HAVE_COPYFILE_H) + CONFIG_CHECK_FUNCTION_EXISTS(copyfile HAVE_COPYFILE) + IF(${COREFOUNDATION_FRAMEWORK}) + CONFIG_CHECK_INCLUDE_FILE(libkern/OSAtomic.h HAVE_LIBKERN_OSATOMIC_H) + CONFIG_CHECK_FUNCTION_EXISTS(OSSpinLockLock HAVE_OSSPINLOCKLOCK) + CONFIG_CHECK_FUNCTION_EXISTS(pthread_atfork HAVE_PTHREAD_ATFORK) + ENDIF(${COREFOUNDATION_FRAMEWORK}) + ADD_TCL_CFLAG(USE_VFORK) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DTCL_DEFAULT_ENCODING=\\\"utf-8\\\"") + ADD_TCL_CFLAG(TCL_LOAD_FROM_MEMORY) + ADD_TCL_CFLAG(TCL_WIDE_CLICKS) + CONFIG_CHECK_INCLUDE_FILE_USABILITY(AvailabilityMacros.h HAVE_AVAILABILITYMACROS_H) + IF(HAVE_AVAILABILITYMACROS_H) + SET(WEAK_IMPORT_SRCS " +#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020 +#error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020 +#endif +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1020 +#error MAC_OS_X_VERSION_MIN_REQUIRED < 1020 +#endif +int rand(void) __attribute__((weak_import)); +int main() { +rand(); +return 0; +} + ") + CHECK_C_SOURCE_COMPILES("${WEAK_IMPORT_SRCS}" WEAK_IMPORT_WORKING) + IF(WEAK_IMPORT_WORKING) + ADD_TCL_CFLAG(HAVE_WEAK_IMPORT) + ENDIF(WEAK_IMPORT_WORKING) + SET(SUSV3_SRCS " +#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 +#error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 +#endif +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +#error MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +#endif +#define _DARWIN_C_SOURCE 1 +#include <sys/cdefs.h> -CHECK_INCLUDE_FILE_USABILITY_H(sys/time.h HAVE_SYS_TIME_H) -CHECK_TIME_AND_SYS_TIME() +int main () {return 0;} + ") + CHECK_C_SOURCE_COMPILES("${SUSV3_SRCS}" SUSV3_WORKING) + IF(SUSV3_WORKING) + ADD_TCL_CFLAG(_DARWIN_C_SOURCE) + ENDIF(SUSV3_WORKING) -CHECK_FUNCTION_EXISTS_H(gmtime_r HAVE_GMTIME_R) -CHECK_FUNCTION_EXISTS_H(localtime_r HAVE_LOCALTIME_R) -CHECK_FUNCTION_EXISTS_H(mktime HAVE_MKTIME) + ENDIF(HAVE_AVAILABILITYMACROS_H) +ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "^Darwin$") -CHECK_STRUCT_HAS_MEMBER_H("struct tm" tm_tzadj time.h HAVE_TM_TZADJ) -CHECK_STRUCT_HAS_MEMBER_H("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF) +# Check for support of fts functions (readdir replacement) +SET(FTS_SRCS " +#include <sys/param.h> +#include <sys/stat.h> +#include <fts.h> -CHECK_INCLUDE_FILE_H(copyfile.h HAVE_COPYFILE_H) -CHECK_FUNCTION_EXISTS_H(copyfile HAVE_COPYFILE) +int main () { +char*const p[2] = {\"/\", NULL}; +FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL); +FTSENT *e = fts_read(f); fts_close(f); +return 0; +} +") +CHECK_C_SOURCE_COMPILES("${FTS_SRCS}" FTS_WORKING) +IF(FTS_WORKING) + ADD_TCL_CFLAG(HAVE_FTS) +ENDIF(FTS_WORKING) -CHECK_INCLUDE_FILE_H(sys/ioctl.h HAVE_SYS_IOCTL_H) -CHECK_INCLUDE_FILE_H(sys/filio.h HAVE_SYS_FILIO_H) +OPTION(TCL_UNLOAD_DLLS "Allow unloading of shared libraries?" ON) +IF(TCL_UNLOAD_DLLS) + ADD_TCL_CFLAG(TCL_UNLOAD_DLLS) +ENDIF(TCL_UNLOAD_DLLS) +# TODO - Need to set up check for timezone info +# TODO - Dtrace -#CHECK_FUNCTION_EXISTS_H( HAVE_GETPWUID_R_5) -CHECK_FUNCTION_EXISTS_H(getpwuid HAVE_GETPWUID_R) -#CHECK_FUNCTION_EXISTS_H( HAVE_GETPWNAM_R_5) -CHECK_FUNCTION_EXISTS_H(getpwnam HAVE_GETPWNAM_R) -#CHECK_FUNCTION_EXISTS_H( HAVE_GETGRGID_R_5) -CHECK_FUNCTION_EXISTS_H(getgrgid HAVE_GETGRGID_R) -#CHECK_FUNCTION_EXISTS_H( HAVE_GETGRNAM_R_5) -CHECK_FUNCTION_EXISTS_H(getgrnam HAVE_GETGRNAM_R) -#CHECK_FUNCTION_EXISTS_H( HAVE_MTSAFE_GETHOSTBYNAME) -#CHECK_FUNCTION_EXISTS_H( HAVE_MTSAFE_GETHOSTBYADDR) -#CHECK_FUNCTION_EXISTS_H( HAVE_STRUCT_STAT_ST_BLOCKS) -#CHECK_FUNCTION_EXISTS_H( HAVE_STRUCT_STAT_ST_BLKSIZE) -CHECK_TYPE_SIZE_H(blkcnt_t HAVE_BLKCNT_T) -CHECK_TYPE_SIZE_H(intptr_t HAVE_INTPTR_T) -CHECK_TYPE_SIZE_H(uintptr_t HAVE_UINTPTR_T) -#CHECK_TYPE_SIZE_H( HAVE_SIGNED_CHAR) -#CHECK_TYPE_SIZE_H( HAVE_LANGINFO) -#CHECK_TYPE_SIZE_H( HAVE_CHFLAGS) -CHECK_FUNCTION_EXISTS_H(getattrlist HAVE_GETATTRLIST) -CHECK_INCLUDE_FILE_H(libkern/OSAtomic.h HAVE_LIBKERN_OSATOMIC_H) -CHECK_FUNCTION_EXISTS_H(OSSpinLockLock HAVE_OSSPINLOCKLOCK) -CHECK_FUNCTION_EXISTS_H(pthread_atfork HAVE_PTHREAD_ATFORK) -#CHECK_INCLUDE_FILE_H( USE_VFORK) -#CHECK_INCLUDE_FILE_H( TCL_WIDE_INT_TYPE long\ long\n") -#CHECK_INCLUDE_FILE_H( TCL_CFG_DEBUG) -#CHECK_INCLUDE_FILE_H( USE_TERMIOS) -#CHECK_INCLUDE_FILE_H( TIME_WITH_SYS_TIME) -#CHECK_INCLUDE_FILE_H( HAVE_TM_GMTOFF) -#CHECK_INCLUDE_FILE_H( HAVE_TIMEZONE_VAR) -#CHECK_INCLUDE_FILE_H( HAVE_STRUCT_STAT64) -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine M_PREC 4\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine TCL_DEFAULT_ENCODING \"utf-8\"\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine TCL_LOAD_FROM_MEMORY 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine TCL_WIDE_CLICKS 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_AVAILABILITYMACROS_H 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_WEAK_IMPORT 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine _DARWIN_C_SOURCE 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine HAVE_FTS 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine TCL_UNLOAD_DLLS 1\n") -FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine USE_DTRACE 1\n") +#-------------------------------------------------------------------- +# Does the C stack grow upwards or downwards? Or cross-compiling? +#-------------------------------------------------------------------- +SET(C_STACK_SRC " +int StackGrowsUp(int *parent) { +int here; +return (&here < parent); +} +int main (int argc, char *argv[]) { +int foo; +return StackGrowsUp(&foo); +} +") +CHECK_C_SOURCE_RUNS("${C_STACK_SRC}" STACK_GROWS_UP) +IF(STACK_GROWS_UP) + ADD_TCL_CFLAG(TCL_STACK_GROWS_UP) +ENDIF(STACK_GROWS_UP) -FIND_PACKAGE(Threads) +CONFIG_CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) +CONFIG_CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) +CONFIG_CHECK_INCLUDE_FILE(sys/fstatfs.h HAVE_SYS_FSTATFS_H) +IF(NOT HAVE_SYS_FSTATFS_H) + SET(TCL_CFLAGS "${TCL_CFLAGS} -DNO_FSTATFS=1") +ENDIF(NOT HAVE_SYS_FSTATFS_H) +CONFIG_CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) +CONFIG_CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H) +CONFIG_CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) +CONFIG_CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) +CONFIG_CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) -# Now that all the tests are done, configure the itclConfig.h file: -FILE(APPEND ${CONFIG_H_FILE} "#endif /*_ITCLCONFIG*/\n") -configure_file(${CONFIG_H_FILE} ${ITCL_BINARY_DIR}/include/itclConfig.h) + + +CHECK_COMPILER_SUPPORTS_HIDDEN_D() + +CONFIG_CHECK_LIBRARY(DL dl dlopen) + + + +CONFIG_CHECK_INCLUDE_FILE_USABILITY(sys/modem.h SYS_MODEM_H) + + +CHECK_FD_SET_IN_TYPES_D() + +CONFIG_CHECK_FUNCTION_EXISTS(chflags HAVE_CHFLAGS) + +IF(COMPAT_SRCS) + ADD_TCL_CFLAG(USE_COMPAT) +ENDIF(COMPAT_SRCS) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ITCL_CFLAGS} ${TCL_CFLAGS}") + SET(ITCL_GENERIC_SRCS generic/itclStubInit.c generic/itclStubLib.c @@ -327,3 +471,5 @@ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl "package ifneeded Itcl ${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION} [list load [file join $dir libitcl${CMAKE_SHARED_LIBRARY_SUFFIX}] Itcl]") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl DESTINATION lib/Itcl${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}) +install(FILES library/itcl.tcl DESTINATION lib/Itcl${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/library/itcl.tcl ${CMAKE_BINARY_DIR}/lib/Itcl${ITCL_MAJOR_VERSION}.${ITCL_MINOR_VERSION} COPYONLY) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |