]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/gen-pkgconfig.in
ncurses 6.2 - patch 20200523
[ncurses.git] / misc / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.46 2020/05/23 17:56:46 tom Exp $
3 ##############################################################################
4 # Copyright 2018-2019,2020 Thomas E. Dickey                                  #
5 # Copyright 2009-2015,2018 Free Software Foundation, Inc.                    #
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@
47
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
58 RPATH_LIST=@RPATH_LIST@
59 PRIVATE_LIBS="@PRIVATE_LIBS@"
60
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}"
68
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@"
73
74 CFLAGS="@PKG_CFLAGS@"
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" ]
80         then
81                 CFLAGS="$CFLAGS -I${includetop}"
82         fi
83 fi
84
85 lib_flags=
86 for opt in -L$libdir @LDFLAGS@ @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         -L*)
99                 [ -d ${opt##-L} ] || continue
100                 case ${opt##-L} in
101                 @LD_SEARCHPATH@) # skip standard libdir
102                         continue
103                         ;;
104                 *)
105                         found=no
106                         for check in $lib_flags
107                         do
108                                 if [ "x$check" = "x$opt" ]
109                                 then
110                                         found=yes
111                                         break
112                                 fi
113                         done
114                         [ $found = yes ] && continue
115                         ;;
116                 esac
117                 ;;
118         esac
119         lib_flags="$lib_flags $opt"
120 done
121
122 # Check if we should specify the tinfo library explicitly so that terminfo
123 # functions or curses variables (which also reside in tinfo) can be linked
124 # using the -lncurses option.
125 NEED_TINFO=no
126 if [ "x@TINFO_LIBS@" != "x" ] && \
127    [ "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY" ]
128 then
129         NEED_TINFO=yes
130 fi
131
132 # The "URL" feature came in pkg-config 0.17
133 USEURL=""
134 CFGVER=`pkg-config --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'`
135 # A missing version should simply fail, but some packagers insist on building
136 # packages on machines which do not actually have the tools they depend on at
137 # runtime.
138 [ -z "$CFGVER" ] && CFGVER=30
139 [ $CFGVER -ge 17 ] || USEURL="#"
140
141 for name in @PC_MODULES_TO_MAKE@
142 do
143         name="${name}"
144         case $name in
145         form*)          name="$FORM_LIBRARY"    ;;
146         menu*)          name="$MENU_LIBRARY"    ;;
147         panel*)         name="$PANEL_LIBRARY"   ;;
148         ncurses++*)     name="$CXX_LIBRARY"             ;;
149         esac
150         LIBS="-l$name"
151
152         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
153         reqs=
154
155         if [ $name = $MAIN_LIBRARY ]; then
156                 desc="$desc library"
157                 [ $NEED_TINFO = yes ] && LIBS="$LIBS -l$TINFO_ARG_SUFFIX"
158                 [ -n "@LIBS@" ] && LIBS="$LIBS @LIBS@"
159         elif [ $name = $SUB_LIBRARY ]; then
160                 desc="$desc terminal interface library"
161         elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
162                 reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
163                 desc="$desc add-on library"
164         else
165                 reqs="$MAIN_LIBRARY${suffix}"
166                 desc="$desc add-on library"
167         fi
168
169         if [ $name != $SUB_LIBRARY ] && \
170            [ $SUB_LIBRARY != $MAIN_LIBRARY ] && \
171            [ $name != $TINFO_NAME ] && \
172            [ $NEED_TINFO != yes ] ; then
173                 [ -n "$reqs" ] && reqs="$reqs, "
174                 reqs="${reqs}${SUB_LIBRARY}${suffix}"
175         fi
176
177         if [ $name = $MAIN_LIBRARY ]
178         then
179                 main_libs="$PRIVATE_LIBS"
180         else
181                 main_libs=
182         fi
183
184         echo "** creating ${name}${suffix}.pc"
185         cat >${name}${suffix}.pc <<EOF
186 # pkg-config file generated by `basename $0`
187 # vile:makemode
188
189 prefix=$show_prefix
190 exec_prefix=$show_exec_prefix
191 libdir=$show_libdir
192 includedir=$show_includedir
193 abi_version=@cf_cv_abi_version@
194 major_version=@NCURSES_MAJOR@
195 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
196
197 Name: ${name}${suffix}
198 Description: $desc
199 Version: \${version}
200 ${USEURL}URL: https://invisible-island.net/ncurses
201 Requires.private: $reqs
202 Libs: $lib_flags $LIBS
203 Libs.private: @LIBS@ $main_libs
204 Cflags: $CFLAGS
205 EOF
206
207 done
208 # vile:shmode ts=4 sw=4