#!/bin/sh
#
# This file is meant to check if any fortran subroutines are defined
# in more than one .a file. It looks for routines that end in _ so
# if your machine does not append _, you probably need to modify things.
# You are also supposed to change the link line
# of your makefile so that it invokes 'check_multdefs' instead.
# That is, replace stuff like
#    $(LINKER) *.o -lm
# with
#    ../etc/check_multdefs *.o -lm
#
\rm -f libdefs
for i in $*
do
  ttt=`echo ${i} | grep "\.a"`
  tt2=`echo ${ttt}xxx`
  if test `expr ${tt2}` = 'xxx'
  then
     touch /dev/null
  else
     nm $ttt | grep " T " | grep _\$ | sed "s/^.* T //" | sed "s/\(.*\)/echo -n \1; grep xxx\1/" | sed "s/$/xxx libdefs | wc /" >> libdefs
  fi
done
chmod +x libdefs
libdefs | grep -v "    1    "