#!/bin/sh

############################################################
# Copyright (c) 2009-2010 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################

set -e
test $# -eq 2

prefix="$1"
objdir="$2"

LC_ALL=C
export LC_ALL

if test -z "$NOSORT"; then
	SORT_CMD=sort
else
	SORT_CMD=cat
fi

grep -v CVS |
grep -v '~$' |
sed -e "s,$objdir,/objdir,g" \
    -e "s,$prefix,/prefix,g" \
    -e "s,/usr/pkg,/prefix," \
    -e "s,/usr,/prefix," \
    -e "s,/opt/local,/prefix," \
    -e "s,/opt,/prefix," \
    -e 's/\([.][^ ]*\)[.]dylib/.so\1/' \
    -e 's/[.]dylib/.so/' \
    -e 's/[.]bundle/.so/' \
    -e 's/[.]exe//' \
    -e '/export[.]sym[.]tmp/ d' \
    -e '/pod2htmd.tmp/ d' \
    -e '/pod2htmi.tmp/ d' \
    -e 's,lib64,lib,' \
    -e 's,lib/[^/]*/lua,lib/lua,' \
    -e 's,lua/[0-9]*[.][0-9]*,lua/X.Y,' \
    -e 's,//,/,g' \
    -e 's,^bmake:.*line [0-9][0-9]*: "\(.*\)".*$,\1,g' \
    -e 's/[.]sl/.so/' -e /so_locations/d |
$SORT_CMD
