xref: /freebsd/crypto/krb5/src/build-tools/krb5-config.in (revision 4b15965daa99044daf184221b7c283bf7f2d7e66)
1#!/bin/sh
2
3# Copyright 2001, 2002, 2003 by the Massachusetts Institute of Technology.
4# All Rights Reserved.
5#
6# Export of this software from the United States of America may
7#   require a specific license from the United States Government.
8#   It is the responsibility of any person or organization contemplating
9#   export to obtain such a license before exporting.
10#
11# WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12# distribute this software and its documentation for any purpose and
13# without fee is hereby granted, provided that the above copyright
14# notice appear in all copies and that both that copyright notice and
15# this permission notice appear in supporting documentation, and that
16# the name of M.I.T. not be used in advertising or publicity pertaining
17# to distribution of the software without specific, written prior
18# permission.  Furthermore if you modify this software you must label
19# your software as modified software and not distribute it in such a
20# fashion that it might be confused with the original M.I.T. software.
21# M.I.T. makes no representations about the suitability of
22# this software for any purpose.  It is provided "as is" without express
23# or implied warranty.
24#
25#
26
27# Configurable parameters set by autoconf
28version_string="Kerberos 5 release @KRB5_VERSION@"
29
30prefix=@prefix@
31exec_prefix=@exec_prefix@
32includedir=@includedir@
33libdir=@libdir@
34CC_LINK='@CC_LINK@'
35KDB5_DB_LIB=@KDB5_DB_LIB@
36RPATH_FLAG='@RPATH_FLAG@'
37PROG_RPATH_FLAGS='@PROG_RPATH_FLAGS@'
38PTHREAD_CFLAGS='@PTHREAD_CFLAGS@'
39DL_LIB='@DL_LIB@'
40DEFCCNAME='@DEFCCNAME@'
41DEFKTNAME='@DEFKTNAME@'
42DEFCKTNAME='@DEFCKTNAME@'
43
44LIBS='@LIBS@'
45GEN_LIB=@GEN_LIB@
46
47# Defaults for program
48library=krb5
49
50# Some constants
51vendor_string="Massachusetts Institute of Technology"
52
53# Process arguments
54# Yes, we are sloppy, library specifications can come before options
55while test $# != 0; do
56    case $1 in
57	--all)
58	    do_all=1
59	    ;;
60	--cflags)
61	    do_cflags=1
62	    ;;
63	--defccname)
64	    do_defccname=1
65	    ;;
66	--defcktname)
67	    do_defcktname=1
68	    ;;
69	--defktname)
70	    do_defktname=1
71	    ;;
72	--deps) # historically a no-op
73	    ;;
74	--exec-prefix)
75	    do_exec_prefix=1
76	    ;;
77	--help)
78	    do_help=1
79	    ;;
80	--libs)
81	    do_libs=1
82	    ;;
83	--prefix)
84	    do_prefix=1
85	    ;;
86	--vendor)
87	    do_vendor=1
88	    ;;
89	--version)
90	    do_version=1
91	    ;;
92	krb5)
93	    library=krb5
94	    ;;
95	gssapi)
96	    library=gssapi
97	    ;;
98	gssrpc)
99	    library=gssrpc
100	    ;;
101	kadm-client)
102	    library=kadm_client
103	    ;;
104	kadm-server)
105	    library=kadm_server
106	    ;;
107	kdb)
108	    library=kdb
109	    ;;
110	*)
111	    echo "$0: Unknown option \`$1' -- use \`--help' for usage"
112	    exit 1
113    esac
114    shift
115done
116
117# If required options - provide help
118if test -z "$do_all" -a -z "$do_version" -a -z "$do_vendor" -a \
119    -z "$do_prefix" -a -z "$do_vendor" -a -z "$do_exec_prefix" -a \
120    -z "$do_defccname" -a -z "$do_defktname" -a -z "$do_defcktname" -a \
121    -z "$do_cflags" -a -z "$do_libs"; then
122    do_help=1
123fi
124
125
126if test -n "$do_help"; then
127    echo "Usage: $0 [OPTIONS] [LIBRARIES]"
128    echo "Options:"
129    echo "        [--help]          Help"
130    echo "        [--all]           Display version, vendor, and various values"
131    echo "        [--version]       Version information"
132    echo "        [--vendor]        Vendor information"
133    echo "        [--prefix]        Kerberos installed prefix"
134    echo "        [--exec-prefix]   Kerberos installed exec_prefix"
135    echo "        [--defccname]     Show built-in default ccache name"
136    echo "        [--defktname]     Show built-in default keytab name"
137    echo "        [--defcktname]    Show built-in default client keytab name"
138    echo "        [--cflags]        Compile time CFLAGS"
139    echo "        [--libs]          List libraries required to link [LIBRARIES]"
140    echo "Libraries:"
141    echo "        krb5              Kerberos 5 application"
142    echo "        gssapi            GSSAPI application with Kerberos 5 bindings"
143    echo "        gssrpc            GSSAPI RPC application"
144    echo "        kadm-client       Kadmin client"
145    echo "        kadm-server       Kadmin server"
146    echo "        kdb               Application that accesses the kerberos database"
147    exit 0
148fi
149
150if test -n "$do_all"; then
151    all_exit=
152    do_version=1
153    do_prefix=1
154    do_exec_prefix=1
155    do_vendor=1
156    title_version="Version:     "
157    title_prefix="Prefix:      "
158    title_exec_prefix="Exec_prefix: "
159    title_vendor="Vendor:      "
160else
161    all_exit="exit 0"
162fi
163
164if test -n "$do_version"; then
165    echo "$title_version$version_string"
166    $all_exit
167fi
168
169if test -n "$do_vendor"; then
170    echo "$title_vendor$vendor_string"
171    $all_exit
172fi
173
174if test -n "$do_prefix"; then
175    echo "$title_prefix$prefix"
176    $all_exit
177fi
178
179if test -n "$do_exec_prefix"; then
180    echo "$title_exec_prefix$exec_prefix"
181    $all_exit
182fi
183
184if test -n "$do_defccname"; then
185    echo "$DEFCCNAME"
186    $all_exit
187fi
188
189if test -n "$do_defktname"; then
190    echo "$DEFKTNAME"
191    $all_exit
192fi
193
194if test -n "$do_defcktname"; then
195    echo "$DEFCKTNAME"
196    $all_exit
197fi
198
199if test -n "$do_cflags"; then
200    if test x"$includedir" != x"/usr/include" ; then
201        echo "-I${includedir}"
202    else
203        echo ''
204    fi
205fi
206
207
208if test -n "$do_libs"; then
209    # Assumes /usr/lib is the standard library directory everywhere...
210    if test "$libdir" = /usr/lib; then
211	libdirarg=
212    else
213	libdirarg="-L$libdir"
214    fi
215    # Ugly gross hack for our build tree
216    lib_flags=`echo $CC_LINK | sed -e 's/\$(CC)//' \
217	    -e 's/\$(PURE)//' \
218	    -e 's#\$(PROG_RPATH_FLAGS)#'"$PROG_RPATH_FLAGS"'#' \
219	    -e 's#\$(PROG_RPATH)#'$libdir'#' \
220	    -e 's#\$(PROG_LIBPATH)#'$libdirarg'#' \
221	    -e 's#\$(RPATH_FLAG)#'"$RPATH_FLAG"'#' \
222	    -e 's#\$(LDFLAGS)##' \
223	    -e 's#\$(PTHREAD_CFLAGS)#'"$PTHREAD_CFLAGS"'#' \
224	    -e 's#\$(CFLAGS)##'`
225
226    if test $library = 'kdb'; then
227	lib_flags="$lib_flags -lkdb5 $KDB5_DB_LIB"
228	library=krb5
229    fi
230
231    if test $library = 'kadm_server'; then
232	lib_flags="$lib_flags -lkadm5srv_mit -lkdb5 $KDB5_DB_LIB"
233	library=gssrpc
234    fi
235
236    if test $library = 'kadm_client'; then
237	lib_flags="$lib_flags -lkadm5clnt_mit"
238	library=gssrpc
239    fi
240
241    if test $library = 'gssrpc'; then
242	lib_flags="$lib_flags -lgssrpc"
243	library=gssapi
244    fi
245
246    if test $library = 'gssapi'; then
247	lib_flags="$lib_flags -lgssapi_krb5"
248	library=krb5
249    fi
250
251    if test $library = 'krb5'; then
252	lib_flags="$lib_flags -lkrb5 -lk5crypto @COM_ERR_LIB@"
253    fi
254
255    # If we ever support a flag to generate output suitable for static
256    # linking, we would output "-lkrb5support $GEN_LIB $LIBS $DL_LIB"
257    # here.
258
259    echo $lib_flags
260fi
261
262exit 0
263