11034bfcdelphij#!@SHELL@
201cf73abapt# $Id: gen-pkgconfig.in,v 1.44 2020/02/12 00:09:26 tom Exp $
31034bfcdelphij##############################################################################
401cf73abapt# Copyright 2018-2019,2020 Thomas E. Dickey                                  #
501cf73abapt# Copyright 2009-2015,2018 Free Software Foundation, Inc.                    #
61034bfcdelphij#                                                                            #
71034bfcdelphij# Permission is hereby granted, free of charge, to any person obtaining a    #
81034bfcdelphij# copy of this software and associated documentation files (the "Software"), #
91034bfcdelphij# to deal in the Software without restriction, including without limitation  #
101034bfcdelphij# the rights to use, copy, modify, merge, publish, distribute, distribute    #
111034bfcdelphij# with modifications, sublicense, and/or sell copies of the Software, and to #
121034bfcdelphij# permit persons to whom the Software is furnished to do so, subject to the  #
131034bfcdelphij# following conditions:                                                      #
141034bfcdelphij#                                                                            #
151034bfcdelphij# The above copyright notice and this permission notice shall be included in #
161034bfcdelphij# all copies or substantial portions of the Software.                        #
171034bfcdelphij#                                                                            #
181034bfcdelphij# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
191034bfcdelphij# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
201034bfcdelphij# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
211034bfcdelphij# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
221034bfcdelphij# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
231034bfcdelphij# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
241034bfcdelphij# DEALINGS IN THE SOFTWARE.                                                  #
251034bfcdelphij#                                                                            #
261034bfcdelphij# Except as contained in this notice, the name(s) of the above copyright     #
271034bfcdelphij# holders shall not be used in advertising or otherwise to promote the sale, #
281034bfcdelphij# use or other dealings in this Software without prior written               #
291034bfcdelphij# authorization.                                                             #
301034bfcdelphij##############################################################################
311034bfcdelphij#
327dbeededelphij# Author: Thomas E. Dickey
331034bfcdelphij#
341034bfcdelphij# The complete configure script for ncurses is the ncurses5-config (or similar
351034bfcdelphij# name, depending on the flavor, e.g., ncursesw5-config, ncurses6-config, etc).
361034bfcdelphij# That provides more information than pkg-config, and is the portable and
371034bfcdelphij# recommended solution.
381034bfcdelphij#
391034bfcdelphij# For each library, generate a ".pc" file which depends on the base ncurses
401034bfcdelphij# library, except that the tinfo library does not depend on ncurses.
411034bfcdelphijLIB_NAME=@LIB_NAME@
421034bfcdelphijTINFO_NAME=@TINFO_NAME@
437dbeededelphijPANEL_NAME=@PANEL_NAME@
447dbeededelphijMENU_NAME=@MENU_NAME@
457dbeededelphijFORM_NAME=@FORM_NAME@
467dbeededelphijCXX_NAME=@CXX_NAME@
471034bfcdelphijDFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
481034bfcdelphijTINFO_ARG_SUFFIX=@TINFO_ARG_SUFFIX@
491034bfcdelphijCXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
501034bfcdelphij
51f52ca6ebaptsuffix=@PC_MODULE_SUFFIX@
521034bfcdelphijprefix="@prefix@"
531034bfcdelphijexec_prefix="@exec_prefix@"
547dbeededelphijincludedir="@includedir@@includesubdir@"
551034bfcdelphijlibdir="@libdir@"
561034bfcdelphij
57f52ca6ebaptRPATH_LIST=@RPATH_LIST@
58f52ca6ebaptPRIVATE_LIBS="@PRIVATE_LIBS@"
59f52ca6ebapt
601034bfcdelphijshow_prefix='@prefix@'
611034bfcdelphijshow_exec_prefix='@exec_prefix@'
627dbeededelphijshow_includedir='@includedir@@includesubdir@'
631034bfcdelphijshow_libdir='@libdir@'
641034bfcdelphij
65f52ca6ebaptMAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@"
661034bfcdelphijSUB_LIBRARY="${TINFO_ARG_SUFFIX}"
67f52ca6ebaptPANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@"
68f52ca6ebaptMENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@"
69f52ca6ebaptFORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@"
70f52ca6ebapt
71f52ca6ebaptCFLAGS="@PKG_CFLAGS@"
72f52ca6ebaptif [ "$includedir" != "/usr/include" ]; then
73f52ca6ebapt	includetop=`echo "$includedir" | sed -e 's,/include/[^/]*$,/include,'`
74f52ca6ebapt	[ "$includetop" = "/usr/include" ] && includetop="$includedir"
75f52ca6ebapt	CFLAGS="$CFLAGS -I\${includedir}"
76f52ca6ebapt	if [ "x$includetop" != "x$includedir" ]
77f52ca6ebapt	then
78f52ca6ebapt		CFLAGS="$CFLAGS -I${includetop}"
79f52ca6ebapt	fi
801034bfcdelphijfi
811034bfcdelphij
82f52ca6ebaptlib_flags=
83f52ca6ebaptfor opt in -L$libdir @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
84f52ca6ebaptdo
85f52ca6ebapt	case $opt in
86f52ca6ebapt	-l*) # LIBS is handled specially below
87f52ca6ebapt		continue
88f52ca6ebapt		;;
89f52ca6ebapt	-specs*) # ignore linker specs-files which were used to build library
90f52ca6ebapt		continue
91f52ca6ebapt		;;
92f52ca6ebapt	-Wl,-z,*) # ignore flags used to manipulate shared image
93f52ca6ebapt		continue
94f52ca6ebapt		;;
95f52ca6ebapt	-L*)
96f52ca6ebapt		[ -d ${opt##-L} ] || continue
97f52ca6ebapt		case ${opt##-L} in
98f52ca6ebapt		@LD_SEARCHPATH@) # skip standard libdir
99f52ca6ebapt			continue
100f52ca6ebapt			;;
101f52ca6ebapt		*)
102f52ca6ebapt			found=no
103f52ca6ebapt			for check in $lib_flags
104f52ca6ebapt			do
105f52ca6ebapt				if [ "x$check" = "x$opt" ]
106f52ca6ebapt				then
107f52ca6ebapt					found=yes
108f52ca6ebapt					break
109f52ca6ebapt				fi
110f52ca6ebapt			done
111f52ca6ebapt			[ $found = yes ] && continue
112f52ca6ebapt			;;
113f52ca6ebapt		esac
114f52ca6ebapt		;;
115f52ca6ebapt	esac
116f52ca6ebapt	lib_flags="$lib_flags $opt"
117f52ca6ebaptdone
118f52ca6ebapt
119f52ca6ebapt# Check if we should specify the tinfo library explicitly so that terminfo
120f52ca6ebapt# functions or curses variables (which also reside in tinfo) can be linked
121f52ca6ebapt# using the -lncurses option.
122f52ca6ebaptNEED_TINFO=no
123f52ca6ebaptif [ "x@TINFO_LIBS@" != "x" ] && \
124f52ca6ebapt   [ "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY" ]
125f52ca6ebaptthen
126f52ca6ebapt	NEED_TINFO=yes
1277dbeededelphijfi
1281034bfcdelphij
12901cf73abapt# The "URL" feature came in pkg-config 0.17
13001cf73abaptUSEURL=""
13101cf73abaptCFGVER=`pkg-config --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'`
13201cf73abapt# A missing version should simply fail, but some packagers insist on building
13301cf73abapt# packages on machines which do not actually have the tools they depend on at
13401cf73abapt# runtime.
13501cf73abapt[ -z "$CFGVER" ] && CFGVER=30
13601cf73abapt[ $CFGVER -ge 17 ] || USEURL="#"
13701cf73abapt
1387dbeededelphijfor name in @PC_MODULES_TO_MAKE@
1397dbeededelphijdo
1407dbeededelphij	name="${name}"
141f52ca6ebapt	LIBS="-l$name"
1421034bfcdelphij
1431034bfcdelphij	desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
1447dbeededelphij	reqs=
1457dbeededelphij
146f52ca6ebapt	if [ $name = $MAIN_LIBRARY ]; then
1471034bfcdelphij		desc="$desc library"
148f52ca6ebapt		[ $NEED_TINFO = yes ] && LIBS="$LIBS -l$TINFO_ARG_SUFFIX"
149f52ca6ebapt		[ -n "@LIBS@" ] && LIBS="$LIBS @LIBS@"
150f52ca6ebapt	elif [ $name = $SUB_LIBRARY ]; then
1511034bfcdelphij		desc="$desc terminal interface library"
1521034bfcdelphij	elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
153f52ca6ebapt		reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
1541034bfcdelphij		desc="$desc add-on library"
1551034bfcdelphij	else
156f52ca6ebapt		reqs="$MAIN_LIBRARY${suffix}"
1571034bfcdelphij		desc="$desc add-on library"
1581034bfcdelphij	fi
1591034bfcdelphij
160f52ca6ebapt	if [ $name != $SUB_LIBRARY ] && \
161f52ca6ebapt	   [ $SUB_LIBRARY != $MAIN_LIBRARY ] && \
162f52ca6ebapt	   [ $name != $TINFO_NAME ] && \
163f52ca6ebapt	   [ $NEED_TINFO != yes ] ; then
164f52ca6ebapt		[ -n "$reqs" ] && reqs="$reqs, "
165f52ca6ebapt		reqs="${reqs}${SUB_LIBRARY}${suffix}"
1661034bfcdelphij	fi
1671034bfcdelphij
168f52ca6ebapt	if [ $name = $MAIN_LIBRARY ]
169f52ca6ebapt	then
170f52ca6ebapt		main_libs="$PRIVATE_LIBS"
171f52ca6ebapt	else
172f52ca6ebapt		main_libs=
173f52ca6ebapt	fi
174f52ca6ebapt
175f52ca6ebapt	echo "** creating ${name}${suffix}.pc"
176f52ca6ebapt	cat >${name}${suffix}.pc <<EOF
177f52ca6ebapt# pkg-config file generated by `basename $0`
178f52ca6ebapt# vile:makemode
179f52ca6ebapt
1801034bfcdelphijprefix=$show_prefix
1811034bfcdelphijexec_prefix=$show_exec_prefix
1821034bfcdelphijlibdir=$show_libdir
1831034bfcdelphijincludedir=$show_includedir
184f52ca6ebaptabi_version=@cf_cv_abi_version@
1851034bfcdelphijmajor_version=@NCURSES_MAJOR@
1861034bfcdelphijversion=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
1871034bfcdelphij
188f52ca6ebaptName: ${name}${suffix}
1891034bfcdelphijDescription: $desc
1901034bfcdelphijVersion: \${version}
19101cf73abapt${USEURL}URL: https://invisible-island.net/ncurses
1927dbeededelphijRequires.private: $reqs
193f52ca6ebaptLibs: $lib_flags $LIBS
194f52ca6ebaptLibs.private: @LIBS@ $main_libs
1957dbeededelphijCflags: $CFLAGS
1961034bfcdelphijEOF
1977dbeededelphij
1981034bfcdelphijdone
199f52ca6ebapt# vile:shmode ts=4 sw=4
200