Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Leak-- (seen in maestro-set).
[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 [ "x@WIN32@" = "x1" ]; then
22     list_add CFLAGS "-include" "@includedir@/smpi/smpi_main.h"
23     list_add LINKARGS "@libdir@\libsimgrid.dll"
24 elif [ "x@APPLE@" = "x1" ]; then
25     list_add CFLAGS "-fpic"
26     list_add LINKARGS "-shared" "-lsimgrid" "-Wl,-undefined,error"
27 else
28     list_add CFLAGS "-fpic"
29     list_add LINKARGS "-shared" "-lsimgrid" "-Wl,-z,defs"
30 fi
31
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         '-trace-call-location')
59             list_add_not_empty CMDARGS "-DTRACE_CALL_LOCATION"
60             ;;
61         '-compiler-version' | '--compiler-version')
62             ${CC} --version
63             ;;
64         *)
65             list_add CMDARGS "${ARG}"
66             ;;
67     esac
68 done
69
70 list_set CMDLINE "${CC}"
71 list_add_not_empty CMDLINE "${CFLAGS}"
72 list_add_not_empty CMDLINE ${INCLUDEARGS}
73 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
74 list_add_not_empty CMDLINE "${CMDARGS}"
75 list_add_not_empty CMDLINE "${LINKARGS}"
76
77 eval $(list_get CMDLINE)
78 "$@"