Bring in changes in develop (ecbuild etc)

This commit is contained in:
Shahram Najm 2018-05-22 12:23:08 +01:00
parent 41b9ea99db
commit 0cd0a36f54
4 changed files with 152 additions and 16 deletions

View File

@ -31,6 +31,37 @@ ecbuild_requires_macro_version( 2.7.2 )
ecbuild_declare_project()
###############################################################################
# system checks needed for eccodes_config.h and some options like MEMFS
check_type_size( int ECCODES_SIZEOF_INT )
check_type_size( long ECCODES_SIZEOF_LONG )
check_type_size( size_t ECCODES_SIZEOF_SIZE_T )
check_include_files( assert.h ECCODES_HAVE_ASSERT_H )
check_include_files( string.h ECCODES_HAVE_STRING_H )
check_include_files( sys/types.h ECCODES_HAVE_SYS_TYPES_H )
check_include_files( sys/stat.h ECCODES_HAVE_SYS_STAT_H )
check_include_files( fcntl.h ECCODES_HAVE_FCNTL_H )
check_include_files( unistd.h ECCODES_HAVE_UNISTD_H )
check_symbol_exists( fseeko "stdio.h" ECCODES_HAVE_FSEEKO )
check_symbol_exists( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN )
check_symbol_exists( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN )
check_symbol_exists( funopen "stdio.h" ECCODES_HAVE_FUNOPEN )
check_c_source_compiles(
" typedef int foo_t;
static inline foo_t static_foo(){return 0;}
foo_t foo(){return 0;}
int main(int argc, char *argv[]){return 0;}
" ECCODES_HAVE_C_INLINE )
include(eccodes_test_endiness)
ecbuild_debug("ECCODES_BIG_ENDIAN=${ECCODES_BIG_ENDIAN}")
ecbuild_debug("ECCODES_LITTLE_ENDIAN=${ECCODES_LITTLE_ENDIAN}")
###############################################################################
# some variables/options of this project
@ -96,7 +127,7 @@ endif()
ecbuild_add_option( FEATURE MEMFS
DESCRIPTION "Memory based access to definitions/samples"
DEFAULT OFF
CONDITION EC_HAVE_FMEMOPEN OR EC_HAVE_FUNOPEN
CONDITION ECCODES_HAVE_FMEMOPEN OR ECCODES_HAVE_FUNOPEN
REQUIRED_PACKAGES PythonInterp
)
@ -192,7 +223,7 @@ else()
endif()
set( IS_BIG_ENDIAN 0 )
if( EC_BIG_ENDIAN )
if( ECCODES_BIG_ENDIAN )
set( IS_BIG_ENDIAN 1 )
endif()
@ -273,6 +304,7 @@ set( ECCODES_DEFINITION_PATH ${the_default_data_prefix}/${ECCODES_DEFINITION_SU
set( ECCODES_SAMPLES_PATH ${the_default_data_prefix}/${ECCODES_SAMPLES_SUFF} )
set( ECCODES_IFS_SAMPLES_PATH ${the_default_data_prefix}/${ECCODES_IFS_SAMPLES_SUFF} )
###############################################################################
### config header
ecbuild_generate_config_headers()

View File

@ -0,0 +1,93 @@
# (C) Copyright 2011- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
test_big_endian( _BIG_ENDIAN )
if( _BIG_ENDIAN )
set( ECCODES_BIG_ENDIAN 1 )
set( ECCODES_LITTLE_ENDIAN 0 )
else()
set( ECCODES_BIG_ENDIAN 0 )
set( ECCODES_LITTLE_ENDIAN 1 )
endif()
set( ECCODES_BIG_ENDIAN ${ECCODES_BIG_ENDIAN} )
set( ECCODES_LITTLE_ENDIAN ${ECCODES_LITTLE_ENDIAN} )
if( NOT DEFINED IEEE_BE )
check_c_source_runs(
"int compare(unsigned char* a,unsigned char* b) {
while(*a != 0) if (*(b++)!=*(a++)) return 1;
return 0;
}
int main(int argc,char** argv) {
unsigned char dc[]={0x30,0x61,0xDE,0x80,0x93,0x67,0xCC,0xD9,0};
double da=1.23456789e-75;
unsigned char* ca;
unsigned char fc[]={0x05,0x83,0x48,0x22,0};
float fa=1.23456789e-35;
if (sizeof(double)!=8) return 1;
ca=(unsigned char*)&da;
if (compare(dc,ca)) return 1;
if (sizeof(float)!=4) return 1;
ca=(unsigned char*)&fa;
if (compare(fc,ca)) return 1;
return 0;
}" IEEE_BE )
if( "${IEEE_BE}" STREQUAL "" )
set( IEEE_BE 0 CACHE INTERNAL "Test IEEE_BE")
endif()
endif()
if( ECCODES_BIG_ENDIAN AND NOT IEEE_BE )
ecbuild_critical("Failed to sanity check on endiness: OS should be Big-Endian but compiled code runs differently -- to ignore this pass -DIEEE_BE=0 to CMake/ecBuild")
endif()
if( NOT DEFINED IEEE_LE )
check_c_source_runs(
"int compare(unsigned char* a,unsigned char* b) {
while(*a != 0) if (*(b++)!=*(a++)) return 1;
return 0;
}
int main(int argc,char** argv) {
unsigned char dc[]={0xD9,0xCC,0x67,0x93,0x80,0xDE,0x61,0x30,0};
double da=1.23456789e-75;
unsigned char* ca;
unsigned char fc[]={0x22,0x48,0x83,0x05,0};
float fa=1.23456789e-35;
if (sizeof(double)!=8) return 1;
ca=(unsigned char*)&da;
if (compare(dc,ca)) return 1;
if (sizeof(float)!=4) return 1;
ca=(unsigned char*)&fa;
if (compare(fc,ca)) return 1;
return 0;
}" IEEE_LE )
if( "${IEEE_LE}" STREQUAL "" )
set( IEEE_LE 0 CACHE INTERNAL "Test IEEE_LE")
endif()
endif()
if( ECCODES_LITTLE_ENDIAN AND NOT IEEE_LE )
ecbuild_critical("Failed to sanity check on endiness: OS should be Little-Endian but compiled code runs differently -- to ignore this pass -DIEEE_LE=0 to CMake/ecBuild")
endif()

View File

@ -23,7 +23,7 @@
#define ECCODES_DEFINITION_PATH "@ECCODES_DEFINITION_PATH@"
#ifdef EC_HAVE_C_INLINE
#ifdef ECCODES_HAVE_C_INLINE
#define GRIB_INLINE inline
#endif
@ -40,35 +40,46 @@
/* headers */
#ifdef EC_HAVE_ASSERT_H
#cmakedefine ECCODES_HAVE_ASSERT_H
#cmakedefine ECCODES_HAVE_STRING_H
#cmakedefine ECCODES_HAVE_SYS_TYPES_H
#cmakedefine ECCODES_HAVE_SYS_STAT_H
#cmakedefine ECCODES_HAVE_FCNTL_H
#cmakedefine ECCODES_HAVE_UNISTD_H
#cmakedefine ECCODES_HAVE_FSEEKO
#cmakedefine ECCODES_HAVE_POSIX_MEMALIGN
#cmakedefine ECCODES_HAVE_FMEMOPEN
#cmakedefine ECCODES_HAVE_FUNOPEN
#if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H)
#define HAVE_ASSERT_H 1
#endif
#ifdef EC_HAVE_STRING_H
#if defined(EC_HAVE_STRING_H) || defined(ECCODES_HAVE_STRING_H)
#define HAVE_STRING_H 1
#endif
#ifdef EC_HAVE_FSEEKO
#define HAVE_FSEEKO 1
#endif
#ifdef EC_HAVE_SYS_TYPES_H
#if defined(EC_HAVE_SYS_TYPES_H) || defined(ECCODES_HAVE_SYS_TYPES_H)
#define HAVE_SYS_TYPES_H 1
#endif
#ifdef EC_HAVE_SYS_STAT_H
#if defined(EC_HAVE_SYS_STAT_H) || defined(ECCODES_HAVE_SYS_STAT_H)
#define HAVE_SYS_STAT_H 1
#endif
#ifdef EC_HAVE_FCNTL_H
#if defined(EC_HAVE_FCNTL_H) || defined(ECCODES_HAVE_FCNTL_H)
#define HAVE_FCNTL_H 1
#endif
#ifdef EC_HAVE_UNISTD_H
#if defined(EC_HAVE_UNISTD_H) || defined(ECCODES_HAVE_UNISTD_H)
#define HAVE_UNISTD_H 1
#endif
#ifdef EC_HAVE_POSIX_MEMALIGN
#if defined(EC_HAVE_FSEEKO) || defined(ECCODES_HAVE_FSEEKO)
#define HAVE_FSEEKO 1
#endif
#if defined(EC_HAVE_POSIX_MEMALIGN) || defined(ECCODES_HAVE_POSIX_MEMALIGN)
#define POSIX_MEMALIGN 1
#endif

View File

@ -13,7 +13,7 @@ if( HAVE_FORTRAN )
COMMAND grib_types > grib_kinds.h
DEPENDS grib_types )
if( ${EC_SIZEOF_INT} EQUAL ${EC_SIZEOF_LONG} )
if( ${ECCODES_SIZEOF_INT} EQUAL ${ECCODES_SIZEOF_LONG} )
set( _long_int_interface grib_f90_int.f90 )
set( _long_int_interface_ec eccodes_f90_int.f90 )
else()
@ -21,7 +21,7 @@ if( HAVE_FORTRAN )
set( _long_int_interface_ec eccodes_f90_long_int.f90 )
endif()
if( ${EC_SIZEOF_INT} EQUAL ${EC_SIZEOF_SIZE_T} )
if( ${ECCODES_SIZEOF_INT} EQUAL ${ECCODES_SIZEOF_SIZE_T} )
set( _sizet_int_interface grib_f90_int_size_t.f90 )
set( _sizet_int_interface_ec eccodes_f90_int_size_t.f90 )
else()