2 # $Id: gen-pkgconfig.in,v 1.52 2021/08/07 21:36:33 tom Exp $
3 ##############################################################################
4 # Copyright 2018-2020,2021 Thomas E. Dickey #
5 # Copyright 2009-2015,2018 Free Software Foundation, Inc. #
7 # Permission is hereby granted, free of charge, to any person obtaining a #
8 # copy of this software and associated documentation files (the "Software"), #
9 # to deal in the Software without restriction, including without limitation #
10 # the rights to use, copy, modify, merge, publish, distribute, distribute #
11 # with modifications, sublicense, and/or sell copies of the Software, and to #
12 # permit persons to whom the Software is furnished to do so, subject to the #
13 # following conditions: #
15 # The above copyright notice and this permission notice shall be included in #
16 # all copies or substantial portions of the Software. #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
21 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
23 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
24 # DEALINGS IN THE SOFTWARE. #
26 # Except as contained in this notice, the name(s) of the above copyright #
27 # holders shall not be used in advertising or otherwise to promote the sale, #
28 # use or other dealings in this Software without prior written #
30 ##############################################################################
32 # Author: Thomas E. Dickey
34 # The complete configure script for ncurses is the ncurses5-config (or similar
35 # name, depending on the flavor, e.g., ncursesw5-config, ncurses6-config, etc).
36 # That provides more information than pkg-config, and is the portable and
37 # recommended solution.
39 # For each library, generate a ".pc" file which depends on the base ncurses
40 # library, except that the tinfo library does not depend on ncurses.
42 TINFO_NAME=@TINFO_NAME@
43 PANEL_NAME=@PANEL_NAME@
48 DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
49 TINFO_ARG_SUFFIX=@TINFO_ARG_SUFFIX@
50 CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
52 suffix=@PC_MODULE_SUFFIX@
54 exec_prefix="@exec_prefix@"
55 includedir="@includedir@@includesubdir@"
58 RPATH_LIST=@RPATH_LIST@
59 PRIVATE_LIBS="@PRIVATE_LIBS@"
61 show_prefix='@prefix@'
62 show_exec_prefix='@exec_prefix@'
63 show_includedir='@includedir@@includesubdir@'
64 show_libdir='@libdir@'
66 MAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@"
67 SUB_LIBRARY="${TINFO_ARG_SUFFIX}"
69 CXX_LIBRARY="${CXX_NAME}@USE_ARG_SUFFIX@"
70 FORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@"
71 MENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@"
72 PANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@"
75 if [ "$includedir" != "/usr/include" ]; then
76 includetop=`echo "$includedir" | sed -e 's,/include/[^/]*$,/include,'`
77 [ "$includetop" = "/usr/include" ] && includetop="$includedir"
78 CFLAGS="$CFLAGS -I\${includedir}"
79 if [ "x$includetop" != "x$includedir" ]
81 CFLAGS="$CFLAGS -I${includetop}"
86 for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ @LIBS@
89 -l*) # LIBS is handled specially below
92 -specs*) # ignore linker specs-files which were used to build library
95 -Wl,-z,*) # ignore flags used to manipulate shared image
98 -Wl,--dynamic-linker*) # ignore ELF interpreter
102 lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
103 [ -d "$lib_check" ] || continue
105 @LD_SEARCHPATH@) # skip standard libdir
106 if [ "$lib_check" = "$libdir" ]
111 LIBDIRS="@LD_SEARCHPATH@"
112 for lib_check in $LIBDIRS
114 if [ -d "$lib_check" ]
116 if [ "$lib_check" != "$libdir" ]
124 [ $lib_first = yes ] && continue
126 for check in $lib_flags
128 if [ "x$check" = "x$opt" ]
134 [ $found = yes ] && continue
142 for check in $lib_flags
144 if [ "x$check" = "x$opt" ]
150 [ $found = yes ] && continue
155 lib_flags="$lib_flags $opt"
158 # Check if we should specify the tinfo library explicitly so that terminfo
159 # functions or curses variables (which also reside in tinfo) can be linked
160 # using the -lncurses option.
162 if [ "x@TINFO_LIBS@" != "x" ] && \
163 [ "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY" ]
168 # The "URL" feature came in pkg-config 0.17
170 CFGVER=`pkg-config --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'`
171 # A missing version should simply fail, but some packagers insist on building
172 # packages on machines which do not actually have the tools they depend on at
174 [ -z "$CFGVER" ] && CFGVER=30
175 [ $CFGVER -ge 17 ] || USEURL="#"
177 for name in @PC_MODULES_TO_MAKE@
181 form*) name="$FORM_LIBRARY" ;;
182 menu*) name="$MENU_LIBRARY" ;;
183 panel*) name="$PANEL_LIBRARY" ;;
184 ncurses++*) name="$CXX_LIBRARY" ;;
188 desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
191 if [ $name = $MAIN_LIBRARY ]; then
193 [ $NEED_TINFO = yes ] && LIBS="$LIBS -l$TINFO_ARG_SUFFIX"
194 [ -n "@LIBS@" ] && LIBS="$LIBS @LIBS@"
195 elif [ $name = $SUB_LIBRARY ]; then
196 desc="$desc terminal interface library"
197 elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
198 reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
199 desc="$desc add-on library"
201 reqs="$MAIN_LIBRARY${suffix}"
202 desc="$desc add-on library"
205 if [ $name != $SUB_LIBRARY ] && \
206 [ $SUB_LIBRARY != $MAIN_LIBRARY ] && \
207 [ $name != $TINFO_NAME ] && \
208 [ $NEED_TINFO != yes ] ; then
209 [ -n "$reqs" ] && reqs="$reqs, "
210 reqs="${reqs}${SUB_LIBRARY}${suffix}"
213 if [ $name = $MAIN_LIBRARY ]
215 main_libs="$PRIVATE_LIBS"
220 echo "** creating ${name}${suffix}.pc"
221 cat >${name}${suffix}.pc <<EOF
222 # pkg-config file generated by `basename $0`
226 exec_prefix=$show_exec_prefix
228 includedir=$show_includedir
229 abi_version=@cf_cv_abi_version@
230 major_version=@NCURSES_MAJOR@
231 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
233 Name: ${name}${suffix}
236 ${USEURL}URL: https://invisible-island.net/ncurses
237 Requires.private: $reqs
238 Libs: $lib_flags $LIBS
239 Libs.private: @LIBS@ $main_libs
244 # vile:shmode ts=4 sw=4