Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
revert [a30523e] (remove supernovae) because I need some timings on G5K, and fix...
[simgrid.git] / buildtools / Cmake / CompleteInFiles.cmake
index e42ffc4..1f422e1 100644 (file)
@@ -3,15 +3,17 @@ ${CMAKE_MODULE_PATH}
 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Modules
 )
 
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
-   message(STATUS "System processor: amd64")
-   set(HAVE_RAWCTX 1)
-   
-ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+# x86_64
+# x86
+# i.86
+IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
     IF(${ARCH_32_BITS})
+        set(PROCESSOR_i686 1)
+        set(SIMGRID_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
         message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
     ELSE(${ARCH_32_BITS})
         message(STATUS "System processor: amd64")
+        set(SIMGRID_SYSTEM_PROCESSOR "amd64")
         set(PROCESSOR_x86_64 1)
         set(PROCESSOR_i686 0)
     ENDIF(${ARCH_32_BITS})          
@@ -52,7 +54,7 @@ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
 ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") #PROCESSOR NOT fIND
     message(STATUS "PROCESSOR NOT FOUND: ${CMAKE_SYSTEM_PROCESSOR}")
     
-ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
 
 message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
 
@@ -65,11 +67,8 @@ include(TestBigEndian)
 TEST_BIG_ENDIAN(BIGENDIAN)
 
 include(FindGraphviz)
-
-string(TOUPPER ${enable_pcre} enable_pcre)
-if(enable_pcre STREQUAL "AUTO" OR enable_pcre STREQUAL "ON")
 include(FindPCRE)
-endif(enable_pcre STREQUAL "AUTO" OR enable_pcre STREQUAL "ON")
+
 set(HAVE_GTNETS 0)
 if(enable_gtnets)      
        include(FindGTnets)
@@ -209,14 +208,16 @@ if(pthread)
        ### Test that we have a way to create semaphores
        
        if(HAVE_SEM_OPEN_LIB)
-               exec_program("${CMAKE_C_COMPILER} -lpthread ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_open.c -o testprog"
+               exec_program("${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_open.c -lpthread -o testprog"
                             OUTPUT_VARIABLE HAVE_SEM_OPEN_run)
                if(HAVE_SEM_OPEN_run)
                        set(HAVE_SEM_OPEN 0)
+                       message(STATUS "Warning: sem_open not compilable")
                else(HAVE_SEM_OPEN_run)
                        exec_program("./testprog" RETURN_VALUE HAVE_SEM_OPEN_run2 OUTPUT_VARIABLE var_compil)
                        if(HAVE_SEM_OPEN_run2)
                                set(HAVE_SEM_OPEN 0)
+                               message(STATUS "Warning: sem_open not executable")
                        else(HAVE_SEM_OPEN_run2)
                                set(HAVE_SEM_OPEN 1)
                        endif(HAVE_SEM_OPEN_run2)       
@@ -226,14 +227,16 @@ if(pthread)
        endif(HAVE_SEM_OPEN_LIB)
 
        if(HAVE_SEM_INIT_LIB)
-               exec_program("${CMAKE_C_COMPILER} -lpthread ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_init.c -o testprog" 
+               exec_program("${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_init.c -lpthread -o testprog"
                             OUTPUT_VARIABLE HAVE_SEM_INIT_run)
                if(HAVE_SEM_INIT_run)
                        set(HAVE_SEM_INIT 0)
+                       message(STATUS "Warning: sem_init not compilable")
                else(HAVE_SEM_INIT_run)
                        exec_program("./testprog" RETURN_VALUE HAVE_SEM_INIT_run OUTPUT_VARIABLE var_compil)
                        if(HAVE_SEM_INIT_run)
                                set(HAVE_SEM_INIT 0)
+                               message(STATUS "Warning: sem_init not executable")
                        else(HAVE_SEM_INIT_run)
                                set(HAVE_SEM_INIT 1)
                        endif(HAVE_SEM_INIT_run)
@@ -243,7 +246,7 @@ if(pthread)
        endif(HAVE_SEM_INIT_LIB)
 
        if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
-               message(FATAL_ERROR "Semaphores are not usable, but they are mandatory to threads (you may need to mount /dev).")
+               message(FATAL_ERROR "Semaphores are not usable (neither sem_open nor sem_init is both compilable and executable), but they are mandatory to threads (you may need to mount /dev).")
        endif(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
 
        ### Test that we have a way to timewait for semaphores
@@ -291,14 +294,14 @@ IF(CMAKE_CROSSCOMPILING)
        ENDIF(WIN32)
 ELSE(CMAKE_CROSSCOMPILING)
        try_run(RUN_mcsc_VAR COMPILE_mcsc_VAR
-               ${simgrid_BINARY_DIR}
+               ${PROJECT_BINARY_DIR}
                ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c
                COMPILE_DEFINITIONS "${mcsc_flags}"
                OUTPUT_VARIABLE var_compil
                )
                
-               if(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
-                       file(READ "${simgrid_BINARY_DIR}/conftestval" mcsc)
+               if(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
+                       file(READ "${PROJECT_BINARY_DIR}/conftestval" mcsc)
                        STRING(REPLACE "\n" "" mcsc "${mcsc}")
                        if(mcsc)
                                set(mcsc "yes")
@@ -306,9 +309,9 @@ ELSE(CMAKE_CROSSCOMPILING)
                        else(mcsc)
                                set(mcsc "no")
                        endif(mcsc)
-           else(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
+           else(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
                        set(mcsc "no")
-               endif(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
+               endif(EXISTS "${PROJECT_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
 ENDIF(CMAKE_CROSSCOMPILING)
 
 if(mcsc MATCHES "no" AND pthread)
@@ -346,38 +349,21 @@ endif(pthread)
 ###############
 ## SVN version check
 ##
-if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
-       find_file(SVN ".svn" ${CMAKE_HOME_DIRECTORY})
-       exec_program("svnversion ${CMAKE_HOME_DIRECTORY}" OUTPUT_VARIABLE "SVN_VERSION")
-       message(STATUS "svn version ${SVN_VERSION}")
-else(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
-       exec_program("git config --get svn-remote.svn.url"
-               OUTPUT_VARIABLE url
-               RETURN_VALUE ret)
-endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
+if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
+exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
+exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
 
 if(url)
        exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
+       message(STATUS "Git version: ${GIT_VERSION}")
        exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
-       
+       message(STATUS "Git date: ${GIT_DATE}")
        string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
        STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
        STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
        STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
-       
-       exec_program("git svn info" ${CMAKE_HOME_DIRECTORY}
-               OUTPUT_VARIABLE "GIT_SVN_VERSION")
-       string(REPLACE "\n" ";" GIT_SVN_VERSION ${GIT_SVN_VERSION})
-       foreach(line ${GIT_SVN_VERSION})
-               string(REGEX MATCH "^Revision:.*" line_good ${line})
-               if(line_good)
-                       string(REPLACE "Revision: " ""
-                               line_good ${line_good})
-                       set(SVN_VERSION ${line_good})
-               endif(line_good)
-       endforeach(line ${GIT_SVN_VERSION})
 endif(url)
-
+endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
 
 ###################################
 ## SimGrid and GRAS specific checks
@@ -386,7 +372,7 @@ endif(url)
 IF(NOT CMAKE_CROSSCOMPILING)
 # Check architecture signature begin
 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_ARCH.c
        RUN_OUTPUT_VARIABLE var1
        )
@@ -398,6 +384,36 @@ else(BIGENDIAN)
   set(GRAS_BIGENDIAN 0)
 endif(BIGENDIAN)
 
+# The syntax of this magic string is given in src/gras/DataDesc/ddt_convert.c
+# It kinda matches the values that the gras_arch_desc_t structure can take
+
+# Basically, the syntax is one char l or B for endianness (little or Big)
+#   then there is a bunch of blocks separated by _.  
+# C block is for char, I block for integers, P block for pointers and
+#   D block for floating points
+# For each block there is an amount of chuncks separated by :, each of
+#   them describing a data size. For example there is only one chunk
+#   in the char block, because no architecture provide several sizes
+#   of chars. In integer block, there is 4 chunks: "short int", "int",
+#   "long int", "long long int". There is 2 pointer chunks for data
+#   pointers and pointers on functions (thanks to the AMD64 madness).
+#   Thee two floating points chuncks are for "float" and "double".
+# Each chunk is of the form datasize/minimal_alignment_size
+
+# These informations are used to convert a data stream from one
+#    formalism to another. Only the GRAS_ARCH is transfered in the
+#    stream, and it it of cruxial importance to keep these detection
+#    information here synchronized with the data hardcoded in the
+#    source in src/gras/DataDesc/ddt_convert.c 
+
+# If you add something here (like a previously unknown architecture),
+#    please add it to the source code too. 
+# Please do not modify stuff here since it'd break the GRAS protocol.
+#     If you really need to change stuff, please also bump
+#    GRAS_PROTOCOL_VERSION in src/gras/Msg/msg_interface.h
+
+SET(GRAS_THISARCH "none")
+
 if(val_big MATCHES "l_C:1/1:_I:2/1:4/1:4/1:8/1:_P:4/1:4/1:_D:4/1:8/1:")
        #gras_arch=0; gras_size=32; gras_arch_name=little32_1;
        SET(GRAS_ARCH_32_BITS 1)
@@ -423,42 +439,51 @@ if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:")
        SET(GRAS_ARCH_32_BITS 0)
        SET(GRAS_THISARCH 4)
 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:")
+if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:8/8:8/8:_D:4/4:8/8:") 
+       #gras_arch=5; gras_size=64; gras_arch_name=little64_2;
+       SET(GRAS_ARCH_32_BITS 0)
+       SET(GRAS_THISARCH 5)
+endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:8/8:8/8:_D:4/4:8/8:")
 
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:") 
-       #gras_arch=5; gras_size=32; gras_arch_name=big32;
+       #gras_arch=6; gras_size=32; gras_arch_name=big32_8;
        SET(GRAS_ARCH_32_BITS 1)
-       SET(GRAS_THISARCH 5)
+       SET(GRAS_THISARCH 6)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:")
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/4:") 
-       #gras_arch=6; gras_size=32; gras_arch_name=big32_8_4;
+       #gras_arch=7; gras_size=32; gras_arch_name=big32_8_4;
        SET(GRAS_ARCH_32_BITS 1)
-       SET(GRAS_THISARCH 6)
+       SET(GRAS_THISARCH 7)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/4:")
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:") 
-       #gras_arch=7; gras_size=32; gras_arch_name=big32_4;
+       #gras_arch=8; gras_size=32; gras_arch_name=big32_4;
        SET(GRAS_ARCH_32_BITS 1)
-       SET(GRAS_THISARCH 7)
+       SET(GRAS_THISARCH 8)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:")
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:") 
-       #gras_arch=8; gras_size=32; gras_arch_name=big32_2;
+       #gras_arch=9; gras_size=32; gras_arch_name=big32_2;
        SET(GRAS_ARCH_32_BITS 1)
-       SET(GRAS_THISARCH 8)
+       SET(GRAS_THISARCH 9)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:") 
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:") 
-       #gras_arch=9; gras_size=64; gras_arch_name=big64;
+       #gras_arch=10; gras_size=64; gras_arch_name=big64;
        SET(GRAS_ARCH_32_BITS 0)
-       SET(GRAS_THISARCH 9)
+       SET(GRAS_THISARCH 10)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:")
 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:") 
-       #gras_arch=10;gras_size=64; gras_arch_name=big64_8_4;
+       #gras_arch=11; gras_size=64; gras_arch_name=big64_8_4;
        SET(GRAS_ARCH_32_BITS 0)
-       SET(GRAS_THISARCH 10)
+       SET(GRAS_THISARCH 11)
 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:") 
 
+if(GRAS_THISARCH MATCHES "none")
+    message(STATUS "architecture: ${val_big}")
+    message(FATAL_ERROR "GRAS_THISARCH is empty: '${GRAS_THISARCH}'")  
+endif(GRAS_THISARCH MATCHES "none")
 
 # Check architecture signature end
 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c
        RUN_OUTPUT_VARIABLE var2
        )
@@ -469,7 +494,7 @@ endforeach(var_tmp ${var2})
 
 # Check for [SIZEOF_MAX]
 try_run(RUN_SM_VAR COMPILE_SM_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_max_size.c
        RUN_OUTPUT_VARIABLE var3
        )
@@ -495,11 +520,11 @@ if(HAVE_MAKECONTEXT OR WIN32)
        endif(WIN32 AND __GNUC__)
        
        try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
-               ${simgrid_BINARY_DIR}
+               ${PROJECT_BINARY_DIR}
                ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c
                COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
                )
-       file(READ ${simgrid_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
+       file(READ ${PROJECT_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
        string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
        string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
        string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
@@ -515,10 +540,10 @@ endif(HAVE_MAKECONTEXT OR WIN32)
 ### check for stackgrowth
 if (NOT CMAKE_CROSSCOMPILING)
        try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
-               ${simgrid_BINARY_DIR}
+               ${PROJECT_BINARY_DIR}
                ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c
                )
-file(READ "${simgrid_BINARY_DIR}/conftestval" stack)
+file(READ "${PROJECT_BINARY_DIR}/conftestval" stack)
 if(stack MATCHES "down")
        set(PTH_STACKGROWTH "-1")
 endif(stack MATCHES "down")
@@ -540,7 +565,7 @@ endif(NOT CMAKE_CROSSCOMPILING)
 
 #AC_PRINTF_NULL
 try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c
        )
 
@@ -593,7 +618,7 @@ foreach(fct ${diff_va})
        }"
        )
        try_compile(COMPILE_VA_NULL_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c
        )
        if(COMPILE_VA_NULL_VAR)
@@ -651,7 +676,7 @@ endforeach(fct ${diff_va})
 #--------------------------------------------------------------------------------------------------
 ### check for getline
 try_compile(COMPILE_RESULT_VAR
-       ${simgrid_BINARY_DIR}
+       ${PROJECT_BINARY_DIR}
        ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c
        )
 
@@ -675,7 +700,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
                #set(PREFER_PORTABLE_SNPRINTF 1)
        else(CMAKE_CROSSCOMPILING)
            try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
-               ${simgrid_BINARY_DIR}
+               ${PROJECT_BINARY_DIR}
                ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c
            )   
        endif(CMAKE_CROSSCOMPILING)
@@ -685,7 +710,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
                set(PREFER_PORTABLE_VSNPRINTF 1)
        else(CMAKE_CROSSCOMPILING)
           try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
-               ${simgrid_BINARY_DIR}
+               ${PROJECT_BINARY_DIR}
                ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c
           )
        endif(CMAKE_CROSSCOMPILING)
@@ -795,8 +820,8 @@ else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
        configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/small_platform_with_routers.xml ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml COPYONLY)
        configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing/platform.xml ${CMAKE_BINARY_DIR}/examples/msg/tracing/platform.xml COPYONLY)
        
-       set(generate_files_to_clean
-               ${generate_files_to_clean}
+       set(generated_files_to_clean
+               ${generated_files_to_clean}
                ${CMAKE_BINARY_DIR}/examples/smpi/hostfile
                ${CMAKE_BINARY_DIR}/examples/msg/small_platform.xml
                ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml
@@ -805,7 +830,7 @@ else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
 endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
 
 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
-"${generate_files_to_clean}")
+"${generated_files_to_clean}")
 
 
 IF(${ARCH_32_BITS})