summaryrefslogtreecommitdiff
path: root/bld/pkg-wrapper
blob: 0ddb678c6a2c48be7be0b42f55a4dd4fb493f834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh

search=$1
shift
pkg=$1
shift
op=$1
shift

in=`cat`

if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
    echo $in | grep $search >/dev/null 2>&1; then
# Nasty, nasty, in --copy, arg 2 is another config to search for, use with NO_GMP
    if [ $op = "--copy" ]; then
	if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
            echo $in | grep $pkg >/dev/null 2>&1; then
	    pkg=""
	else 
	    pkg="$*"
	fi
    elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
	      echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
	pkg=`$pkg  --static $op $*`
    else
	pkg=`$pkg $op $*`
    fi

    if grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
	echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
	if [ $op = "--libs" ] || [ $op = "--copy" ]; then
	    echo "-Wl,-Bstatic $pkg -Wl,-Bdynamic"
	else
	    echo "$pkg" 
	fi
    else
	echo "$pkg"
    fi
fi