Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 1 | #!@SHELL@ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | # $Id: gen-pkgconfig.in,v 1.56 2022/10/08 16:45:20 tom Exp $ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 3 | ############################################################################## |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 4 | # Copyright 2018-2021,2022 Thomas E. Dickey # |
| 5 | # Copyright 2009-2015,2018 Free Software Foundation, Inc. # |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 6 | # # |
| 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: # |
| 14 | # # |
| 15 | # The above copyright notice and this permission notice shall be included in # |
| 16 | # all copies or substantial portions of the Software. # |
| 17 | # # |
| 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. # |
| 25 | # # |
| 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 # |
| 29 | # authorization. # |
| 30 | ############################################################################## |
| 31 | # |
| 32 | # Author: Thomas E. Dickey |
| 33 | # |
| 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. |
| 38 | # |
| 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. |
| 41 | LIB_NAME=@LIB_NAME@ |
| 42 | TINFO_NAME=@TINFO_NAME@ |
| 43 | PANEL_NAME=@PANEL_NAME@ |
| 44 | MENU_NAME=@MENU_NAME@ |
| 45 | FORM_NAME=@FORM_NAME@ |
| 46 | CXX_NAME=@CXX_NAME@ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 47 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 48 | DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@ |
| 49 | TINFO_ARG_SUFFIX=@TINFO_ARG_SUFFIX@ |
| 50 | CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@ |
| 51 | |
| 52 | suffix=@PC_MODULE_SUFFIX@ |
| 53 | prefix="@prefix@" |
| 54 | exec_prefix="@exec_prefix@" |
| 55 | includedir="@includedir@@includesubdir@" |
| 56 | libdir="@libdir@" |
| 57 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 58 | RPATH_LIST=@RPATH_LIST@ |
| 59 | PRIVATE_LIBS="@PRIVATE_LIBS@" |
| 60 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 61 | show_prefix='@prefix@' |
| 62 | show_exec_prefix='@exec_prefix@' |
| 63 | show_includedir='@includedir@@includesubdir@' |
| 64 | show_libdir='@libdir@' |
| 65 | |
| 66 | MAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@" |
| 67 | SUB_LIBRARY="${TINFO_ARG_SUFFIX}" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 68 | |
| 69 | CXX_LIBRARY="${CXX_NAME}@USE_ARG_SUFFIX@" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 70 | FORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 71 | MENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@" |
| 72 | PANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 73 | |
| 74 | CFLAGS="@PKG_CFLAGS@" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 75 | if [ "$includedir" != "/usr/include" ]; then |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 76 | includetop=`echo "$includedir" | sed -e 's,/include/[^/]*$,/include,'` |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 77 | [ "$includetop" = "/usr/include" ] && includetop="$includedir" |
| 78 | CFLAGS="$CFLAGS -I\${includedir}" |
| 79 | if [ "x$includetop" != "x$includedir" ] |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 80 | then |
| 81 | CFLAGS="$CFLAGS -I${includetop}" |
| 82 | fi |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 83 | fi |
| 84 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 85 | lib_flags= |
| 86 | for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ @LIBS@ |
| 87 | do |
| 88 | case $opt in |
| 89 | -l*) # LIBS is handled specially below |
| 90 | continue |
| 91 | ;; |
| 92 | -specs*) # ignore linker specs-files which were used to build library |
| 93 | continue |
| 94 | ;; |
| 95 | -Wl,-z,*) # ignore flags used to manipulate shared image |
| 96 | continue |
| 97 | ;; |
| 98 | -Wl,--dynamic-linker*) # ignore ELF interpreter |
| 99 | continue |
| 100 | ;; |
| 101 | -Wl,--as-needed|-Wl,--build-id=*|-Wl,-dT,*|-Wl,-T,*) |
| 102 | continue |
| 103 | ;; |
| 104 | -L*) |
| 105 | lib_check=`echo "x$opt" | sed -e 's/^.-L//'` |
| 106 | # on a new/nonstandard install, $libdir may not yet exist at this point |
| 107 | if [ "$libdir" != "$lib_check" ] |
| 108 | then |
| 109 | [ -d "$lib_check" ] || continue |
| 110 | fi |
| 111 | case "$lib_check" in |
| 112 | @LD_SEARCHPATH@) # skip standard libdir |
| 113 | if [ "$lib_check" = "$libdir" ] |
| 114 | then |
| 115 | lib_first=yes |
| 116 | IFS_save="$IFS" |
| 117 | IFS='|' |
| 118 | LIBDIRS="@LD_SEARCHPATH@" |
| 119 | for lib_check in $LIBDIRS |
| 120 | do |
| 121 | if [ -d "$lib_check" ] |
| 122 | then |
| 123 | if [ "$lib_check" != "$libdir" ] |
| 124 | then |
| 125 | lib_first=no |
| 126 | fi |
| 127 | break |
| 128 | fi |
| 129 | done |
| 130 | IFS="$IFS_save" |
| 131 | [ $lib_first = yes ] && continue |
| 132 | found=no |
| 133 | for check in $lib_flags |
| 134 | do |
| 135 | if [ "x$check" = "x$opt" ] |
| 136 | then |
| 137 | found=yes |
| 138 | break |
| 139 | fi |
| 140 | done |
| 141 | [ $found = yes ] && continue |
| 142 | : |
| 143 | else |
| 144 | continue |
| 145 | fi |
| 146 | ;; |
| 147 | *) |
| 148 | found=no |
| 149 | for check in $lib_flags |
| 150 | do |
| 151 | if [ "x$check" = "x$opt" ] |
| 152 | then |
| 153 | found=yes |
| 154 | break |
| 155 | fi |
| 156 | done |
| 157 | [ $found = yes ] && continue |
| 158 | ;; |
| 159 | esac |
| 160 | ;; |
| 161 | esac |
| 162 | lib_flags="$lib_flags $opt" |
| 163 | done |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 164 | |
| 165 | # Check if we should specify the tinfo library explicitly so that terminfo |
| 166 | # functions or curses variables (which also reside in tinfo) can be linked |
| 167 | # using the -lncurses option. |
| 168 | NEED_TINFO=no |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 169 | if [ "x@TINFO_LIBS@" != "x" ] && \ |
| 170 | [ "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY" ] |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 171 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 172 | NEED_TINFO=yes |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 173 | fi |
| 174 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 175 | # The "URL" feature came in pkg-config 0.17 |
| 176 | USEURL="" |
| 177 | CFGVER=`${PKG_CONFIG:-pkg-config} --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'` |
| 178 | # A missing version should simply fail, but some packagers insist on building |
| 179 | # packages on machines which do not actually have the tools they depend on at |
| 180 | # runtime. |
| 181 | [ -z "$CFGVER" ] && CFGVER=30 |
| 182 | [ $CFGVER -ge 17 ] || USEURL="#" |
| 183 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 184 | for name in @PC_MODULES_TO_MAKE@ |
| 185 | do |
| 186 | name="${name}" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 187 | case $name in |
| 188 | form*) name="$FORM_LIBRARY" ;; |
| 189 | menu*) name="$MENU_LIBRARY" ;; |
| 190 | panel*) name="$PANEL_LIBRARY" ;; |
| 191 | ncurses++*) name="$CXX_LIBRARY" ;; |
| 192 | esac |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 193 | LIBS="-l$name" |
| 194 | |
| 195 | desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" |
| 196 | reqs= |
| 197 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 198 | if [ $name = $MAIN_LIBRARY ]; then |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 199 | desc="$desc library" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 200 | [ $NEED_TINFO = yes ] && LIBS="$LIBS -l$TINFO_ARG_SUFFIX" |
| 201 | [ -n "@LIBS@" ] && LIBS="$LIBS @LIBS@" |
| 202 | elif [ $name = $SUB_LIBRARY ]; then |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 203 | desc="$desc terminal interface library" |
| 204 | elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then |
| 205 | reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}" |
| 206 | desc="$desc add-on library" |
| 207 | else |
| 208 | reqs="$MAIN_LIBRARY${suffix}" |
| 209 | desc="$desc add-on library" |
| 210 | fi |
| 211 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 212 | if [ $name != $SUB_LIBRARY ] && \ |
| 213 | [ $SUB_LIBRARY != $MAIN_LIBRARY ] && \ |
| 214 | [ $name != $TINFO_NAME ] && \ |
| 215 | [ $NEED_TINFO != yes ] ; then |
| 216 | [ -n "$reqs" ] && reqs="$reqs, " |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 217 | reqs="${reqs}${SUB_LIBRARY}${suffix}" |
| 218 | fi |
| 219 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 220 | if [ $name = $MAIN_LIBRARY ] |
| 221 | then |
| 222 | main_libs="$PRIVATE_LIBS" |
| 223 | else |
| 224 | main_libs= |
| 225 | fi |
| 226 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 227 | echo "** creating ${name}${suffix}.pc" |
| 228 | cat >${name}${suffix}.pc <<EOF |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 229 | # pkg-config file generated by `basename "$0"` |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 230 | # vile:makemode |
| 231 | |
| 232 | prefix=$show_prefix |
| 233 | exec_prefix=$show_exec_prefix |
| 234 | libdir=$show_libdir |
| 235 | includedir=$show_includedir |
| 236 | abi_version=@cf_cv_abi_version@ |
| 237 | major_version=@NCURSES_MAJOR@ |
| 238 | version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@ |
| 239 | |
| 240 | Name: ${name}${suffix} |
| 241 | Description: $desc |
| 242 | Version: \${version} |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 243 | ${USEURL}URL: https://invisible-island.net/ncurses |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 244 | Requires.private: $reqs |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 245 | Libs: $lib_flags $LIBS |
| 246 | Libs.private: @LIBS@ $main_libs |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 247 | Cflags: $CFLAGS |
| 248 | EOF |
| 249 | |
| 250 | done |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 251 | # vile:shmode ts=4 sw=4 |