xref: /freebsd/contrib/dialog/dialog-config.in (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#!@SHELL@
2*a96ef450SBaptiste Daroussin# $Id: dialog-config.in,v 1.13 2019/09/26 00:50:46 tom Exp $
34c8945a0SNathan Whitehorn##############################################################################
4*a96ef450SBaptiste Daroussin# Copyright (c) 2007-2012,2019 Thomas E. Dickey                              #
54c8945a0SNathan Whitehorn#                                                                            #
64c8945a0SNathan Whitehorn# Permission is hereby granted, free of charge, to any person obtaining a    #
74c8945a0SNathan Whitehorn# copy of this software and associated documentation files (the "Software"), #
84c8945a0SNathan Whitehorn# to deal in the Software without restriction, including without limitation  #
94c8945a0SNathan Whitehorn# the rights to use, copy, modify, merge, publish, distribute, distribute    #
104c8945a0SNathan Whitehorn# with modifications, sublicense, and/or sell copies of the Software, and to #
114c8945a0SNathan Whitehorn# permit persons to whom the Software is furnished to do so, subject to the  #
124c8945a0SNathan Whitehorn# following conditions:                                                      #
134c8945a0SNathan Whitehorn#                                                                            #
144c8945a0SNathan Whitehorn# The above copyright notice and this permission notice shall be included in #
154c8945a0SNathan Whitehorn# all copies or substantial portions of the Software.                        #
164c8945a0SNathan Whitehorn#                                                                            #
174c8945a0SNathan Whitehorn# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
184c8945a0SNathan Whitehorn# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
194c8945a0SNathan Whitehorn# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
204c8945a0SNathan Whitehorn# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
214c8945a0SNathan Whitehorn# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
224c8945a0SNathan Whitehorn# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
234c8945a0SNathan Whitehorn# DEALINGS IN THE SOFTWARE.                                                  #
244c8945a0SNathan Whitehorn#                                                                            #
254c8945a0SNathan Whitehorn# Except as contained in this notice, the name(s) of the above copyright     #
264c8945a0SNathan Whitehorn# holders shall not be used in advertising or otherwise to promote the sale, #
274c8945a0SNathan Whitehorn# use or other dealings in this Software without prior written               #
284c8945a0SNathan Whitehorn# authorization.                                                             #
294c8945a0SNathan Whitehorn##############################################################################
304c8945a0SNathan Whitehorn
314c8945a0SNathan Whitehornprefix="@prefix@"
324c8945a0SNathan Whitehornexec_prefix="@exec_prefix@"
332a3e3873SBaptiste Daroussindatarootdir="@datarootdir@"
344c8945a0SNathan Whitehorn
35*a96ef450SBaptiste Daroussinsame_prefix=yes
36*a96ef450SBaptiste Daroussinsame_exec_prefix=yes
374c8945a0SNathan Whitehorn
387a1c0d96SNathan WhitehornTHIS="@PACKAGE@"
394c8945a0SNathan Whitehorn
40*a96ef450SBaptiste Daroussintest $# = 0 && exec @SHELL@ "$0" --error
414c8945a0SNathan Whitehorn
424c8945a0SNathan Whitehornwhile test $# -gt 0; do
43*a96ef450SBaptiste Daroussin
44*a96ef450SBaptiste Daroussin	# (re)evaluate symbols that may depend upon $prefix
45*a96ef450SBaptiste Daroussin	if [ "x$same_prefix" != "xyes" ]
46*a96ef450SBaptiste Daroussin	then
47*a96ef450SBaptiste Daroussin		eval exec_prefix='@exec_prefix@'
48*a96ef450SBaptiste Daroussin		eval datarootdir='@datarootdir@'
49*a96ef450SBaptiste Daroussin	elif [ "x$same_exec_prefix" != "xyes" ]
50*a96ef450SBaptiste Daroussin	then
51*a96ef450SBaptiste Daroussin		eval datarootdir='@datarootdir@'
52*a96ef450SBaptiste Daroussin	fi
53*a96ef450SBaptiste Daroussin
54*a96ef450SBaptiste Daroussin	eval bindir='"@bindir@"'
55*a96ef450SBaptiste Daroussin	eval includedir='"@includedir@"'
56*a96ef450SBaptiste Daroussin	eval libdir='"@libdir@"'
57*a96ef450SBaptiste Daroussin	eval datadir='"@datadir@"'
58*a96ef450SBaptiste Daroussin	eval mandir='"@mandir@"'
59*a96ef450SBaptiste Daroussin
60*a96ef450SBaptiste Daroussin	[ -z "$includedir" ] && includedir="${prefix}/include"
61*a96ef450SBaptiste Daroussin
62*a96ef450SBaptiste Daroussin	eval LDFLAGS='"@LDFLAGS@"'
63*a96ef450SBaptiste Daroussin	eval LIBS='"@LIBS@"'
64*a96ef450SBaptiste Daroussin	LIBS="-l${THIS} $LIBS"
65*a96ef450SBaptiste Daroussin
66*a96ef450SBaptiste Daroussin	# If the directory given by --libdir is not in the LDFLAGS+LIBS set,
67*a96ef450SBaptiste Daroussin	# prepend it to LDFLAGS to help link this application's library.
68*a96ef450SBaptiste Daroussin	found=no
69*a96ef450SBaptiste Daroussin	for opt in $LDFLAGS $LIBS
70*a96ef450SBaptiste Daroussin	do
71*a96ef450SBaptiste Daroussin		if [ "x$-L${libdir}" = "x$opt" ]
72*a96ef450SBaptiste Daroussin		then
73*a96ef450SBaptiste Daroussin			found=yes
74*a96ef450SBaptiste Daroussin			break
75*a96ef450SBaptiste Daroussin		fi
76*a96ef450SBaptiste Daroussin	done
77*a96ef450SBaptiste Daroussin	if [ $found = no ]
78*a96ef450SBaptiste Daroussin	then
79*a96ef450SBaptiste Daroussin		[ -n "$LFLAGS" ] && LDFLAGS=" $LFDLAGS"
80*a96ef450SBaptiste Daroussin		LDFLAGS="-L${libdir}$LDFLAGS"
81*a96ef450SBaptiste Daroussin	fi
82*a96ef450SBaptiste Daroussin	[ -z "$LDFLAGS" ] && LDFLAGS="-L${exec_prefix}/lib"
83*a96ef450SBaptiste Daroussin
84*a96ef450SBaptiste Daroussin	# Ignore -L options which do not correspond to an actual directory,
85*a96ef450SBaptiste Daroussin	# or which are standard library directories (i.e., the linker is
86*a96ef450SBaptiste Daroussin	# supposed to search those directories).
87*a96ef450SBaptiste Daroussin	#
88*a96ef450SBaptiste Daroussin	# There is no portable way to find the list of standard library
89*a96ef450SBaptiste Daroussin	# directories.  Require a POSIX shell anyway, to keep this simple.
90*a96ef450SBaptiste Daroussin	lib_flags=
91*a96ef450SBaptiste Daroussin	for opt in $LDFLAGS $LIBS
92*a96ef450SBaptiste Daroussin	do
93*a96ef450SBaptiste Daroussin		case $opt in
94*a96ef450SBaptiste Daroussin		-L*)
95*a96ef450SBaptiste Daroussin			[ -d ${opt##-L} ] || continue
96*a96ef450SBaptiste Daroussin			case ${opt##-L} in
97*a96ef450SBaptiste Daroussin			@LD_SEARCHPATH@) # skip standard libdir
98*a96ef450SBaptiste Daroussin				continue
99*a96ef450SBaptiste Daroussin				;;
100*a96ef450SBaptiste Daroussin			*)
101*a96ef450SBaptiste Daroussin				;;
102*a96ef450SBaptiste Daroussin			esac
103*a96ef450SBaptiste Daroussin			;;
104*a96ef450SBaptiste Daroussin		esac
105*a96ef450SBaptiste Daroussin		lib_flags="$lib_flags $opt"
106*a96ef450SBaptiste Daroussin	done
107*a96ef450SBaptiste Daroussin
1084c8945a0SNathan Whitehorn	case "$1" in
1094c8945a0SNathan Whitehorn	-*=*)
1104c8945a0SNathan Whitehorn		ARG=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
1114c8945a0SNathan Whitehorn		;;
1124c8945a0SNathan Whitehorn	*)
1134c8945a0SNathan Whitehorn		ARG=
1144c8945a0SNathan Whitehorn		;;
1154c8945a0SNathan Whitehorn	esac
1164c8945a0SNathan Whitehorn
1174c8945a0SNathan Whitehorn	case "$1" in
1184c8945a0SNathan Whitehorn	# basic configuration
1194c8945a0SNathan Whitehorn	--prefix=*)
1204c8945a0SNathan Whitehorn		prefix="$ARG"
1214c8945a0SNathan Whitehorn		test -z "$exec_prefix" && exec_prefix="$ARG"
122*a96ef450SBaptiste Daroussin		same_prefix=no
1234c8945a0SNathan Whitehorn		;;
1244c8945a0SNathan Whitehorn	--prefix)
1254c8945a0SNathan Whitehorn		echo "$prefix"
1264c8945a0SNathan Whitehorn		;;
1274c8945a0SNathan Whitehorn	--exec-prefix=*)
1284c8945a0SNathan Whitehorn		exec_prefix="$ARG"
129*a96ef450SBaptiste Daroussin		same_exec_prefix=no
1304c8945a0SNathan Whitehorn		;;
1314c8945a0SNathan Whitehorn	--exec-prefix)
1324c8945a0SNathan Whitehorn		echo "$exec_prefix"
1334c8945a0SNathan Whitehorn		;;
1344c8945a0SNathan Whitehorn	# compile/link
135*a96ef450SBaptiste Daroussin	--cflags|--cflags-only-I)
1364c8945a0SNathan Whitehorn		INCS=
137*a96ef450SBaptiste Daroussin		if test "$includedir" != /usr/include ; then
138*a96ef450SBaptiste Daroussin			INCS="-I$includedir"
1394c8945a0SNathan Whitehorn		fi
1404c8945a0SNathan Whitehorn		sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
1414c8945a0SNathan Whitehorn			$INCS
1424c8945a0SNathan WhitehornENDECHO
1434c8945a0SNathan Whitehorn		;;
144*a96ef450SBaptiste Daroussin	--cflags-only-other)
145*a96ef450SBaptiste Daroussin		# no -D/-U options should be needed
146*a96ef450SBaptiste Daroussin		echo
147*a96ef450SBaptiste Daroussin		;;
1484c8945a0SNathan Whitehorn	--libs)
149*a96ef450SBaptiste Daroussin		OPTS=
150*a96ef450SBaptiste Daroussin		for opt in $lib_flags
151*a96ef450SBaptiste Daroussin		do
152*a96ef450SBaptiste Daroussin			[ -n "$OPTS" ] && OPTS="$OPTS "
153*a96ef450SBaptiste Daroussin			OPTS="${OPTS}${opt}"
154*a96ef450SBaptiste Daroussin		done
155*a96ef450SBaptiste Daroussin		printf "%s\n" "$OPTS"
156*a96ef450SBaptiste Daroussin		;;
157*a96ef450SBaptiste Daroussin	--libs-only-L)
158*a96ef450SBaptiste Daroussin		OPTS=
159*a96ef450SBaptiste Daroussin		for opt in $lib_flags
160*a96ef450SBaptiste Daroussin		do
161*a96ef450SBaptiste Daroussin			case "x$opt" in
162*a96ef450SBaptiste Daroussin			x-L*)
163*a96ef450SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
164*a96ef450SBaptiste Daroussin				OPTS="${OPTS}${opt}"
165*a96ef450SBaptiste Daroussin				;;
166*a96ef450SBaptiste Daroussin			esac
167*a96ef450SBaptiste Daroussin		done
168*a96ef450SBaptiste Daroussin		printf "%s\n" "$OPTS"
169*a96ef450SBaptiste Daroussin		;;
170*a96ef450SBaptiste Daroussin	--libs-only-l)
171*a96ef450SBaptiste Daroussin		OPTS=
172*a96ef450SBaptiste Daroussin		for opt in $lib_flags
173*a96ef450SBaptiste Daroussin		do
174*a96ef450SBaptiste Daroussin			case "x$opt" in
175*a96ef450SBaptiste Daroussin			x-l*)
176*a96ef450SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
177*a96ef450SBaptiste Daroussin				OPTS="${OPTS}${opt}"
178*a96ef450SBaptiste Daroussin				;;
179*a96ef450SBaptiste Daroussin			esac
180*a96ef450SBaptiste Daroussin		done
181*a96ef450SBaptiste Daroussin		printf "%s\n" "$OPTS"
182*a96ef450SBaptiste Daroussin		;;
183*a96ef450SBaptiste Daroussin	--libs-only-other)
184*a96ef450SBaptiste Daroussin		OPTS=
185*a96ef450SBaptiste Daroussin		for opt in $lib_flags
186*a96ef450SBaptiste Daroussin		do
187*a96ef450SBaptiste Daroussin			case "x$opt" in
188*a96ef450SBaptiste Daroussin			x-[lL]*)
189*a96ef450SBaptiste Daroussin				;;
190*a96ef450SBaptiste Daroussin			*)
191*a96ef450SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
192*a96ef450SBaptiste Daroussin				OPTS="${OPTS}${opt}"
193*a96ef450SBaptiste Daroussin				;;
194*a96ef450SBaptiste Daroussin			esac
195*a96ef450SBaptiste Daroussin		done
196*a96ef450SBaptiste Daroussin		printf "%s\n" "$OPTS"
1974c8945a0SNathan Whitehorn		;;
1984c8945a0SNathan Whitehorn	# identification
1994c8945a0SNathan Whitehorn	--version)
2004c8945a0SNathan Whitehorn		echo "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
2014c8945a0SNathan Whitehorn		;;
2024c8945a0SNathan Whitehorn	--abi-version)
2034c8945a0SNathan Whitehorn		echo "@VERSION@" | sed -e 's/:/./g'
2044c8945a0SNathan Whitehorn		;;
2054c8945a0SNathan Whitehorn	# locations
2064c8945a0SNathan Whitehorn	--bindir)
2074c8945a0SNathan Whitehorn		echo "${bindir}"
2084c8945a0SNathan Whitehorn		;;
2094c8945a0SNathan Whitehorn	--datadir)
2104c8945a0SNathan Whitehorn		echo "${datadir}"
2114c8945a0SNathan Whitehorn		;;
2124c8945a0SNathan Whitehorn	--libdir)
2134c8945a0SNathan Whitehorn		echo "${libdir}"
2144c8945a0SNathan Whitehorn		;;
2154c8945a0SNathan Whitehorn	--mandir)
2164c8945a0SNathan Whitehorn		echo "${mandir}"
2174c8945a0SNathan Whitehorn		;;
2184c8945a0SNathan Whitehorn	# general info
2194c8945a0SNathan Whitehorn	--help)
2204c8945a0SNathan Whitehorn		cat <<ENDHELP
2214c8945a0SNathan WhitehornUsage: ${THIS}-config [options]
2224c8945a0SNathan Whitehorn
2234c8945a0SNathan WhitehornOptions:
2244c8945a0SNathan Whitehorn  --prefix           echos the package-prefix of ${THIS}
2254c8945a0SNathan Whitehorn  --prefix=ARG       sets the package-prefix of ${THIS}
2264c8945a0SNathan Whitehorn  --exec-prefix      echos the executable-prefix of ${THIS}
2274c8945a0SNathan Whitehorn  --exec-prefix=ARG  sets the executable-prefix of ${THIS}
2284c8945a0SNathan Whitehorn
2294c8945a0SNathan Whitehorn  --cflags           echos the C compiler flags needed to compile with ${THIS}
2304c8945a0SNathan Whitehorn  --libs             echos the libraries needed to link with ${THIS}
2314c8945a0SNathan Whitehorn
232*a96ef450SBaptiste Daroussin  --libs-only-L      echos -L linker options (search path) for ${THIS}
233*a96ef450SBaptiste Daroussin  --libs-only-l      echos -l linker options (libraries) for ${THIS}
234*a96ef450SBaptiste Daroussin  --libs-only-other  echos linker options other than -L/-l
235*a96ef450SBaptiste Daroussin
2364c8945a0SNathan Whitehorn  --version          echos the release+patchdate version of ${THIS}
2374c8945a0SNathan Whitehorn  --abi-version      echos the ABI version of ${THIS}
2384c8945a0SNathan Whitehorn
2394c8945a0SNathan Whitehorn  --bindir           echos the directory containing ${THIS} programs
2404c8945a0SNathan Whitehorn  --datadir          echos the directory containing ${THIS} data
2414c8945a0SNathan Whitehorn  --libdir           echos the directory containing ${THIS} libraries
242*a96ef450SBaptiste Daroussin  --mandir           echos the directory containing ${THIS} manual pages
2434c8945a0SNathan Whitehorn
2444c8945a0SNathan Whitehorn  --help             prints this message
2454c8945a0SNathan WhitehornENDHELP
2464c8945a0SNathan Whitehorn		;;
2474c8945a0SNathan Whitehorn	--error|*)
248*a96ef450SBaptiste Daroussin		@SHELL@ "$0" --help 1>&2
2494c8945a0SNathan Whitehorn		exit 1
2504c8945a0SNathan Whitehorn		;;
2514c8945a0SNathan Whitehorn	esac
2524c8945a0SNathan Whitehorn	shift
2534c8945a0SNathan Whitehorndone
2544c8945a0SNathan Whitehorn# vile:shmode
255