Git init
[external/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 gnutls nss) 
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.14
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_098=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_098=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="  -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 nss)
171     if test "0" = "0"; then
172         the_crypto_flags="-I/usr/include/nspr -I/usr/include/nss   -DXMLSEC_CRYPTO_NSS=1 -DXMLSEC_CRYPTO=\\\"nss\\\""
173         the_crypto_libs="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl  "
174         the_xmlsec_crypto_lib="-lxmlsec1-nss"
175     else
176         echo "Error: the \"$crypto\" cryptographic library is not supported"
177         usage 1
178     fi
179     ;;
180     
181 *)
182     echo "Error: the \"$crypto\" cryptographic library is not supported"
183     usage 1
184     ;;
185     
186 esac
187
188 #
189 # Assemble all the settings together
190 #
191 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"
192 the_libs="$the_libs -L${package_libdir} -lxmlsec1 -lltdl  $the_xmlsec_crypto_lib -lxmlsec1 $the_xml_libs $the_xslt_libs $the_crypto_libs"
193
194 if $cflags; then
195     all_flags="$the_flags"
196 fi
197
198 if $libs; then
199     all_flags="$all_flags $services $the_libs"
200 fi
201
202 if test -z "$all_flags" || test "x$all_flags" = "x "; then
203     exit 1
204 fi
205
206 # Straight out any possible duplicates, but be careful to
207 # get `-lfoo -lbar -lbaz' for `-lfoo -lbaz -lbar -lbaz'
208 other_flags=
209 rev_libs=
210 for i in $all_flags; do
211     case "$i" in
212     # a library, save it for later, in reverse order
213     -l*) rev_libs="$i $rev_libs" ;;
214     *)
215         case " $other_flags " in
216         *\ $i\ *) ;;                            # already there
217         *) other_flags="$other_flags $i" ;;     # add it to output
218         esac ;;
219     esac
220 done
221
222 ord_libs=
223 for i in $rev_libs; do
224     case " $ord_libs " in
225     *\ $i\ *) ;;                        # already there
226     *) ord_libs="$i $ord_libs" ;;       # add it to output in reverse order
227     esac
228 done
229
230 echo $other_flags $ord_libs
231
232 exit 0