Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize stack creation.
[simgrid.git] / src / smpi / smpicc.in
1 #! /bin/sh
2
3 # Copyright (c) 2007-2014. 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 CC=@CMAKE_C_COMPILER@
10
11 INCLUDEARGS="@includeflag@"
12 CMAKE_LINKARGS="-L@libdir@"
13
14 @SMPITOOLS_SH@
15
16 list_set CFLAGS
17 list_set LINKARGS
18 if [ "@WIN32@" != "1" ]; then
19     list_add CFLAGS "-Dmain=smpi_simulated_main_"
20     list_add LINKARGS "-lsimgrid"
21 else
22     list_add CFLAGS "-include" "@includedir@/smpi/smpi_main.h"
23     list_add LINKARGS "@libdir@\libsimgrid.dll"
24 fi
25
26 list_set CMDARGS
27 while [ $# -gt 0 ]; do
28     ARG="$1"
29     shift
30     case "${ARG}" in
31         -c)
32             CMAKE_LINKARGS=""
33             LINKARGS=""
34             list_add CMDARGS "-c"
35             ;;
36         *.c)
37             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
38             if [ -z "$SRCFILE" ] ; then
39                 SRCFILE="$ARG"
40             fi
41             list_add CMDARGS "${SRCFILE}"
42             ;;
43         *)
44             list_add CMDARGS "${ARG}"
45       ;;
46   esac
47 done
48
49 list_set CMDLINE "${CC}"
50 list_add_not_empty CMDLINE "${CFLAGS}"
51 list_add_not_empty CMDLINE ${INCLUDEARGS}
52 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
53 list_add_not_empty CMDLINE "${CMDARGS}"
54 list_add_not_empty CMDLINE "${LINKARGS}"
55
56 eval $(list_get CMDLINE)
57 "$@"