1#!/bin/sh
2
3prefix=@prefix@
4
5major_version=@MOD_MAJOR_VERSION@
6minor_version=@MOD_MINOR_VERSION@
7patch_version=@MOD_PATCH_VERSION@
8
9usage()
10{
11	cat <<EOF
12Usage: nss-config [OPTIONS] [LIBRARIES]
13Options:
14	[--prefix[=DIR]]
15	[--exec-prefix[=DIR]]
16	[--includedir[=DIR]]
17	[--libdir[=DIR]]
18	[--version]
19	[--libs]
20	[--cflags]
21Dynamic Libraries:
22	nss
23	nssutil
24	ssl
25	smime
26EOF
27	exit $1
28}
29
30if test $# -eq 0; then
31	usage 1 1>&2
32fi
33
34lib_ssl=yes
35lib_smime=yes
36lib_nss=yes
37lib_nssutil=yes
38
39while test $# -gt 0; do
40  case "$1" in
41  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
42  *) optarg= ;;
43  esac
44
45  case $1 in
46    --prefix=*)
47      prefix=$optarg
48      ;;
49    --prefix)
50      echo_prefix=yes
51      ;;
52    --exec-prefix=*)
53      exec_prefix=$optarg
54      ;;
55    --exec-prefix)
56      echo_exec_prefix=yes
57      ;;
58    --includedir=*)
59      includedir=$optarg
60      ;;
61    --includedir)
62      echo_includedir=yes
63      ;;
64    --libdir=*)
65      libdir=$optarg
66      ;;
67    --libdir)
68      echo_libdir=yes
69      ;;
70    --version)
71      echo ${major_version}.${minor_version}.${patch_version}
72      ;;
73    --cflags)
74      echo_cflags=yes
75      ;;
76    --libs)
77      echo_libs=yes
78      ;;
79    ssl)
80      lib_ssl=yes
81      ;;
82    smime)
83      lib_smime=yes
84      ;;
85    nss)
86      lib_nss=yes
87      ;;
88    nssutil)
89      lib_nssutil=yes
90      ;;
91    *)
92      usage 1 1>&2
93      ;;
94  esac
95  shift
96done
97
98# Set variables that may be dependent upon other variables
99if test -z "$exec_prefix"; then
100    exec_prefix=`pkg-config --variable=exec_prefix nss`
101fi
102if test -z "$includedir"; then
103    includedir=`pkg-config --variable=includedir nss`
104fi
105if test -z "$libdir"; then
106    libdir=`pkg-config --variable=libdir nss`
107fi
108
109if test "$echo_prefix" = "yes"; then
110    echo $prefix
111fi
112
113if test "$echo_exec_prefix" = "yes"; then
114    echo $exec_prefix
115fi
116
117if test "$echo_includedir" = "yes"; then
118    echo $includedir
119fi
120
121if test "$echo_libdir" = "yes"; then
122    echo $libdir
123fi
124
125if test "$echo_cflags" = "yes"; then
126    echo -I$includedir
127fi
128
129if test "$echo_libs" = "yes"; then
130      libdirs="-Wl,-rpath-link,$libdir -L$libdir"
131      if test -n "$lib_ssl"; then
132	libdirs="$libdirs -lssl${major_version}"
133      fi
134      if test -n "$lib_smime"; then
135	libdirs="$libdirs -lsmime${major_version}"
136      fi
137      if test -n "$lib_nss"; then
138	libdirs="$libdirs -lnss${major_version}"
139      fi
140      if test -n "$lib_nssutil"; then
141	libdirs="$libdirs -lnssutil${major_version}"
142      fi
143      echo $libdirs
144fi
145
146