1#!/bin/sh
2
3search=$1
4shift
5pkg=$1
6shift
7op=$1
8shift
9
10in=`cat`
11
12if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
13    echo $in | grep $search >/dev/null 2>&1; then
14# Nasty, nasty, in --copy, arg 2 is another config to search for, use with NO_GMP
15    if [ $op = "--copy" ]; then
16	if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
17            echo $in | grep $pkg >/dev/null 2>&1; then
18	    pkg=""
19	else 
20	    pkg="$*"
21	fi
22    elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
23	      echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
24	pkg=`$pkg  --static $op $*`
25    else
26	pkg=`$pkg $op $*`
27    fi
28
29    if grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
30	echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
31	if [ $op = "--libs" ] || [ $op = "--copy" ]; then
32	    echo "-Wl,-Bstatic $pkg -Wl,-Bdynamic"
33	else
34	    echo "$pkg" 
35	fi
36    else
37	echo "$pkg"
38    fi
39fi
40
41