build: Compatibility to pkg-config.
[npth.git] / npth-config.in
1 #!/bin/sh
2 # Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
3 #
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
7 #
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12 prefix=@prefix@
13 exec_prefix=@exec_prefix@
14
15 # Make sure that no weird locale setting messes up our sed regexps etc.
16 LC_COLLATE=C
17 LC_ALL=C
18 LANG=C
19
20 # NPTH's own cflags and libs
21 cflags="-I@includedir@ @NPTH_CONFIG_CFLAGS@"
22 libs="-L@libdir@ @NPTH_CONFIG_LIBS@"
23
24 output=""
25
26 usage()
27 {
28     cat <<EOF
29 Usage: npth-config [OPTIONS]
30 Options:
31         [--thread={${thread_modules}}]
32         [--prefix]
33         [--exec-prefix]
34         [--version]
35         [--api-version]
36         [--host]
37         [--libs]
38         [--cflags]
39 EOF
40     exit $1
41 }
42
43 if test $# -eq 0; then
44     usage 1 1>&2
45 fi
46
47 while test $# -gt 0; do
48     case "$1" in
49         -*=*)
50             optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
51             ;;
52         *)
53             optarg=
54             ;;
55     esac
56
57     case $1 in
58         --prefix=*)
59             # For compatibility reasons with old M4 macros, we ignore
60             # setting of prefix.
61             ;;
62         --prefix)
63             output="$output $prefix"
64             ;;
65         --exec-prefix=*)
66             ;;
67         --exec-prefix)
68             output="$output $exec_prefix"
69             ;;
70         --glib)
71             with_glib=yes
72             ;;
73         --variable=*)
74             case "${1#*=}" in
75                 prefix) echo "$prefix" ;;
76                 exec_prefix) echo "$exec_prefix" ;;
77                 host) echo "@NPTH_CONFIG_HOST@" ;;
78                 api_version) echo "@NPTH_CONFIG_API_VERSION@" ;;
79             esac
80             exit 0
81             ;;
82         --modversion|--version)
83             echo "@PACKAGE_VERSION@"
84             exit 0
85             ;;
86         --api-version)
87             echo "@NPTH_CONFIG_API_VERSION@"
88             exit 0
89             ;;
90         --host)
91             echo "@NPTH_CONFIG_HOST@"
92             exit 0
93             ;;
94         --cflags)
95             result=
96             for i in $cflags ; do
97               skip=no
98               case $i in
99                   -I/usr/include|-I/include)
100                       skip=yes
101                       ;;
102                   -I*)
103                       for j in $result ; do
104                           if test x"$j" = x"$i" ; then
105                               skip=yes
106                               break;
107                           fi
108                       done
109                       ;;
110               esac
111               if test $skip = no ; then
112                   result="$result $i"
113               fi
114             done
115             output="$output $result"
116             ;;
117         --libs)
118             result=
119             for i in $libs ; do
120               skip=no
121               case $i in
122                   -L/usr/lib|-L/lib)
123                       skip=yes
124                       ;;
125                   -L*|-l*)
126                       for j in $result ; do
127                           if test x"$j" = x"$i" ; then
128                               skip=yes
129                               break;
130                           fi
131                       done
132                       ;;
133               esac
134               if test $skip = no ; then
135                   result="$result $i"
136               fi
137             done
138             output="$output $result"
139             ;;
140         *)
141             usage 1 1>&2
142             ;;
143     esac
144     shift
145 done
146
147 echo $output