3 # Copyright (c) 2007-2020. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
9 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
10 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
19 # Don't use -Wl,-z-defs with Clang and address sanitizer
20 if [ "@CMAKE_C_COMPILER_ID@" = "Clang" -a "@HAVE_SANITIZER_ADDRESS@" = "TRUE" ]; then
21 LINKER_UNDEFINED_ERROR=""
23 LINKER_UNDEFINED_ERROR="1"
26 list_set CFLAGS @SMPI_C_FLAGS@
28 if [ "x@WIN32@" = "x1" ]; then
29 list_add CFLAGS "-include" "@includedir@/smpi/smpi_main.h"
30 list_add LINKARGS "@libdir@\libsimgrid.dll"
31 elif [ "x@APPLE@" = "x1" ]; then
32 list_add CFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
33 list_add CFLAGS "-fPIC"
34 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
35 list_add LINKARGS "-shared"
36 if [ "@APPLE@" != "1" ]; then
37 list_add LINKARGS "-Wl,-z,defs"
40 echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
42 list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
44 list_add CFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
45 list_add CFLAGS "-fPIC"
46 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
47 list_add LINKARGS "-shared"
49 echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
51 list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
55 while [ $# -gt 0 ]; do
65 SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
66 if [ -z "$SRCFILE" ] ; then
69 list_add CMDARGS "${SRCFILE}"
71 '-version' | '--version')
72 printf '%b\n' "$SIMGRID_VERSION"
75 "-git-version" | "--git-version")
76 printf '%b\n' "$SIMGRID_GITHASH"
79 '-trace-call-location')
80 list_add_not_empty CMDARGS "-DTRACE_CALL_LOCATION"
82 '-compiler-version' | '--compiler-version')
85 '-show'|'-compile-info'|'-link-info')
86 # Dry run displaying commands instead of executing them. Useful to cmake
90 list_add CMDARGS "${ARG}"
95 list_set CMDLINE "${CC}"
96 list_add_not_empty CMDLINE "${CFLAGS}"
97 list_add_not_empty CMDLINE ${INCLUDEARGS}
98 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
99 list_add_not_empty CMDLINE "${CMDARGS}"
100 list_add_not_empty CMDLINE "${LINKARGS}"
102 eval $(list_get CMDLINE)
103 if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
105 [ "x$show" = x1 ] && exit 0