Imported Upstream version 1.2.19
[platform/upstream/xmlsec1.git] / xmlsec1-config
1 #! /bin/sh
2
3 prefix="/usr"
4 package="xmlsec1"
5 exec_prefix="${prefix}"
6 exec_prefix_set=no
7 package_libdir="${exec_prefix}/lib"
8
9 usage()
10 {
11     cat <<EOF
12 Usage: $package-config [OPTION]...
13
14 Known values for OPTION are:
15
16   --prefix=DIR          change XMLSEC prefix
17   --exec-prefix=DIR     change XMLSEC executable prefix
18   --libs                print library linking information
19   --cflags              print pre-processor and compiler flags
20   --crypto              print the default crypto library name
21   --help                display this help and exit
22   --version             output version information
23   --crypto=LIB          configure with XMLSEC crypto library (one of the
24                         following: none default openssl nss gnutls gcrypt)
25 EOF
26
27     exit $1
28 }
29
30
31 #
32 # first parse command line aruments
33 #
34 if [ $# -eq 0 ]
35 then
36     usage 1 1>&2
37 fi
38
39 cflags=false
40 libs=false
41 if [ "z0" = "z1" ] ;
42 then
43     crypto="default"
44 else
45     crypto="none"
46 fi
47
48 while [ $# -gt 0 ]
49 do
50     case "$1" in
51     -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
52     *) optarg= ;;
53     esac
54
55     case "$1" in
56     --crypto=*)
57         crypto=$optarg
58         ;;
59         
60     --prefix=*)
61         prefix=$optarg
62         if [ $exec_prefix_set = no ]
63         then
64             exec_prefix=$optarg
65         fi
66         ;;
67
68     --prefix)
69         echo $prefix
70         ;;
71
72     --exec-prefix=*)
73         exec_prefix=$optarg
74         exec_prefix_set=yes
75         ;;
76
77     --exec-prefix)
78         echo $exec_prefix
79         ;;
80
81     --version)
82         echo 1.2.19
83         exit 0
84         ;;
85     
86     --crypto)
87         echo openssl
88         exit 0
89         ;;
90         
91     --help)
92         usage 0
93         ;;
94
95     --cflags)
96         cflags=true
97         ;;
98
99     --libs)
100         libs=true
101         ;;
102     
103     *)
104         usage 1
105         ;;
106     esac
107     shift
108 done
109
110 #
111 # Get LibXML2 settings
112 #
113 the_xml_flags="`xml2-config --cflags`"
114 the_xml_libs="`xml2-config --libs`"
115
116 #
117 # Get LibXSLT settings
118 #
119 the_xslt_flags=""
120 the_xslt_libs=""
121 if test "0" = "0"; then 
122     the_xslt_flags="`xslt-config --cflags`"
123     the_xslt_libs="`xslt-config --libs`"
124 fi    
125
126 #
127 # Get crypto library settings
128 #
129 the_crypto_flags=""
130 the_crypto_libs=""
131 the_xmlsec_crypto_lib=""
132 case "$crypto" in
133 none)
134     # no crypto, just the core xmlsec engine (useful when more
135     # than one crypto engine i sused by application)
136     if [ "z0" != "z1" ] ;
137     then
138         the_crypto_flags="-DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO=\\\"openssl\\\""
139     fi
140     ;;
141
142 default) 
143     the_crypto_flags="  -DXMLSEC_OPENSSL_100=1 -DXMLSEC_CRYPTO_OPENSSL=1 -DXMLSEC_CRYPTO=\\\"openssl\\\""
144     the_crypto_libs="-lssl -lcrypto  "
145     the_xmlsec_crypto_lib="-lxmlsec1-openssl"
146     ;;
147     
148 openssl)
149     if test "0" = "0"; then
150         the_crypto_flags="  -DXMLSEC_OPENSSL_100=1 -DXMLSEC_CRYPTO_OPENSSL=1 -DXMLSEC_CRYPTO=\\\"openssl\\\""
151         the_crypto_libs="-lssl -lcrypto  "
152         the_xmlsec_crypto_lib="-lxmlsec1-openssl"
153     else
154         echo "Error: the \"$crypto\" cryptographic library is not supported"
155         usage 1
156     fi
157     ;;
158
159 gnutls)
160     if test "0" = "0"; then
161         the_crypto_flags="-I/usr/include/p11-kit-1   -DXMLSEC_CRYPTO_GNUTLS=1 -DXMLSEC_CRYPTO=\\\"gnutls\\\""
162         the_crypto_libs="-lgnutls  "
163         the_xmlsec_crypto_lib="-lxmlsec1-gnutls"
164     else
165         echo "Error: the \"$crypto\" cryptographic library is not supported"
166         usage 1
167     fi
168     ;;
169
170 gcrypt)
171     if test "0" = "0"; then
172         the_crypto_flags="  -DXMLSEC_CRYPTO_GCRYPT=1 -DXMLSEC_CRYPTO=\\\"gcrypt\\\""
173         the_crypto_libs=" -L/lib/i386-linux-gnu -lgcrypt"
174         the_xmlsec_crypto_lib="-lxmlsec1-gcrypt"
175     else
176         echo "Error: the \"$crypto\" cryptographic library is not supported"
177         usage 1
178     fi
179     ;;
180
181 nss)
182     if test "0" = "0"; then
183         the_crypto_flags="-I/usr/include/nspr -I/usr/include/nss   -DXMLSEC_CRYPTO_NSS=1 -DXMLSEC_CRYPTO=\\\"nss\\\""
184         the_crypto_libs="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4  "
185         the_xmlsec_crypto_lib="-lxmlsec1-nss"
186     else
187         echo "Error: the \"$crypto\" cryptographic library is not supported"
188         usage 1
189     fi
190     ;;
191     
192 *)
193     echo "Error: the \"$crypto\" cryptographic library is not supported"
194     usage 1
195     ;;
196     
197 esac
198
199 #
200 # Assemble all the settings together
201 #
202 the_flags="$the_flags  -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_XKMS=1 -DXMLSEC_DL_LIBLTDL=1 -I${prefix}/include/xmlsec1   $the_xml_flags $the_xslt_flags $the_crypto_flags"
203 the_libs="$the_libs -L${package_libdir} -lxmlsec1 -lltdl  $the_xmlsec_crypto_lib -lxmlsec1 $the_xml_libs $the_xslt_libs $the_crypto_libs"
204
205 if $cflags; then
206     all_flags="$the_flags"
207 fi
208
209 if $libs; then
210     all_flags="$all_flags $services $the_libs"
211 fi
212
213 if test -z "$all_flags" || test "x$all_flags" = "x "; then
214     exit 1
215 fi
216
217 # Straight out any possible duplicates, but be careful to
218 # get `-lfoo -lbar -lbaz' for `-lfoo -lbaz -lbar -lbaz'
219 other_flags=
220 rev_libs=
221 for i in $all_flags; do
222     case "$i" in
223     # a library, save it for later, in reverse order
224     -l*) rev_libs="$i $rev_libs" ;;
225     *)
226         case " $other_flags " in
227         *\ $i\ *) ;;                            # already there
228         *) other_flags="$other_flags $i" ;;     # add it to output
229         esac ;;
230     esac
231 done
232
233 ord_libs=
234 for i in $rev_libs; do
235     case " $ord_libs " in
236     *\ $i\ *) ;;                        # already there
237     *) ord_libs="$i $ord_libs" ;;       # add it to output in reverse order
238     esac
239 done
240
241 echo $other_flags $ord_libs
242
243 exit 0