Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow smpicc to survive to non-functionnal readlink on mac (by doing as if there...
[simgrid.git] / src / smpi / smpicc.in
index a92f30f..c46d186 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/bash
 #FIXME: .. paths...
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
@@ -11,7 +11,9 @@ TMPDIR="$(mktemp -d tmpXXXXXXX)"
 
 function modsource {
   SOURCE="$1"
-  SOURCEFILE="$(basename ${SOURCE})"
+  ## basename is not available on MAcOSX : SOURCEFILE="$(basename ${SOURCE})"
+  SOURCEFILE="`echo ${SOURCE} | egrep -o '[^/]+$'`"
+
   SOURCEDIR="${SOURCE%${SOURCEFILE}}"
   if [ -n "${SOURCEDIR}" ]; then
     mkdir -p ${TMPDIR}${SOURCEDIR}
@@ -19,12 +21,13 @@ function modsource {
   TMPSOURCE="${TMPDIR}${SOURCE}"
   cat > ${TMPSOURCE} <<HEADER
 #define SEED ${SEED}
-#include "smpi.h"
+#include "smpi/smpi.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/asserts.h"
 #define sleep(x) smpi_sleep(x)
 #define gettimeofday(x, y) smpi_gettimeofday(x, y)
+int smpi_run_simulation(int *argc, char **argv);
 HEADER
   # very simplistic transform, will probably want full parser for next version
   grep -v "mpi.h" < ${SOURCE} | perl -pe 's/main/smpi_simulated_main/;' >> ${TMPSOURCE}
@@ -38,8 +41,8 @@ FOOTER
   fi
 }
 
-INCLUDEARGS=""
-LINKARGS="-L@libdir@ -lsimgrid -lsmpi "
+INCLUDEARGS="-I @top_srcdir@/include "
+LINKARGS="-L@top_builddir@/src/.libs -L@libdir@ -lsimgrid -lsmpi "
 
 CMDLINE=""
 while [ -n "$1" ]; do
@@ -49,8 +52,12 @@ while [ -n "$1" ]; do
       LINKARGS=""
       CMDLINE="${CMDLINE} -c "
   elif [ "${ARG%.c}" != "${ARG}" ]; then
-    INCLUDEARGS="-I . -I .. -I ../include -I @includedir@ "
-    SRCFILE="$(realpath ${ARG})"
+    INCLUDEARGS="${INCLUDEARGS} -I . -I .. -I ../include -I @includedir@ "
+#    SRCFILE="$(realpath ${ARG})"
+    SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
+    if [ -z $SRCFILE ] ; then
+      SRCFILE="$ARG"
+    fi
     modsource ${SRCFILE}
     CMDLINE="${CMDLINE} ${TMPDIR}${SRCFILE} "
   else
@@ -58,7 +65,7 @@ while [ -n "$1" ]; do
   fi
 done
 
-CMDLINE="${CC} ${INCLUDEARGS} ${CMDLINE} ${LINKARGS}"
+CMDLINE="${CC} ${INCLUDEARGS} ${CFLAGS} ${CMDLINE} ${LINKARGS}"
 
 #echo "${CMDLINE}"
 ${CMDLINE}