blob: 704bdd30771d4e5c439c773edd70e70a6e116db7 [file] [log] [blame]
Simon Kelley3d8df262005-08-29 12:19:27 +01001#!/bin/sh
2
Simon Kelley1f15b812009-10-13 17:49:32 +01003search=$1
4shift
Simon Kelleyc979fa02014-01-21 13:45:17 +00005pkg=$1
6shift
7op=$1
8shift
Simon Kelley1f15b812009-10-13 17:49:32 +01009
Simon Kelleyc979fa02014-01-21 13:45:17 +000010in=`cat`
11
Simon Kelleyc979fa02014-01-21 13:45:17 +000012if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
13 echo $in | grep $search >/dev/null 2>&1; then
Simon Kelley3a5a84c2018-10-31 21:30:13 +000014# Nasty, nasty, in --copy, arg 2 (if non-empty) is another config to search for, used with NO_GMP
Simon Kelleyb98d22c2014-02-04 16:57:25 +000015 if [ $op = "--copy" ]; then
Simon Kelley3a5a84c2018-10-31 21:30:13 +000016 if [ -z "$pkg" ]; then
17 pkg="$*"
18 elif grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
19 echo $in | grep $pkg >/dev/null 2>&1; then
Simon Kelley063efb32014-06-17 19:49:31 +010020 pkg=""
21 else
22 pkg="$*"
23 fi
Simon Kelley4ea8e802014-03-05 11:01:23 +000024 elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
Simon Kelley3a5a84c2018-10-31 21:30:13 +000025 echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
Simon Kelley4ea8e802014-03-05 11:01:23 +000026 pkg=`$pkg --static $op $*`
Simon Kelleyb98d22c2014-02-04 16:57:25 +000027 else
Simon Kelley4ea8e802014-03-05 11:01:23 +000028 pkg=`$pkg $op $*`
Simon Kelleyb98d22c2014-02-04 16:57:25 +000029 fi
Simon Kelley3a5a84c2018-10-31 21:30:13 +000030
Simon Kelleyb98d22c2014-02-04 16:57:25 +000031 if grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
Simon Kelley3a5a84c2018-10-31 21:30:13 +000032 echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
Simon Kelleyb98d22c2014-02-04 16:57:25 +000033 if [ $op = "--libs" ] || [ $op = "--copy" ]; then
34 echo "-Wl,-Bstatic $pkg -Wl,-Bdynamic"
35 else
36 echo "$pkg"
37 fi
38 else
39 echo "$pkg"
40 fi
Simon Kelleyc979fa02014-01-21 13:45:17 +000041fi
Simon Kelley3d8df262005-08-29 12:19:27 +010042