Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
check that disk has been given as argument before accessing its pimpl
[simgrid.git] / src / smpi / smpicxx.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2014-2022. 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="@GIT_VERSION@"
11
12 CXX=@CMAKE_CXX_COMPILER@
13
14 @SMPITOOLS_SH@
15
16 list_set INCLUDEARGS @includeflag@
17 list_set CMAKE_LINKARGS "-L@libdir@"
18
19 list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@
20 list_set LINKARGS
21
22 if [ "@CMAKE_C_COMPILER_ID@" = "Clang" ] && [ "@HAVE_SANITIZER_ADDRESS@" = "TRUE" ]; then
23     LINKER_UNDEFINED_ERROR=""
24 else
25     LINKER_UNDEFINED_ERROR="1"
26 fi
27
28 if [ "x@WIN32@" = "x1" ]; then
29     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h"
30     list_add LINKARGS "@libdir@\libsimgrid.dll"
31 elif [ "x@APPLE@" = "x1" ]; then
32     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
33        list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
34        list_add LINKARGS "-shared"
35     else
36        echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
37     fi
38     if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
39       list_add LINKARGS "-lsimgrid" "-lm" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
40     fi
41 else
42     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
43        list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
44        list_add LINKARGS "-shared"
45     else
46        echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
47     fi
48     if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
49       list_add LINKARGS "-lsimgrid" "-lm"  ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
50     fi
51 fi
52
53 list_set CMDARGS
54 while [ $# -gt 0 ]; do
55     ARG="$1"
56     shift
57     case "${ARG}" in
58         -c)
59             CMAKE_LINKARGS=""
60             LINKARGS=""
61             list_add CMDARGS "-c"
62             ;;
63         *.c)
64             SRCFILE="$(readlink -f "${ARG}" 2>/dev/null)"
65             if [ -z "$SRCFILE" ] ; then
66                 SRCFILE="$ARG"
67             fi
68             list_add CMDARGS "${SRCFILE}"
69             ;;
70         '-version' | '--version')
71             printf '%b\n' "$SIMGRID_VERSION"
72             exit 0
73             ;;
74         "-git-version" | "--git-version")
75             printf '%b\n' "$SIMGRID_GITHASH"
76             exit 0
77             ;;
78         '-compiler-version' | '--compiler-version')
79             ${CXX} --version
80             ;;
81         '-show'|'-compile-info'|'-link-info')
82             # Dry run displaying commands instead of executing them. Useful to cmake
83             show=1
84             ;;
85         *)
86             list_add CMDARGS "${ARG}"
87       ;;
88   esac
89 done
90
91 if [ "x@WIN32@" != "x1" ]; then
92     list_add CMDARGS "-fPIC"
93 fi
94
95 list_set CMDLINE "${CXX}"
96 list_add_not_empty CMDLINE "${CXXFLAGS}"
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}"
101
102 eval $(list_get CMDLINE)
103 if [ "x$VERBOSE" = x1 ] || [ "x$show" = x1 ] ; then
104   echo "$@"
105   [ "x$show" = x1 ] && exit 0
106 fi
107 "$@"