xref: /freebsd/contrib/ncurses/misc/ncurses-config.in (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
14a1a9510SRong-En Fan#!@SHELL@
2*21817992SBaptiste Daroussin# $Id: ncurses-config.in,v 1.52 2022/07/26 21:36:28 tom Exp $
34a1a9510SRong-En Fan##############################################################################
4*21817992SBaptiste Daroussin# Copyright 2018-2021,2022 Thomas E. Dickey                                  #
5e1865124SBaptiste Daroussin# Copyright 2006-2015,2017 Free Software Foundation, Inc.                    #
64a1a9510SRong-En Fan#                                                                            #
74a1a9510SRong-En Fan# Permission is hereby granted, free of charge, to any person obtaining a    #
84a1a9510SRong-En Fan# copy of this software and associated documentation files (the "Software"), #
94a1a9510SRong-En Fan# to deal in the Software without restriction, including without limitation  #
104a1a9510SRong-En Fan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
114a1a9510SRong-En Fan# with modifications, sublicense, and/or sell copies of the Software, and to #
124a1a9510SRong-En Fan# permit persons to whom the Software is furnished to do so, subject to the  #
134a1a9510SRong-En Fan# following conditions:                                                      #
144a1a9510SRong-En Fan#                                                                            #
154a1a9510SRong-En Fan# The above copyright notice and this permission notice shall be included in #
164a1a9510SRong-En Fan# all copies or substantial portions of the Software.                        #
174a1a9510SRong-En Fan#                                                                            #
184a1a9510SRong-En Fan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
194a1a9510SRong-En Fan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
204a1a9510SRong-En Fan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
214a1a9510SRong-En Fan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
224a1a9510SRong-En Fan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
234a1a9510SRong-En Fan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
244a1a9510SRong-En Fan# DEALINGS IN THE SOFTWARE.                                                  #
254a1a9510SRong-En Fan#                                                                            #
264a1a9510SRong-En Fan# Except as contained in this notice, the name(s) of the above copyright     #
274a1a9510SRong-En Fan# holders shall not be used in advertising or otherwise to promote the sale, #
284a1a9510SRong-En Fan# use or other dealings in this Software without prior written               #
294a1a9510SRong-En Fan# authorization.                                                             #
304a1a9510SRong-En Fan##############################################################################
314a1a9510SRong-En Fan#
3206bfebdeSXin LI# Author: Thomas E. Dickey, 2006-on
334a1a9510SRong-En Fan
3473f0a83dSXin LILANG=C;		export LANG
3573f0a83dSXin LILANGUAGE=C;	export LANGUAGE
3673f0a83dSXin LILC_ALL=C;	export LC_ALL
3773f0a83dSXin LILC_CTYPE=C;	export LC_CTYPE
3873f0a83dSXin LI
394a1a9510SRong-En Fanprefix="@prefix@"
404a1a9510SRong-En Fanexec_prefix="@exec_prefix@"
414a1a9510SRong-En Fan
424a1a9510SRong-En Fanbindir="@bindir@"
4306bfebdeSXin LIincludedir="@includedir@"
444a1a9510SRong-En Fanlibdir="@libdir@"
4573f0a83dSXin LIdatarootdir="@datarootdir@"
464a1a9510SRong-En Fandatadir="@datadir@"
474a1a9510SRong-En Fanmandir="@mandir@"
484a1a9510SRong-En Fan
49aae38d10SBaptiste DaroussinTHIS="@LIB_NAME@@USE_LIB_SUFFIX@"
5006bfebdeSXin LITINFO_LIB="@TINFO_ARG_SUFFIX@"
5173f0a83dSXin LIRPATH_LIST="@RPATH_LIST@"
524a1a9510SRong-En Fan
53aae38d10SBaptiste Daroussinincludesubdir="@includedir@/${THIS}"
54aae38d10SBaptiste Daroussin
5573f0a83dSXin LI# Ensure that RPATH_LIST contains only absolute pathnames, if it is nonempty.
5673f0a83dSXin LI# We cannot filter it out within the build-process since the variable is used
5773f0a83dSXin LI# in some special cases of installation using a relative path.
58aae38d10SBaptiste Daroussinif [ -n "$RPATH_LIST" ]
5973f0a83dSXin LIthen
6073f0a83dSXin LI	save_IFS="$IFS"
6173f0a83dSXin LI	IFS='@PATH_SEPARATOR@'
6273f0a83dSXin LI	filtered=
6373f0a83dSXin LI	for item in $RPATH_LIST
6473f0a83dSXin LI	do
6573f0a83dSXin LI		case "$item" in
6673f0a83dSXin LI		./*|../*|*/..|*/../*)
6773f0a83dSXin LI			;;
6873f0a83dSXin LI		*)
69aae38d10SBaptiste Daroussin			[ -n "$filtered" ] && filtered="${filtered}@PATH_SEPARATOR@"
7073f0a83dSXin LI			filtered="${filtered}${item}"
7173f0a83dSXin LI			;;
7273f0a83dSXin LI		esac
7373f0a83dSXin LI	done
7473f0a83dSXin LI	IFS="$save_IFS"
7573f0a83dSXin LI	# if the result is empty, there is little we can do to fix it
7673f0a83dSXin LI	RPATH_LIST="$filtered"
7773f0a83dSXin LIfi
785ca44d1cSRong-En Fan
7906bfebdeSXin LI# with --disable-overwrite, we installed into a subdirectory, but transformed
8006bfebdeSXin LI# the headers to include like this:
8106bfebdeSXin LI#	<ncurses@LIB_SUFFIX@/curses.h>
82aae38d10SBaptiste Daroussinif [ x@WITH_OVERWRITE@ = xno ]; then
8306bfebdeSXin LI	case $includedir in
84aae38d10SBaptiste Daroussin	$prefix/include/ncurses@LIB_SUFFIX@@EXTRA_SUFFIX@)
8506bfebdeSXin LI		includedir=`echo "$includedir" | sed -e 's,/[^/]*$,,'`
8606bfebdeSXin LI		;;
8706bfebdeSXin LI	esac
8806bfebdeSXin LIfi
8906bfebdeSXin LI
90aae38d10SBaptiste DaroussinLIBS="@LIBS@"
91aae38d10SBaptiste Daroussinif [ "@TINFO_NAME@" = "@LIB_NAME@" ]; then
92aae38d10SBaptiste Daroussin	LIBS="-l${THIS} $LIBS"
93aae38d10SBaptiste Daroussinelse
94aae38d10SBaptiste Daroussin	LIBS="-l${THIS} -l${TINFO_LIB} $LIBS"
95aae38d10SBaptiste Daroussinfi
964a1a9510SRong-En Fan
97aae38d10SBaptiste Daroussin# Ignore -L options which do not correspond to an actual directory, or which
98aae38d10SBaptiste Daroussin# are standard library directories (i.e., the linker is supposed to search
99aae38d10SBaptiste Daroussin# those directories).
100aae38d10SBaptiste Daroussin#
101aae38d10SBaptiste Daroussin# There is no portable way to find the list of standard library directories.
102aae38d10SBaptiste Daroussin# Require a POSIX shell anyway, to keep this simple.
103aae38d10SBaptiste Daroussinlib_flags=
104*21817992SBaptiste Daroussinfor opt in -L$libdir @EXTRA_PKG_LDFLAGS@ $LIBS
105aae38d10SBaptiste Daroussindo
106aae38d10SBaptiste Daroussin	case $opt in
107aae38d10SBaptiste Daroussin	-specs*) # ignore linker specs-files which were used to build library
108aae38d10SBaptiste Daroussin		continue
109aae38d10SBaptiste Daroussin		;;
110aae38d10SBaptiste Daroussin	-Wl,-z,*) # ignore flags used to manipulate shared image
111aae38d10SBaptiste Daroussin		continue
112aae38d10SBaptiste Daroussin		;;
113*21817992SBaptiste Daroussin	-Wl,--dynamic-linker*) # ignore ELF interpreter
114*21817992SBaptiste Daroussin		continue
115*21817992SBaptiste Daroussin		;;
116*21817992SBaptiste Daroussin	-Wl,--as-needed|-Wl,--build-id=*|-Wl,-dT,*|-Wl,-T,*)
117*21817992SBaptiste Daroussin		continue
118*21817992SBaptiste Daroussin		;;
119aae38d10SBaptiste Daroussin	-L*)
120*21817992SBaptiste Daroussin		lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
1217a656419SBaptiste Daroussin		[ -d "$lib_check" ] || continue
1227a656419SBaptiste Daroussin		case "$lib_check" in
123aae38d10SBaptiste Daroussin		@LD_SEARCHPATH@) # skip standard libdir
1247a656419SBaptiste Daroussin			if [ "$lib_check" = "$libdir" ]
1257a656419SBaptiste Daroussin			then
1267a656419SBaptiste Daroussin				lib_first=yes
1277a656419SBaptiste Daroussin				IFS_save="$IFS"
1287a656419SBaptiste Daroussin				IFS='|'
1297a656419SBaptiste Daroussin				LIBDIRS="@LD_SEARCHPATH@"
1307a656419SBaptiste Daroussin				for lib_check in $LIBDIRS
1317a656419SBaptiste Daroussin				do
1327a656419SBaptiste Daroussin					if [ -d "$lib_check" ]
1337a656419SBaptiste Daroussin					then
1347a656419SBaptiste Daroussin						if [ "$lib_check" != "$libdir" ]
1357a656419SBaptiste Daroussin						then
1367a656419SBaptiste Daroussin							lib_first=no
1377a656419SBaptiste Daroussin						fi
1387a656419SBaptiste Daroussin						break
1397a656419SBaptiste Daroussin					fi
1407a656419SBaptiste Daroussin				done
1417a656419SBaptiste Daroussin				IFS="$IFS_save"
1427a656419SBaptiste Daroussin				[ $lib_first = yes ] && continue
1437a656419SBaptiste Daroussin				found=no
1447a656419SBaptiste Daroussin				for check in $lib_flags
1457a656419SBaptiste Daroussin				do
1467a656419SBaptiste Daroussin					if [ "x$check" = "x$opt" ]
1477a656419SBaptiste Daroussin					then
1487a656419SBaptiste Daroussin						found=yes
1497a656419SBaptiste Daroussin						break
1507a656419SBaptiste Daroussin					fi
1517a656419SBaptiste Daroussin				done
1527a656419SBaptiste Daroussin				[ $found = yes ] && continue
1537a656419SBaptiste Daroussin				:
1547a656419SBaptiste Daroussin			else
155aae38d10SBaptiste Daroussin				continue
1567a656419SBaptiste Daroussin			fi
157aae38d10SBaptiste Daroussin			;;
158aae38d10SBaptiste Daroussin		*)
159aae38d10SBaptiste Daroussin			found=no
160aae38d10SBaptiste Daroussin			for check in $lib_flags
161aae38d10SBaptiste Daroussin			do
162aae38d10SBaptiste Daroussin				if [ "x$check" = "x$opt" ]
163aae38d10SBaptiste Daroussin				then
164aae38d10SBaptiste Daroussin					found=yes
165aae38d10SBaptiste Daroussin					break
166aae38d10SBaptiste Daroussin				fi
167aae38d10SBaptiste Daroussin			done
168aae38d10SBaptiste Daroussin			[ $found = yes ] && continue
169aae38d10SBaptiste Daroussin			;;
170aae38d10SBaptiste Daroussin		esac
171aae38d10SBaptiste Daroussin		;;
172aae38d10SBaptiste Daroussin	esac
173aae38d10SBaptiste Daroussin	lib_flags="$lib_flags $opt"
174aae38d10SBaptiste Daroussindone
175aae38d10SBaptiste Daroussin
176*21817992SBaptiste Daroussin[ $# = 0 ] && exec @SHELL@ "$0" --error
177aae38d10SBaptiste Daroussin
178aae38d10SBaptiste Daroussinwhile [ $# -gt 0 ]; do
1794a1a9510SRong-En Fan	case "$1" in
1804a1a9510SRong-En Fan	# basic configuration
1814a1a9510SRong-En Fan	--prefix)
1824a1a9510SRong-En Fan		echo "$prefix"
1834a1a9510SRong-En Fan		;;
1844a1a9510SRong-En Fan	--exec-prefix)
1854a1a9510SRong-En Fan		echo "$exec_prefix"
1864a1a9510SRong-En Fan		;;
1874a1a9510SRong-En Fan	# compile/link
1884a1a9510SRong-En Fan	--cflags)
189aae38d10SBaptiste Daroussin		INCS="@PKG_CFLAGS@"
190aae38d10SBaptiste Daroussin		if [ "x@WITH_OVERWRITE@" = xno ]; then
191aae38d10SBaptiste Daroussin			INCS="$INCS -I${includesubdir}"
1924a1a9510SRong-En Fan		fi
193aae38d10SBaptiste Daroussin		if [ "${includedir}" != /usr/include ]; then
19406bfebdeSXin LI			INCS="$INCS -I${includedir}"
1954a1a9510SRong-En Fan		fi
1964a1a9510SRong-En Fan		sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
1974a1a9510SRong-En Fan			$INCS
1984a1a9510SRong-En FanENDECHO
1994a1a9510SRong-En Fan		;;
2004a1a9510SRong-En Fan	--libs)
201aae38d10SBaptiste Daroussin		OPTS=
202aae38d10SBaptiste Daroussin		for opt in $lib_flags
203aae38d10SBaptiste Daroussin		do
204aae38d10SBaptiste Daroussin			[ -n "$OPTS" ] && OPTS="$OPTS "
205aae38d10SBaptiste Daroussin			OPTS="${OPTS}${opt}"
206aae38d10SBaptiste Daroussin		done
207*21817992SBaptiste Daroussin		printf '%s\n' "$OPTS"
208aae38d10SBaptiste Daroussin		;;
209aae38d10SBaptiste Daroussin	--libs-only-L)
210aae38d10SBaptiste Daroussin		OPTS=
211aae38d10SBaptiste Daroussin		for opt in $lib_flags
212aae38d10SBaptiste Daroussin		do
213aae38d10SBaptiste Daroussin			case "x$opt" in
214aae38d10SBaptiste Daroussin			x-L*)
215aae38d10SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
216aae38d10SBaptiste Daroussin				OPTS="${OPTS}${opt}"
217aae38d10SBaptiste Daroussin				;;
218aae38d10SBaptiste Daroussin			esac
219aae38d10SBaptiste Daroussin		done
220*21817992SBaptiste Daroussin		printf '%s\n' "$OPTS"
221aae38d10SBaptiste Daroussin		;;
222aae38d10SBaptiste Daroussin	--libs-only-l)
223aae38d10SBaptiste Daroussin		OPTS=
224aae38d10SBaptiste Daroussin		for opt in $lib_flags
225aae38d10SBaptiste Daroussin		do
226aae38d10SBaptiste Daroussin			case "x$opt" in
227aae38d10SBaptiste Daroussin			x-l*)
228aae38d10SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
229aae38d10SBaptiste Daroussin				OPTS="${OPTS}${opt}"
230aae38d10SBaptiste Daroussin				;;
231aae38d10SBaptiste Daroussin			esac
232aae38d10SBaptiste Daroussin		done
233*21817992SBaptiste Daroussin		printf '%s\n' "$OPTS"
234aae38d10SBaptiste Daroussin		;;
235aae38d10SBaptiste Daroussin	--libs-only-other)
236aae38d10SBaptiste Daroussin		OPTS=
237aae38d10SBaptiste Daroussin		for opt in $lib_flags
238aae38d10SBaptiste Daroussin		do
239aae38d10SBaptiste Daroussin			case "x$opt" in
240aae38d10SBaptiste Daroussin			x-[lL]*)
241aae38d10SBaptiste Daroussin				;;
242aae38d10SBaptiste Daroussin			*)
243aae38d10SBaptiste Daroussin				[ -n "$OPTS" ] && OPTS="$OPTS "
244aae38d10SBaptiste Daroussin				OPTS="${OPTS}${opt}"
245aae38d10SBaptiste Daroussin				;;
246aae38d10SBaptiste Daroussin			esac
247aae38d10SBaptiste Daroussin		done
248*21817992SBaptiste Daroussin		printf '%s\n' "$OPTS"
2494a1a9510SRong-En Fan		;;
2504a1a9510SRong-En Fan	# identification
2514a1a9510SRong-En Fan	--version)
2524a1a9510SRong-En Fan		echo "@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@"
2534a1a9510SRong-En Fan		;;
2544a1a9510SRong-En Fan	--abi-version)
2554a1a9510SRong-En Fan		echo "@cf_cv_abi_version@"
2564a1a9510SRong-En Fan		;;
2574a1a9510SRong-En Fan	--mouse-version)
2584a1a9510SRong-En Fan		echo "@NCURSES_MOUSE_VERSION@"
2594a1a9510SRong-En Fan		;;
2604a1a9510SRong-En Fan	# locations
2614a1a9510SRong-En Fan	--bindir)
2624a1a9510SRong-En Fan		echo "${bindir}"
2634a1a9510SRong-En Fan		;;
2644a1a9510SRong-En Fan	--datadir)
2654a1a9510SRong-En Fan		echo "${datadir}"
2664a1a9510SRong-En Fan		;;
26706bfebdeSXin LI	--includedir)
268aae38d10SBaptiste Daroussin		INCS=
269aae38d10SBaptiste Daroussin		if [ "x@WITH_OVERWRITE@" = xno ]; then
270aae38d10SBaptiste Daroussin			INCS="${includesubdir}"
271aae38d10SBaptiste Daroussin		elif [ "${includedir}" != /usr/include ]; then
272aae38d10SBaptiste Daroussin			INCS="${includedir}"
273aae38d10SBaptiste Daroussin		fi
274*21817992SBaptiste Daroussin		echo "$INCS"
27506bfebdeSXin LI		;;
2764a1a9510SRong-En Fan	--libdir)
2774a1a9510SRong-En Fan		echo "${libdir}"
2784a1a9510SRong-En Fan		;;
2794a1a9510SRong-En Fan	--mandir)
2804a1a9510SRong-En Fan		echo "${mandir}"
2814a1a9510SRong-En Fan		;;
2824a1a9510SRong-En Fan	--terminfo)
2834a1a9510SRong-En Fan		echo "@TERMINFO@"
2844a1a9510SRong-En Fan		;;
2854a1a9510SRong-En Fan	--terminfo-dirs)
2864a1a9510SRong-En Fan		echo "@TERMINFO_DIRS@"
2874a1a9510SRong-En Fan		;;
2884a1a9510SRong-En Fan	--termpath)
2894a1a9510SRong-En Fan		echo "@TERMPATH@"
2904a1a9510SRong-En Fan		;;
2914a1a9510SRong-En Fan	# general info
2924a1a9510SRong-En Fan	--help)
2934a1a9510SRong-En Fan		cat <<ENDHELP
294*21817992SBaptiste DaroussinUsage: `basename "$0"` [options]
2954a1a9510SRong-En Fan
2964a1a9510SRong-En FanOptions:
2974a1a9510SRong-En Fan  --prefix           echos the package-prefix of ${THIS}
2984a1a9510SRong-En Fan  --exec-prefix      echos the executable-prefix of ${THIS}
2994a1a9510SRong-En Fan
3004a1a9510SRong-En Fan  --cflags           echos the C compiler flags needed to compile with ${THIS}
3014a1a9510SRong-En Fan  --libs             echos the libraries needed to link with ${THIS}
3024a1a9510SRong-En Fan
303aae38d10SBaptiste Daroussin  --libs-only-L      echos -L linker options (search path) for ${THIS}
304aae38d10SBaptiste Daroussin  --libs-only-l      echos -l linker options (libraries) for ${THIS}
305aae38d10SBaptiste Daroussin  --libs-only-other  echos linker options other than -L/-l
306aae38d10SBaptiste Daroussin
3074a1a9510SRong-En Fan  --version          echos the release+patchdate version of ${THIS}
3084a1a9510SRong-En Fan  --abi-version      echos the ABI version of ${THIS}
3094a1a9510SRong-En Fan  --mouse-version    echos the mouse-interface version of ${THIS}
3104a1a9510SRong-En Fan
3114a1a9510SRong-En Fan  --bindir           echos the directory containing ${THIS} programs
3124a1a9510SRong-En Fan  --datadir          echos the directory containing ${THIS} data
31306bfebdeSXin LI  --includedir       echos the directory containing ${THIS} header files
3144a1a9510SRong-En Fan  --libdir           echos the directory containing ${THIS} libraries
3154a1a9510SRong-En Fan  --mandir           echos the directory containing ${THIS} manpages
3164a1a9510SRong-En Fan  --terminfo         echos the \$TERMINFO terminfo database path
3174a1a9510SRong-En Fan  --terminfo-dirs    echos the \$TERMINFO_DIRS directory list
3184a1a9510SRong-En Fan  --termpath         echos the \$TERMPATH termcap list
3194a1a9510SRong-En Fan
3204a1a9510SRong-En Fan  --help             prints this message
3214a1a9510SRong-En FanENDHELP
3224a1a9510SRong-En Fan		;;
3234a1a9510SRong-En Fan	--error|*)
324*21817992SBaptiste Daroussin		@SHELL@ "$0" --help 1>&2
3254a1a9510SRong-En Fan		exit 1
3264a1a9510SRong-En Fan		;;
3274a1a9510SRong-En Fan	esac
3284a1a9510SRong-En Fan	shift
3294a1a9510SRong-En Fandone
33073f0a83dSXin LI# vi:ts=4 sw=4
3314a1a9510SRong-En Fan# vile:shmode
332