build: Provide npth.pc, generated by configure.
[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         --version)
74             echo "@PACKAGE_VERSION@"
75             exit 0
76             ;;
77         --api-version)
78             echo "@NPTH_CONFIG_API_VERSION@"
79             exit 0
80             ;;
81         --host)
82             echo "@NPTH_CONFIG_HOST@"
83             exit 0
84             ;;
85         --cflags)
86             result=
87             for i in $cflags ; do
88               skip=no
89               case $i in
90                   -I/usr/include|-I/include)
91                       skip=yes
92                       ;;
93                   -I*)
94                       for j in $result ; do
95                           if test x"$j" = x"$i" ; then
96                               skip=yes
97                               break;
98                           fi
99                       done
100                       ;;
101               esac
102               if test $skip = no ; then
103                   result="$result $i"
104               fi
105             done
106             output="$output $result"
107             ;;
108         --libs)
109             result=
110             for i in $libs ; do
111               skip=no
112               case $i in
113                   -L/usr/lib|-L/lib)
114                       skip=yes
115                       ;;
116                   -L*|-l*)
117                       for j in $result ; do
118                           if test x"$j" = x"$i" ; then
119                               skip=yes
120                               break;
121                           fi
122                       done
123                       ;;
124               esac
125               if test $skip = no ; then
126                   result="$result $i"
127               fi
128             done
129             output="$output $result"
130             ;;
131         *)
132             usage 1 1>&2
133             ;;
134     esac
135     shift
136 done
137
138 echo $output