Changeset 7549


Ignore:
Timestamp:
08/02/18 00:18:24 (2 weeks ago)
Author:
baker
Message:

add (disabled) USE_CC_BITS option to use default compiler target bits; use simpler if [] (test) syntax

Location:
trunk/environment
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/environment/ew_linux.bash

    r7547 r7549  
    1 # Create an Earthworm environment on Linux 
     1# Enable USE_CC_BITS to default EW_BITs to the compiler target (removes -m32/64) 
     2# Otherwise, the default is 32, as it was 
     3#USE_CC_BITS=true 
     4 
     5# Create an Earthworm environment on PC Linux 
    26# This file should be sourced by a Bourne shell wanting  
    3 # to run or build an EARTHWORM system under Linux. 
     7# to run or build an EARTHWORM system under Linux on a PC. 
    48 
    59# For running EW on Linux, if any ports are used, make sure that your 
     
    3640# Set environment variables for compiling Earthworm modules 
    3741 
    38 # Set EW_BITS=64 to build for 64-bit target (note that with EW_BITS=64 
    39 #  size of 'long' type changes from 4 bytes to 8 bytes) 
    40 export EW_BITS="${EW_INSTALL_BITS:-32}" 
     42# Be explicit about which compilers to use (only CC is checked for validity) 
     43CC=gcc 
     44CXX=g++ 
    4145 
    42 # Warning flags for compiler: 
    43 export WARNFLAGS="-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-pragmas -Wformat -Wdeclaration-after-statement" 
    44 # Extra flags for enabling more warnings during code development: 
    45 #export WARNFLAGS="-Wall -Wextra -Wcast-align -Wpointer-arith -Wbad-function-cast -Winline -Wundef -Wnested-externs -Wshadow -Wfloat-equal -Wno-unused-parameter -Wformat -Wdeclaration-after-statement" 
     46if [ "${CC}" = "gcc" ] ; then 
    4647 
    47 # -D_FILE_OFFSET_BITS=64 is for Large Filesystem Support (64-bit offsets) on a 32-bit compile (gcc only); it is benign on a 64-bit compile 
     48   export CC 
     49   export CXX 
    4850 
    49 export GLOBALFLAGS="-m${EW_BITS} -g -D_LINUX -Dlinux -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_USE_TERMIOS -D_FILE_OFFSET_BITS=64 -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}" 
    50 export PLATFORM="LINUX" 
     51   # Set EW_BITS=64 to build for 64-bit target (note that with EW_BITS=64 
     52   # size of 'long' type changes from 4 bytes to 8 bytes) 
    5153 
    52 export LINK_LIBS="-lm -lpthread" 
     54   if [ -n "${USE_CC_BITS}" ] ; then 
     55      # gcc target prefix is "i686" on 32-bit PCs, "x86_64" on 64-bit PCs 
     56      CC_BITS=`${CC} -v 2>&1 | 
     57               awk '/^Target:/{ 
     58                       split( $2, arch, "-" ); 
     59                       if ( arch[1] == "x86_64" ) 
     60                          print( "64" ) 
     61                       else 
     62                          print( "32" ) 
     63                    }'` 
     64      if [ -n "${EW_INSTALL_BITS}" ] ; then 
     65         export EW_BITS="${EW_INSTALL_BITS}" 
     66         TARGET="-m${EW_BITS} " 
     67      else 
     68         export EW_BITS="${CC_BITS}" 
     69         TARGET="" 
     70      fi 
     71   else 
     72      export EW_BITS="${EW_INSTALL_BITS:-32}" 
     73      TARGET="-m${EW_BITS} " 
     74   fi 
    5375 
    54 # Be explicit about which compilers to use 
    55 export CC=gcc 
    56 export CXX=g++ 
     76   # Warning flags for compiler: 
     77   export WARNFLAGS="-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-pragmas -Wformat -Wdeclaration-after-statement" 
     78   # Extra flags for enabling more warnings during code development: 
     79   #export WARNFLAGS="-Wall -Wextra -Wcast-align -Wpointer-arith -Wbad-function-cast -Winline -Wundef -Wnested-externs -Wshadow -Wfloat-equal -Wno-unused-parameter -Wformat -Wdeclaration-after-statement" 
    5780 
    58 # Set initial defaults 
    59 export CFLAGS=${GLOBALFLAGS} 
    60 export CXXFLAGS=${GLOBALFLAGS} 
     81   # -D_FILE_OFFSET_BITS=64 is for Large Filesystem Support (64-bit offsets) on a 32-bit compile (gcc only); it is benign on a 64-bit compile 
     82 
     83   export GLOBALFLAGS="${TARGET}-g -D_LINUX -Dlinux -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_USE_TERMIOS -D_FILE_OFFSET_BITS=64 -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}" 
     84   export PLATFORM="LINUX" 
     85 
     86   export LINK_LIBS="-lm -lpthread" 
     87 
     88   # Set initial defaults 
     89   export CFLAGS=${GLOBALFLAGS} 
     90   export CXXFLAGS=${GLOBALFLAGS} 
     91 
     92else 
     93 
     94   echo "CC must be gcc" 
     95 
     96fi 
    6197 
    6298# Pick a Fortran compiler 
     
    66102#FC=ifort 
    67103 
    68 if [[ "${FC}" = "gfortran" ]] ; then 
     104if [ "${FC}" = "gfortran" ] ; then 
    69105 
    70106   export FC 
    71107   # Extra run-time checks: -fcheck=all 
    72    #export FFLAGS="-m${EW_BITS} -O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace" 
    73    export FFLAGS="-m${EW_BITS} -O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace" 
     108   #export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace" 
     109   export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace" 
    74110 
    75111   # FC_MAIN_IS_C is not needed with gfortran 
    76112   #export FC_MAIN_IS_C=-nofor-main 
    77113 
    78 elif [[ "${FC}" = "ifort" ]] ; then 
     114elif [ "${FC}" = "ifort" ] ; then 
    79115 
    80116   export FC 
     
    82118   # ifort version 15 introduced the -init option; older compilers complain, but ignore it 
    83119   # ifort complains about comments past column 72; -warn truncated_source is pretty useless 
    84    #export FFLAGS="-m${EW_BITS} -O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback" 
    85    export FFLAGS="-m${EW_BITS} -O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback" 
     120   #export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback" 
     121   export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback" 
    86122 
    87123   # Intel Fortran supplies main() unless told not to 
  • trunk/environment/ew_macosx_intel.sh

    r7479 r7549  
    1 # Create an Earthworm environment on Mac OS X 
     1# Enable USE_CC_BITS to default EW_BITs to the compiler target (removes -m32/64) 
     2# Otherwise, the default is 32, as it was 
     3#USE_CC_BITS=true 
     4 
     5# Create an Earthworm environment on Intel Mac OS X 
    26# This file should be sourced by a Bourne shell wanting  
    3 # to run or build an EARTHWORM system under Mac OS X. 
     7# to run or build an EARTHWORM system under Intel Mac OS X. 
    48 
    59# For running EW on a Mac, if any ports are used, make sure that your 
     
    3640# Set environment variables for compiling Earthworm modules 
    3741 
    38 # Set EW_BITS=64 to build for 64-bit target (note that with EW_BITS=64 
    39 #  size of 'long' type changes from 4 bytes to 8 bytes) 
    40 export EW_BITS="${EW_INSTALL_BITS:-32}" 
     42# Be explicit about which compilers to use (only CC is checked for validity) 
     43CC=gcc 
     44CXX=g++ 
    4145 
    42 # Warning flags for compiler: 
    43 export WARNFLAGS="-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-pragmas -Wformat -Wdeclaration-after-statement" 
    44 # Extra flags for enabling more warnings during code development: 
    45 #export WARNFLAGS="-Wall -Wextra -Wcast-align -Wpointer-arith -Wbad-function-cast -Winline -Wundef -Wnested-externs -Wshadow -Wfloat-equal -Wno-unused-parameter -Wformat -Wdeclaration-after-statement" 
     46if [ "${CC}" = "gcc" ] ; then 
    4647 
    47 # -D_DARWIN_USE_64_BIT_INODE (OSX 10.5 and later) is for 64-bit inode numbers (see man 2 stat) 
     48   export CC 
     49   export CXX 
    4850 
    49 export GLOBALFLAGS="-m${EW_BITS} -g -D_MACOSX -D_DARWIN_C_SOURCE -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_DARWIN_USE_64_BIT_INODE -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}" 
    50 export PLATFORM="LINUX" # Uses the same make options as Linux, so used here 
     51   # Set EW_BITS=64 to build for 64-bit target (note that with EW_BITS=64 
     52   # size of 'long' type changes from 4 bytes to 8 bytes) 
    5153 
    52 # This is needed to get the Mac linker to work with some modules 
    53 export LDFLAGS=-Wl,-search_paths_first 
     54   if [ -n "${USE_CC_BITS}" ] ; then 
     55      # gcc target prefix is "i686" on 32-bit PCs, "x86_64" on 64-bit PCs 
     56      CC_BITS=`${CC} -v 2>&1 | 
     57               awk '/^Target:/{ 
     58                       split( $2, arch, "-" ); 
     59                       if ( arch[1] == "x86_64" ) 
     60                          print( "64" ) 
     61                       else 
     62                          print( "32" ) 
     63                    }'` 
     64      if [ -n "${EW_INSTALL_BITS}" ] ; then 
     65         export EW_BITS="${EW_INSTALL_BITS}" 
     66         TARGET="-m${EW_BITS} " 
     67      else 
     68         export EW_BITS="${CC_BITS}" 
     69         TARGET="" 
     70      fi 
     71   else 
     72      export EW_BITS="${EW_INSTALL_BITS:-32}" 
     73      TARGET="-m${EW_BITS} " 
     74   fi 
    5475 
    55 # Be explicit about which compilers to use 
    56 export CC=gcc 
    57 export CXX=g++ 
     76   # Warning flags for compiler: 
     77   export WARNFLAGS="-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-pragmas -Wformat -Wdeclaration-after-statement" 
     78   # Extra flags for enabling more warnings during code development: 
     79   #export WARNFLAGS="-Wall -Wextra -Wcast-align -Wpointer-arith -Wbad-function-cast -Winline -Wundef -Wnested-externs -Wshadow -Wfloat-equal -Wno-unused-parameter -Wformat -Wdeclaration-after-statement" 
    5880 
    59 # Set initial defaults 
    60 export CFLAGS=${GLOBALFLAGS} 
    61 export CXXFLAGS=${GLOBALFLAGS} 
     81   # -D_DARWIN_USE_64_BIT_INODE (OSX 10.5 and later) is for 64-bit inode numbers (see man 2 stat) 
     82 
     83   export GLOBALFLAGS="${TARGET}-g -D_MACOSX -D_DARWIN_C_SOURCE -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_DARWIN_USE_64_BIT_INODE -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}" 
     84   export PLATFORM="LINUX" # Uses the same make options as Linux, so used here 
     85 
     86   # This is needed to get the Mac linker to work with some modules 
     87   export LDFLAGS=-Wl,-search_paths_first 
     88 
     89   # Set initial defaults 
     90   export CFLAGS=${GLOBALFLAGS} 
     91   export CXXFLAGS=${GLOBALFLAGS} 
     92 
     93else 
     94 
     95   echo "CC must be gcc" 
     96 
     97fi 
    6298 
    6399# Pick a Fortran compiler 
     
    67103#FC=ifort 
    68104 
    69 if [[ "${FC}" = "gfortran" ]] ; then 
     105if [ "${FC}" = "gfortran" ] ; then 
    70106 
    71107   export FC 
    72108   # Extra run-time checks: -fcheck=all 
    73    #export FFLAGS="-m${EW_BITS} -O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace" 
    74    export FFLAGS="-m${EW_BITS} -O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace" 
     109   #export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace" 
     110   export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace" 
    75111 
    76112   # FC_MAIN_IS_C is not needed with gfortran 
    77113   #export FC_MAIN_IS_C=-nofor-main 
    78114 
    79 elif [[ "${FC}" = "ifort" ]] ; then 
     115elif [ "${FC}" = "ifort" ] ; then 
    80116 
    81117   export FC 
     
    83119   # ifort version 15 introduced the -init option; older compilers complain, but ignore it 
    84120   # ifort complains about comments past column 72; -warn truncated_source is pretty useless 
    85    #export FFLAGS="-m${EW_BITS} -O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback" 
    86    export FFLAGS="-m${EW_BITS} -O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback" 
     121   #export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback" 
     122   export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback" 
    87123 
    88124   # Intel Fortran supplies main() unless told not to 
Note: See TracChangeset for help on using the changeset viewer.