xref: /freebsd/krb5/util/build-tools/krb5-config.sh (revision 621e0e7f27303452c2f5b5fcf93aaf72e2b036a6)
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
28# Disreagard the above. Edit this by hand in the bespoke FreeBSD build.
29version_string="Kerberos 5 release 1.22.1"
30
31prefix=/usr
32exec_prefix=${prefix}
33includedir=${prefix}/include
34libdir=${exec_prefix}/lib
35CC_LINK='$(CC) $(PROG_LIBPATH) $(PROG_RPATH_FLAGS) $(CFLAGS) $(LDFLAGS)'
36KDB5_DB_LIB=
37RPATH_FLAG=''
38PROG_RPATH_FLAGS=''
39PTHREAD_CFLAGS='-pthread'
40DL_LIB=''
41DEFCCNAME='FILE:/tmp/krb5cc_%{uid}'
42DEFKTNAME='FILE:/etc/krb5.keytab'
43DEFCKTNAME='FILE:/var/krb5/user/%{euid}/client.keytab'
44
45LIBS='-lintl -L/usr/local/lib'
46GEN_LIB=
47
48# Defaults for program
49library=krb5
50
51# Some constants
52vendor_string="Massachusetts Institute of Technology"
53
54# Process arguments
55# Yes, we are sloppy, library specifications can come before options
56while test $# != 0; do
57    case $1 in
58	--all)
59	    do_all=1
60	    ;;
61	--cflags)
62	    do_cflags=1
63	    ;;
64	--defccname)
65	    do_defccname=1
66	    ;;
67	--defcktname)
68	    do_defcktname=1
69	    ;;
70	--defktname)
71	    do_defktname=1
72	    ;;
73	--deps) # historically a no-op
74	    ;;
75	--exec-prefix)
76	    do_exec_prefix=1
77	    ;;
78	--help)
79	    do_help=1
80	    ;;
81	--libs)
82	    do_libs=1
83	    ;;
84	--prefix)
85	    do_prefix=1
86	    ;;
87	--vendor)
88	    do_vendor=1
89	    ;;
90	--version)
91	    do_version=1
92	    ;;
93	krb5)
94	    library=krb5
95	    ;;
96	gssapi)
97	    library=gssapi
98	    ;;
99	gssrpc)
100	    library=gssrpc
101	    ;;
102	kadm-client)
103	    library=kadm_client
104	    ;;
105	kadm-server)
106	    library=kadm_server
107	    ;;
108	kdb)
109	    library=kdb
110	    ;;
111	*)
112	    echo "$0: Unknown option \`$1' -- use \`--help' for usage"
113	    exit 1
114    esac
115    shift
116done
117
118# If required options - provide help
119if test -z "$do_all" -a -z "$do_version" -a -z "$do_vendor" -a \
120    -z "$do_prefix" -a -z "$do_vendor" -a -z "$do_exec_prefix" -a \
121    -z "$do_defccname" -a -z "$do_defktname" -a -z "$do_defcktname" -a \
122    -z "$do_cflags" -a -z "$do_libs"; then
123    do_help=1
124fi
125
126
127if test -n "$do_help"; then
128    echo "Usage: $0 [OPTIONS] [LIBRARIES]"
129    echo "Options:"
130    echo "        [--help]          Help"
131    echo "        [--all]           Display version, vendor, and various values"
132    echo "        [--version]       Version information"
133    echo "        [--vendor]        Vendor information"
134    echo "        [--prefix]        Kerberos installed prefix"
135    echo "        [--exec-prefix]   Kerberos installed exec_prefix"
136    echo "        [--defccname]     Show built-in default ccache name"
137    echo "        [--defktname]     Show built-in default keytab name"
138    echo "        [--defcktname]    Show built-in default client keytab name"
139    echo "        [--cflags]        Compile time CFLAGS"
140    echo "        [--libs]          List libraries required to link [LIBRARIES]"
141    echo "Libraries:"
142    echo "        krb5              Kerberos 5 application"
143    echo "        gssapi            GSSAPI application with Kerberos 5 bindings"
144    echo "        gssrpc            GSSAPI RPC application"
145    echo "        kadm-client       Kadmin client"
146    echo "        kadm-server       Kadmin server"
147    echo "        kdb               Application that accesses the kerberos database"
148    exit 0
149fi
150
151if test -n "$do_all"; then
152    all_exit=
153    do_version=1
154    do_prefix=1
155    do_exec_prefix=1
156    do_vendor=1
157    title_version="Version:     "
158    title_prefix="Prefix:      "
159    title_exec_prefix="Exec_prefix: "
160    title_vendor="Vendor:      "
161else
162    all_exit="exit 0"
163fi
164
165if test -n "$do_version"; then
166    echo "$title_version$version_string"
167    $all_exit
168fi
169
170if test -n "$do_vendor"; then
171    echo "$title_vendor$vendor_string"
172    $all_exit
173fi
174
175if test -n "$do_prefix"; then
176    echo "$title_prefix$prefix"
177    $all_exit
178fi
179
180if test -n "$do_exec_prefix"; then
181    echo "$title_exec_prefix$exec_prefix"
182    $all_exit
183fi
184
185if test -n "$do_defccname"; then
186    echo "$DEFCCNAME"
187    $all_exit
188fi
189
190if test -n "$do_defktname"; then
191    echo "$DEFKTNAME"
192    $all_exit
193fi
194
195if test -n "$do_defcktname"; then
196    echo "$DEFCKTNAME"
197    $all_exit
198fi
199
200if test -n "$do_cflags"; then
201    if test x"$includedir" != x"/usr/include" ; then
202        echo "-I${includedir}"
203    else
204        echo ''
205    fi
206fi
207
208
209if test -n "$do_libs"; then
210    # Assumes /usr/lib is the standard library directory everywhere...
211    if test "$libdir" = /usr/lib; then
212	libdirarg=
213    else
214	libdirarg="-L$libdir"
215    fi
216    # Ugly gross hack for our build tree
217    lib_flags=`echo $CC_LINK | sed -e 's/\$(CC)//' \
218	    -e 's/\$(PURE)//' \
219	    -e 's#\$(PROG_RPATH_FLAGS)#'"$PROG_RPATH_FLAGS"'#' \
220	    -e 's#\$(PROG_RPATH)#'$libdir'#' \
221	    -e 's#\$(PROG_LIBPATH)#'$libdirarg'#' \
222	    -e 's#\$(RPATH_FLAG)#'"$RPATH_FLAG"'#' \
223	    -e 's#\$(LDFLAGS)##' \
224	    -e 's#\$(PTHREAD_CFLAGS)#'"$PTHREAD_CFLAGS"'#' \
225	    -e 's#\$(CFLAGS)##'`
226
227    if test $library = 'kdb'; then
228	lib_flags="$lib_flags -lkdb5 $KDB5_DB_LIB"
229	library=krb5
230    fi
231
232    if test $library = 'kadm_server'; then
233	lib_flags="$lib_flags -lkadm5srv_mit -lkdb5 $KDB5_DB_LIB"
234	library=gssrpc
235    fi
236
237    if test $library = 'kadm_client'; then
238	lib_flags="$lib_flags -lkadm5clnt_mit"
239	library=gssrpc
240    fi
241
242    if test $library = 'gssrpc'; then
243	lib_flags="$lib_flags -lgssrpc"
244	library=gssapi
245    fi
246
247    if test $library = 'gssapi'; then
248	lib_flags="$lib_flags -lgssapi_krb5"
249	library=krb5
250    fi
251
252    if test $library = 'krb5'; then
253	lib_flags="$lib_flags -lkrb5 -lk5crypto -lcom_err"
254    fi
255
256    # If we ever support a flag to generate output suitable for static
257    # linking, we would output "-lkrb5support $GEN_LIB $LIBS $DL_LIB"
258    # here.
259
260    echo $lib_flags
261fi
262
263exit 0
264