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

DIMENSION=$1  # gerris2D or gerris3D
WDIR=$2       # simulation directory

CC=/usr/bin/clang
LD=/usr/bin/clang
CFLAGS="-O -fpic -Wall -Wno-unused -Werror"
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

if $CC `pkg-config $DIMENSION --cflags` $CFLAGS -I"$WDIR" \
    -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
