Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Actor: make the refcount observable, and improve debug messages
[simgrid.git] / src / smpi / smpicxx.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2014-2019. The SimGrid Team.
4 # All rights reserved.
5
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.
8
9 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
10 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
11
12 CXX=@CMAKE_CXX_COMPILER@
13
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
16
17 @SMPITOOLS_SH@
18
19 list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@
20 list_set LINKARGS
21 if [ "@WIN32@" != "1" ]; then
22     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
23     list_add CXXFLAGS "-fPIC"
24     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
25        list_add LINKARGS "-shared"
26     else
27        echo "Warning: smpicxx pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
28     fi
29     list_add LINKARGS "-lsimgrid"
30 else
31     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h"
32     list_add LINKARGS "@libdir@\libsimgrid.dll"
33 fi
34
35 # By default, we execute the commands instead of only showing them to cmake
36 show=
37
38 list_set CMDARGS
39 while [ $# -gt 0 ]; do
40     ARG="$1"
41     shift
42     case "${ARG}" in
43         -c)
44             CMAKE_LINKARGS=""
45             LINKARGS=""
46             list_add CMDARGS "-c"
47             ;;
48         *.c)
49             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
50             if [ -z "$SRCFILE" ] ; then
51                 SRCFILE="$ARG"
52             fi
53             list_add CMDARGS "${SRCFILE}"
54             ;;
55         '-version' | '--version')
56             printf '%b\n' "$SIMGRID_VERSION"
57             exit 0
58             ;;
59         "-git-version" | "--git-version")
60             printf '%b\n' "$SIMGRID_GITHASH"
61             exit 0
62             ;;
63         '-compiler-version' | '--compiler-version')
64             ${CXX} --version
65             ;;
66         '-show'|'-compile-info'|'-link-info')
67             # Dry run displaying commands instead of executing them. Useful to cmake
68             show=1
69             ;;
70         *)
71             list_add CMDARGS "${ARG}"
72       ;;
73   esac
74 done
75
76 list_set CMDLINE "${CXX}"
77 list_add_not_empty CMDLINE "${CXXFLAGS}"
78 list_add_not_empty CMDLINE ${INCLUDEARGS}
79 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
80 list_add_not_empty CMDLINE "${CMDARGS}"
81 list_add_not_empty CMDLINE "${LINKARGS}"
82
83 eval $(list_get CMDLINE)
84 if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
85   echo "$@"
86   [ "x$show" = x1 ] && exit 0
87 fi
88 "$@"