Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
smpicc: don't add -shared when SMPI_PRETEND_CC is on
[simgrid.git] / src / smpi / smpicc.in
1 #!/usr/bin/env 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     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
27        list_add LINKARGS "-shared"
28     fi
29     list_add LINKARGS "-lsimgrid" "-Wl,-undefined,error"
30 else
31     list_add CFLAGS "-fpic"
32     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
33        list_add LINKARGS "-shared"
34     fi
35     list_add LINKARGS "-lsimgrid" "-Wl,-z,defs"
36 fi
37
38
39 list_set CMDARGS
40 while [ $# -gt 0 ]; do
41     ARG="$1"
42     shift
43     case "${ARG}" in
44         -c)
45             CMAKE_LINKARGS=""
46             LINKARGS=""
47             list_add CMDARGS "-c"
48             ;;
49         *.c)
50             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
51             if [ -z "$SRCFILE" ] ; then
52                 SRCFILE="$ARG"
53             fi
54             list_add CMDARGS "${SRCFILE}"
55             ;;
56         '-version' | '--version')
57             printf '%b\n' "$SIMGRID_VERSION"
58             exit 0
59             ;;
60         "-git-version" | "--git-version")
61             printf '%b\n' "$SIMGRID_GITHASH"
62             exit 0
63             ;;
64         '-trace-call-location')
65             list_add_not_empty CMDARGS "-DTRACE_CALL_LOCATION"
66             ;;
67         '-compiler-version' | '--compiler-version')
68             ${CC} --version
69             ;;
70         *)
71             list_add CMDARGS "${ARG}"
72             ;;
73     esac
74 done
75
76 list_set CMDLINE "${CC}"
77 list_add_not_empty CMDLINE "${CFLAGS}"
78 list_add_not_empty CMDLINE ${INCLUDEARGS}
79 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
80 list_add_not_empty CMDLINE "${CMDARGS}"
81 list_add_not_empty CMDLINE "${LINKARGS}"
82
83 eval $(list_get CMDLINE)
84 "$@"