Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
241757c1052c48c46df27867ff6e9fea8d74213c
[simgrid.git] / src / smpi / smpicxx.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2014-2017. 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
20 list_set LINKARGS
21 if [ "@WIN32@" != "1" ]; then
22     # list_add CXXFLAGS "-Dmain=smpi_simulated_main_"
23     list_add CXXFLAGS "-fpic" "-std=gnu++11"
24     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
25        list_add LINKARGS "-shared"
26     fi
27     list_add LINKARGS "-lsimgrid" "-std=gnu++11"
28 else
29     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h" "-std=gnu++11"
30     list_add LINKARGS "@libdir@\libsimgrid.dll" "-std=gnu++11"
31 fi
32
33 list_set CMDARGS
34 while [ $# -gt 0 ]; do
35     ARG="$1"
36     shift
37     case "${ARG}" in
38         -c)
39             CMAKE_LINKARGS=""
40             LINKARGS=""
41             list_add CMDARGS "-c"
42             ;;
43         *.c)
44             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
45             if [ -z "$SRCFILE" ] ; then
46                 SRCFILE="$ARG"
47             fi
48             list_add CMDARGS "${SRCFILE}"
49             ;;
50         '-version' | '--version')
51             printf '%b\n' "$SIMGRID_VERSION"
52             exit 0
53             ;;
54         "-git-version" | "--git-version")
55             printf '%b\n' "$SIMGRID_GITHASH"
56             exit 0
57             ;;
58         '-compiler-version' | '--compiler-version')
59             ${CXX} --version
60             ;;
61         *)
62             list_add CMDARGS "${ARG}"
63       ;;
64   esac
65 done
66
67 list_set CMDLINE "${CXX}"
68 list_add_not_empty CMDLINE "${CXXFLAGS}"
69 list_add_not_empty CMDLINE ${INCLUDEARGS}
70 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
71 list_add_not_empty CMDLINE "${CMDARGS}"
72 list_add_not_empty CMDLINE "${LINKARGS}"
73
74 eval $(list_get CMDLINE)
75 "$@"