Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'toufic' of github.com:Takishipp/simgrid
[simgrid.git] / src / smpi / smpicc.in
1 #! /bin/sh
2
3 # Copyright (c) 2007-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 CC=@CMAKE_C_COMPILER@
13
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
16
17 @SMPITOOLS_SH@
18
19 list_set CFLAGS
20 list_set LINKARGS
21 if [ "@WIN32@" != "1" ]; then
22     # list_add CFLAGS "-Dmain=smpi_simulated_main_"
23     list_add CFLAGS "-fpic"
24     list_add LINKARGS "-shared" "-lsimgrid" "-Wl,-z,defs"
25 else
26     list_add CFLAGS "-include" "@includedir@/smpi/smpi_main.h"
27     list_add LINKARGS "@libdir@\libsimgrid.dll"
28 fi
29
30 list_set CMDARGS
31 while [ $# -gt 0 ]; do
32     ARG="$1"
33     shift
34     case "${ARG}" in
35         -c)
36             CMAKE_LINKARGS=""
37             LINKARGS=""
38             list_add CMDARGS "-c"
39             ;;
40         *.c)
41             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
42             if [ -z "$SRCFILE" ] ; then
43                 SRCFILE="$ARG"
44             fi
45             list_add CMDARGS "${SRCFILE}"
46             ;;
47         '-version' | '--version')
48             printf '%b\n' "$SIMGRID_VERSION"
49             exit 0
50             ;;
51         "-git-version" | "--git-version")
52             printf '%b\n' "$SIMGRID_GITHASH"
53             exit 0
54             ;;
55         '-trace-call-location')
56             list_add_not_empty CMDARGS "-DTRACE_CALL_LOCATION"
57             ;;
58         '-compiler-version' | '--compiler-version')
59             ${CC} --version
60             ;;
61         *)
62             list_add CMDARGS "${ARG}"
63             ;;
64     esac
65 done
66
67 list_set CMDLINE "${CC}"
68 list_add_not_empty CMDLINE "${CFLAGS}"
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 "$@"