Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Restore explicitely defined constructor (with empty body).
[simgrid.git] / src / smpi / smpicc.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2007-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 CC=@CMAKE_C_COMPILER@
13
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
16
17 @SMPITOOLS_SH@
18
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=""
22 else
23     LINKER_UNDEFINED_ERROR="1"
24 fi
25
26 list_set CFLAGS @SMPI_C_FLAGS@
27 list_add LINKARGS
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     else
37        echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
38     fi
39     list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
40 else
41     list_add CFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
42     list_add CFLAGS "-fPIC"
43     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
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     list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
49 fi
50
51 list_set CMDARGS
52 while [ $# -gt 0 ]; do
53     ARG="$1"
54     shift
55     case "${ARG}" in
56         -c)
57             CMAKE_LINKARGS=""
58             LINKARGS=""
59             list_add CMDARGS "-c"
60             ;;
61         *.c)
62             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
63             if [ -z "$SRCFILE" ] ; then
64                 SRCFILE="$ARG"
65             fi
66             list_add CMDARGS "${SRCFILE}"
67             ;;
68         '-version' | '--version')
69             printf '%b\n' "$SIMGRID_VERSION"
70             exit 0
71             ;;
72         "-git-version" | "--git-version")
73             printf '%b\n' "$SIMGRID_GITHASH"
74             exit 0
75             ;;
76         '-trace-call-location')
77             list_add_not_empty CMDARGS "-DTRACE_CALL_LOCATION"
78             ;;
79         '-compiler-version' | '--compiler-version')
80             ${CC} --version
81             ;;
82         '-show'|'-compile-info'|'-link-info')
83             # Dry run displaying commands instead of executing them. Useful to cmake
84             show=1
85             ;;
86          *)
87             list_add CMDARGS "${ARG}"
88             ;;
89     esac
90 done
91
92 list_set CMDLINE "${CC}"
93 list_add_not_empty CMDLINE "${CFLAGS}"
94 list_add_not_empty CMDLINE ${INCLUDEARGS}
95 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
96 list_add_not_empty CMDLINE "${CMDARGS}"
97 list_add_not_empty CMDLINE "${LINKARGS}"
98
99 eval $(list_get CMDLINE)
100 if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
101   echo "$@"
102   [ "x$show" = x1 ] && exit 0
103 fi
104 "$@"