]> AND Public Git Repository - simgrid.git/blobdiff - src/smpi/smpicxx.in
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid going back to complex selector and switch to a simple algorithm here to avoid...
[simgrid.git] / src / smpi / smpicxx.in
index 2ef3b5e64f0c551017e576cbc8681968ad140719..ac2beeb4ba386a541c0812877cf445608c53f08e 100755 (executable)
@@ -1,13 +1,13 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2014-2020. The SimGrid Team.
+# Copyright (c) 2014-2022. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
 
 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
-SIMGRID_GITHASH="@SIMGRID_GITHASH@"
+SIMGRID_GITHASH="@GIT_VERSION@"
 
 CXX=@CMAKE_CXX_COMPILER@
 
@@ -19,7 +19,7 @@ CMAKE_LINKARGS="-L@libdir@"
 list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@
 list_set LINKARGS
 
-if [ "@CMAKE_C_COMPILER_ID@" = "Clang" -a "@HAVE_SANITIZER_ADDRESS@" = "TRUE" ]; then
+if [ "@CMAKE_C_COMPILER_ID@" = "Clang" ] && [ "@HAVE_SANITIZER_ADDRESS@" = "TRUE" ]; then
     LINKER_UNDEFINED_ERROR=""
 else
     LINKER_UNDEFINED_ERROR="1"
@@ -29,26 +29,26 @@ if [ "x@WIN32@" = "x1" ]; then
     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h"
     list_add LINKARGS "@libdir@\libsimgrid.dll"
 elif [ "x@APPLE@" = "x1" ]; then
-    list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
     list_add CXXFLAGS "-fPIC"
     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
+       list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
        list_add LINKARGS "-shared"
     else
        echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
     fi
     if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
-      list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
+      list_add LINKARGS "-lsimgrid" "-lm" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
     fi
 else
-    list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
     list_add CXXFLAGS "-fPIC"
     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
+       list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
        list_add LINKARGS "-shared"
     else
        echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
     fi
     if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
-      list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
+      list_add LINKARGS "-lsimgrid" "-lm"  ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
     fi
 fi
 
@@ -63,7 +63,7 @@ while [ $# -gt 0 ]; do
             list_add CMDARGS "-c"
             ;;
         *.c)
-            SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
+            SRCFILE="$(readlink -f "${ARG}" 2>/dev/null)"
             if [ -z "$SRCFILE" ] ; then
                 SRCFILE="$ARG"
             fi
@@ -93,12 +93,12 @@ done
 list_set CMDLINE "${CXX}"
 list_add_not_empty CMDLINE "${CXXFLAGS}"
 list_add_not_empty CMDLINE ${INCLUDEARGS}
-list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
+list_add_not_empty CMDLINE "${CMAKE_LINKARGS}"
 list_add_not_empty CMDLINE "${CMDARGS}"
 list_add_not_empty CMDLINE "${LINKARGS}"
 
 eval $(list_get CMDLINE)
-if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+if [ "x$VERBOSE" = x1 ] || [ "x$show" = x1 ] ; then
   echo "$@"
   [ "x$show" = x1 ] && exit 0
 fi