#!/bin/sh
# file generated automatically by configure from 'build_function_gcc'

LINENO=$1     # line number
DIMENSION=$2  # gerris2D or gerris3D
WDIR=$3       # simulation directory
              # remaining arguments are line numbers for GfsGlobal

CC=gcc
LD=gcc
CFLAGS="-O -fpic -Wall -Wno-unused -Werror -I$WDIR"
LDFLAGS="-O -fpic -shared"

touch links
if sed 's/@/#/g' < function.c | awk '{
      if ($1 == "#" && $2 == "link") {
        for (i = 3; i <= NF; i++)
          printf ("%s ", $i) >> "links";
        print "";
      } else if ($1 == "#link") {
        for (i = 2; i <= NF; i++)
          printf ("%s ", $i) >> "links";
        print "";
      } else print $0;
    }' > module.c; then :
else
    exit 1
fi

shift
shift
shift
i=0
globals=""
while test $# -gt 0; do
    globals="$globals -D_GFSLINE"$i"_="$1
    i=`expr $i + 1`
    shift
done

if $CC `pkg-config $DIMENSION --cflags` -D_GFSLINE_=$LINENO $globals $CFLAGS \
    -c -o module.o module.c; then
    if $LD `pkg-config $DIMENSION --libs` $LDFLAGS -o module.so `cat links` module.o; then :
    else
	exit 1
    fi
else
    exit 1
fi
