#! /bin/sh # Copyright (c) 2010-2014. The SimGrid Team. # All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. prefix="@exec_prefix@" smpicc="$prefix/bin/smpicc" smpif2c="$prefix/bin/smpif2c" @SMPITOOLS_SH@ list_set ARGS "-DMAIN__=user_main" "-Diargc_=smpi_process_argc" "-Dgetarg_=smpi_process_getarg" list_set LINKARGS "-L@F2C_LIBRARY_PATH@" "-lf2c" "-lm" list_set SRCFILES while [ $# -gt 0 ]; do ARG="$1" shift case "${ARG}" in *.f) SRCFILE="$(readlink -f ${ARG} 2>/dev/null)" if [ -z "$SRCFILE" ] ; then SRCFILE="$ARG" fi list_add SRCFILES "${SRCFILE}" ;; *) if [ "${ARG}" = "-c" ]; then LINKARGS="" fi list_add ARGS "${ARG}" ;; esac done list_add_not_empty ARGS "${LINKARGS}" build () { local SRCFILE SRCFILE="$1" TMPFILE=$(mymktemp "${SRCFILE}" ".f") CFILE="${TMPFILE%.f}.c" eval $(list_get ARGS) cp "${SRCFILE}" "${TMPFILE}" \ && "$smpif2c" "${TMPFILE}" \ && "$smpicc" "$@" "${CFILE}" \ && rm -f "${CFILE}" \ && rm -f "${TMPFILE}" \ || exit $? # When the file is compiled with "-c" and no output file is specified with # "-o", rename the output. FIXME: do it properly. if [ -f "${CFILE%.c}.o" ]; then mv "${CFILE%.c}.o" "${SRCFILE%.f}.o" fi } if [ -n "${SRCFILES}" ]; then eval $(list_get SRCFILES) for SRCFILE in "$@"; do build "$SRCFILE" done else eval $(list_get ARGS) "$smpicc" "$@" fi