xref: /freebsd/contrib/dialog/dialog-config.in (revision 4c8945a0)
14c8945a0SNathan Whitehorn#!@SHELL@
24c8945a0SNathan Whitehorn# $Id: dialog-config.in,v 1.13 2019/09/26 00:50:46 tom Exp $
34c8945a0SNathan Whitehorn##############################################################################
44c8945a0SNathan Whitehorn# 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@"
334c8945a0SNathan Whitehorndatarootdir="@datarootdir@"
344c8945a0SNathan Whitehorn
354c8945a0SNathan Whitehornsame_prefix=yes
364c8945a0SNathan Whitehornsame_exec_prefix=yes
374c8945a0SNathan Whitehorn
384c8945a0SNathan WhitehornTHIS="@PACKAGE@"
394c8945a0SNathan Whitehorn
404c8945a0SNathan Whitehorntest $# = 0 && exec @SHELL@ "$0" --error
414c8945a0SNathan Whitehorn
424c8945a0SNathan Whitehornwhile test $# -gt 0; do
434c8945a0SNathan Whitehorn
444c8945a0SNathan Whitehorn	# (re)evaluate symbols that may depend upon $prefix
454c8945a0SNathan Whitehorn	if [ "x$same_prefix" != "xyes" ]
464c8945a0SNathan Whitehorn	then
474c8945a0SNathan Whitehorn		eval exec_prefix='@exec_prefix@'
484c8945a0SNathan Whitehorn		eval datarootdir='@datarootdir@'
494c8945a0SNathan Whitehorn	elif [ "x$same_exec_prefix" != "xyes" ]
504c8945a0SNathan Whitehorn	then
514c8945a0SNathan Whitehorn		eval datarootdir='@datarootdir@'
524c8945a0SNathan Whitehorn	fi
534c8945a0SNathan Whitehorn
544c8945a0SNathan Whitehorn	eval bindir='"@bindir@"'
554c8945a0SNathan Whitehorn	eval includedir='"@includedir@"'
564c8945a0SNathan Whitehorn	eval libdir='"@libdir@"'
574c8945a0SNathan Whitehorn	eval datadir='"@datadir@"'
584c8945a0SNathan Whitehorn	eval mandir='"@mandir@"'
594c8945a0SNathan Whitehorn
604c8945a0SNathan Whitehorn	[ -z "$includedir" ] && includedir="${prefix}/include"
614c8945a0SNathan Whitehorn
624c8945a0SNathan Whitehorn	eval LDFLAGS='"@LDFLAGS@"'
634c8945a0SNathan Whitehorn	eval LIBS='"@LIBS@"'
644c8945a0SNathan Whitehorn	LIBS="-l${THIS} $LIBS"
654c8945a0SNathan Whitehorn
664c8945a0SNathan Whitehorn	# If the directory given by --libdir is not in the LDFLAGS+LIBS set,
674c8945a0SNathan Whitehorn	# prepend it to LDFLAGS to help link this application's library.
684c8945a0SNathan Whitehorn	found=no
694c8945a0SNathan Whitehorn	for opt in $LDFLAGS $LIBS
704c8945a0SNathan Whitehorn	do
714c8945a0SNathan Whitehorn		if [ "x$-L${libdir}" = "x$opt" ]
724c8945a0SNathan Whitehorn		then
734c8945a0SNathan Whitehorn			found=yes
744c8945a0SNathan Whitehorn			break
754c8945a0SNathan Whitehorn		fi
764c8945a0SNathan Whitehorn	done
774c8945a0SNathan Whitehorn	if [ $found = no ]
784c8945a0SNathan Whitehorn	then
794c8945a0SNathan Whitehorn		[ -n "$LFLAGS" ] && LDFLAGS=" $LFDLAGS"
804c8945a0SNathan Whitehorn		LDFLAGS="-L${libdir}$LDFLAGS"
814c8945a0SNathan Whitehorn	fi
824c8945a0SNathan Whitehorn	[ -z "$LDFLAGS" ] && LDFLAGS="-L${exec_prefix}/lib"
834c8945a0SNathan Whitehorn
844c8945a0SNathan Whitehorn	# Ignore -L options which do not correspond to an actual directory,
854c8945a0SNathan Whitehorn	# or which are standard library directories (i.e., the linker is
864c8945a0SNathan Whitehorn	# supposed to search those directories).
874c8945a0SNathan Whitehorn	#
884c8945a0SNathan Whitehorn	# There is no portable way to find the list of standard library
894c8945a0SNathan Whitehorn	# directories.  Require a POSIX shell anyway, to keep this simple.
904c8945a0SNathan Whitehorn	lib_flags=
914c8945a0SNathan Whitehorn	for opt in $LDFLAGS $LIBS
924c8945a0SNathan Whitehorn	do
934c8945a0SNathan Whitehorn		case $opt in
944c8945a0SNathan Whitehorn		-L*)
954c8945a0SNathan Whitehorn			[ -d ${opt##-L} ] || continue
964c8945a0SNathan Whitehorn			case ${opt##-L} in
974c8945a0SNathan Whitehorn			@LD_SEARCHPATH@) # skip standard libdir
984c8945a0SNathan Whitehorn				continue
994c8945a0SNathan Whitehorn				;;
1004c8945a0SNathan Whitehorn			*)
1014c8945a0SNathan Whitehorn				;;
1024c8945a0SNathan Whitehorn			esac
1034c8945a0SNathan Whitehorn			;;
1044c8945a0SNathan Whitehorn		esac
1054c8945a0SNathan Whitehorn		lib_flags="$lib_flags $opt"
1064c8945a0SNathan Whitehorn	done
1074c8945a0SNathan Whitehorn
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"
1224c8945a0SNathan Whitehorn		same_prefix=no
1234c8945a0SNathan Whitehorn		;;
1244c8945a0SNathan Whitehorn	--prefix)
1254c8945a0SNathan Whitehorn		echo "$prefix"
1264c8945a0SNathan Whitehorn		;;
1274c8945a0SNathan Whitehorn	--exec-prefix=*)
1284c8945a0SNathan Whitehorn		exec_prefix="$ARG"
1294c8945a0SNathan Whitehorn		same_exec_prefix=no
1304c8945a0SNathan Whitehorn		;;
1314c8945a0SNathan Whitehorn	--exec-prefix)
1324c8945a0SNathan Whitehorn		echo "$exec_prefix"
1334c8945a0SNathan Whitehorn		;;
1344c8945a0SNathan Whitehorn	# compile/link
1354c8945a0SNathan Whitehorn	--cflags|--cflags-only-I)
136		INCS=
137		if test "$includedir" != /usr/include ; then
138			INCS="-I$includedir"
139		fi
140		sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
141			$INCS
142ENDECHO
143		;;
144	--cflags-only-other)
145		# no -D/-U options should be needed
146		echo
147		;;
148	--libs)
149		OPTS=
150		for opt in $lib_flags
151		do
152			[ -n "$OPTS" ] && OPTS="$OPTS "
153			OPTS="${OPTS}${opt}"
154		done
155		printf "%s\n" "$OPTS"
156		;;
157	--libs-only-L)
158		OPTS=
159		for opt in $lib_flags
160		do
161			case "x$opt" in
162			x-L*)
163				[ -n "$OPTS" ] && OPTS="$OPTS "
164				OPTS="${OPTS}${opt}"
165				;;
166			esac
167		done
168		printf "%s\n" "$OPTS"
169		;;
170	--libs-only-l)
171		OPTS=
172		for opt in $lib_flags
173		do
174			case "x$opt" in
175			x-l*)
176				[ -n "$OPTS" ] && OPTS="$OPTS "
177				OPTS="${OPTS}${opt}"
178				;;
179			esac
180		done
181		printf "%s\n" "$OPTS"
182		;;
183	--libs-only-other)
184		OPTS=
185		for opt in $lib_flags
186		do
187			case "x$opt" in
188			x-[lL]*)
189				;;
190			*)
191				[ -n "$OPTS" ] && OPTS="$OPTS "
192				OPTS="${OPTS}${opt}"
193				;;
194			esac
195		done
196		printf "%s\n" "$OPTS"
197		;;
198	# identification
199	--version)
200		echo "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
201		;;
202	--abi-version)
203		echo "@VERSION@" | sed -e 's/:/./g'
204		;;
205	# locations
206	--bindir)
207		echo "${bindir}"
208		;;
209	--datadir)
210		echo "${datadir}"
211		;;
212	--libdir)
213		echo "${libdir}"
214		;;
215	--mandir)
216		echo "${mandir}"
217		;;
218	# general info
219	--help)
220		cat <<ENDHELP
221Usage: ${THIS}-config [options]
222
223Options:
224  --prefix           echos the package-prefix of ${THIS}
225  --prefix=ARG       sets the package-prefix of ${THIS}
226  --exec-prefix      echos the executable-prefix of ${THIS}
227  --exec-prefix=ARG  sets the executable-prefix of ${THIS}
228
229  --cflags           echos the C compiler flags needed to compile with ${THIS}
230  --libs             echos the libraries needed to link with ${THIS}
231
232  --libs-only-L      echos -L linker options (search path) for ${THIS}
233  --libs-only-l      echos -l linker options (libraries) for ${THIS}
234  --libs-only-other  echos linker options other than -L/-l
235
236  --version          echos the release+patchdate version of ${THIS}
237  --abi-version      echos the ABI version of ${THIS}
238
239  --bindir           echos the directory containing ${THIS} programs
240  --datadir          echos the directory containing ${THIS} data
241  --libdir           echos the directory containing ${THIS} libraries
242  --mandir           echos the directory containing ${THIS} manual pages
243
244  --help             prints this message
245ENDHELP
246		;;
247	--error|*)
248		@SHELL@ "$0" --help 1>&2
249		exit 1
250		;;
251	esac
252	shift
253done
254# vile:shmode
255